How to create installlable modules
premak
created: 2006-01-10 06:54:47
Any idea abt how to create a installable packages in perl.i am using h2xs utility. It creates the Makefile.pl. But in my requirement i need to check some modules are present in system before installing the module. Also version of the module is important. If it is older version i need to install the new version. So plz help me
Re: How to create installlable modules
cog
created: 2006-01-10 07:01:46
Hi, premak.

I'd suggest you'd take a look at José's Guide for creating Perl modules, because there's clearly more information there that you'll need.

Search for "PREREQ_PM" in that document. I think you'll find what you want.

HTH.

Re^2: How to create installable modules ?
blm
created: 2006-01-11 07:06:11

Perhaps we should be suggesting resources that detail the use of the new methods that do not rely on ExtUtils::MakeMaker? At least that is the feeling I get from reading slides from Michael Schwern's presentation "MakeMaker is Doomed". In this talk he recommends Module::Build. The quote that stuck in my mind that stuck in my mind from those slides was when Michael Schwern says:

I'm sick of maintaining MakeMaker, let it fade away."

Perhaps I should get stuck into updating that tutorial or writing a new one.

Re^3: How to create installable modules ?
created: 2006-01-11 22:56:39
Perhaps we should be suggesting resources that detail the use of the new methods that do not rely on ExtUtils::MakeMaker? At least that is the feeling I get from reading slides from Michael Schwern's presentation "MakeMaker is Doomed". In this talk he recommends Module::Build.
MakeMaker cannot really begin to fade away until Module::Build is part of the Perl core distribution. I've heard talk that that will happen with 5.10, but, AFAICT, it hasn't happened yet. And the fading won't get really serious until Module::Build is so well established that established module-authors (myself included) feel compelled to start including Build.PL scripts in their CPAN distros along with Makefile.PL. Then, in a later version, we can begin to imagine not including MakeMaker in the core distribution. That's a long ways off, IMH.

Having peered into MakeMaker's innards, I can well appreciate what Schwern goes through in attempting to maintain it.

All that being said, what I would welcome (and what you are welcome to volunteer for) is a supplement to cog's tutorial which provides a point-to-point guide for building a Build.PL file to accomplish what a Makefile.PL does at least for a pure Perl distribution.

jimk

Re^4: How to create installable modules ?
blm
created: 2006-01-11 23:59:26

My recollection is that the first module that I tried to install that needed Module::Build actually installed it as a prereq. And even then you can write a Makefile.PL that is just a wrapper around Build.PL for those that can't or won't be able to use the new build stuff. Is this inaccurate?

Isn't this person that we are trying to help build a module distribution not an established module author anyway?

Re^5: How to create installable modules ?
created: 2006-01-12 11:32:50

You can't automatically install it as a prerequisite unless you know how to install it. It's a bit of a Catch-22: you can't process a Build.PL until you have Module::Build, and you can't install Module::Build (for the first time, at least) with a Build.PL. :)

--
brian d foy
Subscribe to The Perl Review
Re^6: How to create installable modules ?
blm
created: 2006-01-13 02:17:59
Thanks for clarifying that for me, brian! :-)
Re^3: How to create installable modules ?
created: 2006-01-12 11:30:35

Of course Schwern says ExtUtils::MakeMaker is dead. He's the one trying to kill it. It's still the workhorse that gets modules installed, though.

I'm not going to worry about it until Module::Build is in the standard distribution and enough people have upgraded their perl distros.

--
brian d foy
Subscribe to The Perl Review
Re: How to create installlable modules
created: 2006-01-10 11:19:03

Inside your Makefile.PL, you have a WriteMakefile function. That function takes a list of key-value pairs which it will use to figure out what's going on and what to do when a user tries to install the module.

Inside that function, you should see an entry for PREREQ_PM => {}. This part allows you to specify all of the prerequisite modules along with their minimum versions. For example, this little snippet requires Foo::Bar version 1.02 or greater, Baz::Quux 2.70 or greater, and any version of CGI.pm.

WriteMakefile(
#...
    PREREQ_PM => {
        Foo::Bar => 1.02,
        Baz::Quux => 2.70,
        CGI       => 0,
        }
#...
);

Tools such as CPAN.pm and CPANPLUS can use this information to automatically install and update dependencies.

If you'd like to discover the module versions that you have installed, you can use a quick command line (among hundreds of other ways):

$ perl -MCGI -le 'print CGI->VERSION' 
3.04

If you have the latest version (1.05) of my cpan(1) utility, you can use the -D switch to get module details. This is handy not only to check your installed version of the module, but to see what CPAN thinks is the current version.

$ cpan -D CGI
CGI
---------------------------------------------------------------------
        (no description)
        L/LD/LDS/CGI.pm-3.15.tar.gz
        /usr/local/lib/perl5/5.8.4/CGI.pm
        Installed: 3.04
        CPAN:      3.15  Not up to date
        Lincoln D. Stein (LDS)
        lstein@cshl.org     

Good luck :)

--
brian d foy
Subscribe to The Perl Review
Re^2: How to create installable modules ?
created: 2006-01-11 04:27:03
Hi Brian, Thanks for your reply. I have some more doubts. I have specified all the prerequisite modules in PREREQ_PM like this. PREREQ_PM => { XML::Writer => 0.531, XML::Sablotron => 0.98 } While doing "perl Makefile.pl" it is giving a warning that these modules are not installed . Is these modules will automatilcally installed? Other thing is that I need to check BDBXML is present in the system . Thanks and regards
Re^3: How to create installable modules ?
created: 2006-01-11 14:50:02

If you install the tools with CPAN.pm, my cpan script, or CPAN++, they can automatically handle the dependencies for you. Simply running the Makefile.PL script won't do that for you.

--
brian d foy
Subscribe to The Perl Review
Re^4: How to create installable modules ?
created: 2006-01-12 06:21:11
Hi Brian, So how we install the module through CPAN utility after creating the makefile.pl. Thanks and regards
Re^2: How to create installable modules ?
created: 2006-01-11 22:40:47
If you'd like to discover the module versions that you have installed, you can use a quick command line (among hundreds of other ways):

$ perl -MCGI -le 'print CGI->VERSION' # prints:  3.04

Is there a similar trick for scripts installed from CPAN, such as cpan itself?

I ask because I just installed the latest Bundle::CPAN distro and, when I called perldoc -m cpan, I saw this:

# $Id: cpan,v 1.5 2005/12/24 00:59:08 comdog Exp $

... which leads me to believe that this is version 1.5, not version 1.05 as you suggest farther down in your posting.

(Or is this an artifact of the way you set your $VERSION?

my $VERSION =
	sprintf "%d.%02d", q$Revision: 296 $ =~ m/ (\d+) \. (\d+) /xg;

jimk

Re^3: How to create installable modules ?
created: 2006-01-12 11:24:06

There isn't a similar trick for scripts unless the script is specially written for it. It would need methods (so, it has to be class), and it would need one named VERSION.

Don't be fooled by the CVS file revision number. The distro was cpan-1.5 (the latest is cpan-1.51) which I set in Makefile.PL. The 1.05 is a mistake.

The latest cpan script has a -v switch, though. :)

--
brian d foy
Subscribe to The Perl Review

perlmonks.org content © perlmonks.org and Anonymous Monk, blm, brian_d_foy, cog, jkeenan1, premak

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03