Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Module::Build's pm_files in ExtUtils::MakeMaker?

by LTjake (Prior)
on Sep 20, 2005 at 11:49 UTC ( #493406=perlquestion: print w/ replies, xml ) Need Help??
LTjake has asked for the wisdom of the Perl Monks concerning the following question:

NB: This has been cross-posted to my journal

As I do some work to my older modules, I'm converting their installation procedures to Module::Build (mentioned here).

Whilst updating CGI::Application::PhotoGallery, I ran in to a little bug (detailed by Phred). The desired behavior is to have the default templates install in @INC so i can simply add @INC to the include paths and they'll be used as a fall-back mechanism. The way I achieved that with ExtUtils::MakeMaker was to put them directly in the /lib/ directory in the distro and EU::MM will happily copy them over on make install.

With Module::Build, i can take them out of the lib directory and put them in /etc/ and use the pm_files option to make sure they're copied over:

pm_files => { 'etc/photos_index.tmpl' => 'lib/CGI/Application/PhotoGallery/phot +os_index.tmpl', 'etc/photos_single.tmpl' => 'lib/CGI/Application/PhotoGallery/phot +os_single.tmpl', # wish i could just do the templates... 'lib/CGI/Application/PhotoGallery.pm' => 'lib/CGI/Applicati +on/PhotoGallery.pm', 'lib/CGI/Application/PhotoGallery/GD.pm' => 'lib/CGI/Applicati +on/PhotoGallery/GD.pm', 'lib/CGI/Application/PhotoGallery/Magick.pm' => 'lib/CGI/Applicati +on/PhotoGallery/Magick.pm' }

This is fine and dandy, except that I'm auto-generating a Makefile.PL and Module::Build::Compat has no way to handle that construct.

So, is there a better way to handle this scenario, or should i revert to stuffing my templates in the /lib/ directory?

Update: Minor style updates.

--
"Go up to the next female stranger you see and tell her that her "body is a wonderland."
My hypothesis is that she’ll be too busy laughing at you to even bother slapping you.
" (src)

Comment on Module::Build's pm_files in ExtUtils::MakeMaker?
Select or Download Code
Re: Module::Build's pm_files in ExtUtils::MakeMaker?
by PodMaster (Abbot) on Sep 20, 2005 at 12:14 UTC
    This is fine and dandy, except that I'm auto-generating a Makefile.PL and Module::Build::Compat has no way to handle that construct.

    So, is there a better way to handle this scenario, or should i revert to stuffing my templates in the /lib/ directory?

    Fix Module::Build::Compat.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Module::Build's pm_files in ExtUtils::MakeMaker?
by xdg (Monsignor) on Sep 20, 2005 at 14:13 UTC

    Look at the Module::Build::Cookbook on adding new file types to the build process. E.g. (from the cookbook)

    Sometimes you might have extra types of files that you want to install alongside the standard types like .pm and .pod files. For instance, you might have a Foo.dat file containing some data related to the Boo::Baz module. Assuming the data doesn't need to be created on the fly, the best place for it to end up is probably as Boo/Baz/Foo.dat somewhere in perl's @INC path so Boo::Baz can access it easily at runtime. The following code from a sample Build.PL file demonstrates how to accomplish this:

    use Module::Build; my $build = new Module::Build ( module_name => 'Boo::Baz', ... ); $build->add_build_element('dat'); $build->create_build_script;

    This will find all .dat files in the lib/ directory, copy them to the blib/lib/ directory during the build action, and install them during the install action.

    There's more in the cookbook about what to do if you don't want to leave the files under lib, but keep them somewhere else instead.

    use Module::Build; my $build = new Module::Build ( module_name => 'Boo::Baz', dat_files => {'some/dir/Foo.dat' => 'lib/Boo/Baz/Foo.dat'}, ... ); $build->add_build_element('dat'); $build->create_build_script;

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      Hi! Thanks for your reply.

      With your suggestion, i can now do the following which allows me to get rid of the pm_files section.

      my $build = Module::Build->new( # ... tmpl_files => { 'etc/photos_index.tmpl' => 'lib/CGI/Application/PhotoGallery/ +photos_index.tmpl', 'etc/photos_single.tmpl' => 'lib/CGI/Application/PhotoGallery +/photos_single.tmpl', } ); $build->add_build_element( 'tmpl' ); $build->create_build_script;

      So, Thanks! =)

      However, the auto-generated Makefile.PL still has no idea about those templates and will not install them as needed.

      --
      "Go up to the next female stranger you see and tell her that her "body is a wonderland."
      My hypothesis is that she’ll be too busy laughing at you to even bother slapping you.
      " (src)

        I'd bring it up on the Module::Build mailing list. It looks like it might not be too hard to patch Module::Build::Compat to write a PMLIBDIRS argument to the Makefile.PL -- assuming that's the right way to do it... I don't know ExtUtils::MakeMaker well enough..

        -xdg

        Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

        Just in case anyone stumbles across this older post ... it's possible that the issue has been fixed, but there's (currently) nothing to stop you from using a different build element whose files are also in lib, where MakeMaker would find them:

        tmpl_files => { map { $_ => $_ } glob( 'lib/CGI/Application/PhotoGallery/*.tmpl' +) },

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://493406]
Approved by Corion
Front-paged by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2014-12-28 13:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (181 votes), past polls