I've been doing two things, recently:
Update: Looking at this again, I'd like to stress that this is not a tutorial or a howto on packaging. It's a number issues that I consider either important or beneficial when incorperated into your packaging workflow.
Update: Both Zaxo and Corion expressed concern about my advocation of Module::Build. They explain a problem with the faked Makefile.PL interface to it (which IMHO is sillly - if you make a Makefile at least remove the dependancy from M::B).
Anyway, I sort of take it back. Read their posts, see what they have to say. I bought M::B's story, but I may be an idiot. Ciao!
</Update>
From here on, unless noted, instances of ./Build or Build.PL are canonical to, and can be replaced by make or Makefile.PL if you went the ExtUtils::MakeMaker way. Keep in mind that Michael Schwern, MakeMaker's maintainer promotes replacing MakeMaker with Module::Build.
The first step of properly packaging a module has to do with what goes in, and what stays out.
A confusing aspect of that is that what goes into your src dir is not necessarily what goes into your tarball. This is where we'll start.
Given a proper MANIFEST, run perl Build.PL and then ./Build dist. If you want a SIGNATURE file generated, put the argument sign => 1, in your Build.pl args. If you want a Makefile.PL, put a create_makefile_pl => 'traditional', in there too (but make sure Makefile.PL is mentioned in your MANIFEST!).
Instead, write a MANIFEST.SKIP file. My generic one looks like this:
The first line removes the pesky OSX .DS_Store stuff. The next 3 lines take care of skipping build cruft. Any editor backup files are skipped, as are vim swap files. Devel::Cover dirs are also ommitted, and lastly, so is the MANIFEST.SKIP file itself. I sometimes add \.tar\.gz$ to the mess, to make sure that dists are not accidentally added to the manifest too.\.DS_Store$ ^_build ^Build$ ^blib ~$ \.bak$ \.sw.$ ^cover_db ^MANIFEST\.SKIP$
Now that we defined what we want out of the manifest, lets get our tool to generate one for us: perl Build.pl; ./Build manifest And now, any file that doesn't match the patterns in MANIFEST.SKIP is mentioned in there.
That looks well behaved, right? Lets see what's wrong with it:#!/usr/bin/perl use strict; use warnings; use Module::Build; Module::Build->new( module_name => 'My::Module', license => 'perl', requires => { 'Other::Module' => '0', }, build_requires => { 'Test::Funky' => 0, }, create_makefile_pl => 'traditional', sign => 1, )->create_build_script;
It should be noted that Test::Prereq might not apply to modules you optionally use in tests. skip_all is often used when these modules aren't available. Test::WithoutModule helps you check if that code works correctly.
cpansmoke will complain if you include no t/ dir. It will send you an email saying "would you please get up off your ass and at least write a tests that does use_ok("Your::Module")".
This has become an integral part of a proper distribution, even if it doesn't really do any real testing. At least try to look like you're trying.
From there the value of $VERSION is extracted, and used as the distribution version.
Versions are important because they imply compatibility, they define dependancies, and so forth. On the CPAN there is a general format.
And your source dir should be:Your-Module-0.01/ |-- Build.PL # your build script. |-- LICENSE # put you're license here if you really feel like it |-- MANIFEST # we discussed it already |-- Makefile.PL # this too. For those who aren't using CPANPLUS yet. |-- Meta.yml # this is generated by ./Build dist |-- README # everyone should have one |-- SIGNATURE # like MANIFEST, only cryptographic |-- lib/ # this should look like something you could put in @INC |-- t/ # this is where you keep your tests | |-- lib/ # if your tests need some libraries, put them here, and u +se lib 't/lib'
Build dist and friends should also generate:src/ |-- Build.PL |-- LICENSE |-- README |-- lib/ |-- t/ |-- lib/
And ofcourse, there is cruft:src/ |-- MANIFEST |-- Makefile.PL |-- Meta.yml
That last part is there, but you shouldn't really care about it. Manipulate your MANIFEST.SKIP if they bother you.src/ |-- Build # left over from perl Build.PL |-- Makefile # or perl Makefile.PL |-- _build # where Build.PL keeps it's data |-- blib # where your source tree is before installation |-- *~ # your editor backups |-- cover_db # your data from test coverage |-- CVS # your source control meta data
Test:: is a namespace you should know. See also Test::Distribution and it's friends.
Devel:: is a namespace to help you write code. Deve::Cover, for example, is a away to see what code is getting run when you run tests.
Module::Signature makes cryptographically signed MANIFEST like files.
The CPAN testing service is an experiement to try and measure package quality.
http://testers.cpan.org run tests for you, on many platforms and perls, when you release modules with tests.
http://qa.perl.org is a website concerned with the quality of perl and CPAN in general. It's an interesting starting point.
That doesn't mean you shouldn't see what h2xs is outputting, and understand what the mess it makes is.
P.S.
my brain is a bit zonked today. This probably has many grammer errors, ambiguities, and disinformation. Please inform me if you find any!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: On packaging modules
by Zaxo (Archbishop) on Nov 23, 2004 at 11:24 UTC | |
by itub (Priest) on Nov 23, 2004 at 15:15 UTC | |
by dragonchild (Archbishop) on Nov 23, 2004 at 15:30 UTC | |
by lachoy (Parson) on Nov 24, 2004 at 01:58 UTC | |
by lachoy (Parson) on Nov 24, 2004 at 02:01 UTC | |
by itub (Priest) on Nov 24, 2004 at 03:26 UTC | |
by kappa (Chaplain) on Nov 23, 2004 at 12:52 UTC | |
by ysth (Canon) on Nov 23, 2004 at 17:47 UTC | |
by Anonymous Monk on Dec 06, 2004 at 19:27 UTC | |
|
Re: On packaging modules
by Corion (Patriarch) on Nov 23, 2004 at 11:28 UTC | |
by nothingmuch (Priest) on Nov 23, 2004 at 11:35 UTC | |
|
Re: On packaging modules
by dragonchild (Archbishop) on Nov 23, 2004 at 14:19 UTC | |
by ysth (Canon) on Nov 23, 2004 at 19:13 UTC | |
by nothingmuch (Priest) on Nov 24, 2004 at 08:43 UTC | |
|
Module::Starter, baby!
by petdance (Parson) on Nov 27, 2004 at 17:00 UTC | |
|
Re: On packaging modules
by Anonymous Monk on Dec 06, 2004 at 19:01 UTC | |
by tye (Sage) on Dec 06, 2004 at 19:36 UTC | |
by schwern (Scribe) on Dec 15, 2004 at 09:00 UTC | |
by tye (Sage) on Dec 15, 2004 at 14:09 UTC | |
by Corion (Patriarch) on Dec 15, 2004 at 09:29 UTC | |
by Anonymous Monk on Dec 16, 2004 at 12:10 UTC | |
| |
by ysth (Canon) on Dec 15, 2004 at 10:05 UTC |