FAQ
In a distribution I would like to use a module (specifically
File::Copy::Recursive ) within Makefile.PL

How can I do this?
How do you do this?

I am using Module::Install so I would be mostly interested in that
solution but if you have this solved
for the other packaging tools, please do share that too.

If I just say

use File::Copy::Recursive;

it will blow up on systems that don't have the module installed.

So I tried

configure_requires 'File::Copy::Recursive' => 0;
require File::Copy::Recursive;

but that still blows up when I run Makefile.PL

I wonder if this will work once it is packaged and when the META.yml has
the configure_requires field already or if I need another way to make sure
File::Copy::Recursive is installed before Makefile.PL is executed?

regards
Gabor

Search Discussions

  • Torsten Schoenfeld at Aug 9, 2011 at 9:47 am

    On 09.08.2011 09:11, Gabor Szabo wrote:
    So I tried

    configure_requires 'File::Copy::Recursive' => 0;
    require File::Copy::Recursive;

    but that still blows up when I run Makefile.PL
    Yes, configure_requires is the way to go. If a CPAN client sees that,
    it will fetch the requirement before running Makefile.PL/Build.PL.
    Then wrap your 'use' call in an eval and if that fails, show an
    informative message to the user, and exit with exit code 0 so that CPAN
    testers know that their system is not supported. See also
    <http://wiki.cpantesters.org/wiki/CPANAuthorNotes>.
  • Eric Wilhelm at Aug 15, 2011 at 6:40 pm
    # from Gabor Szabo
    # on Tuesday 09 August 2011 00:11:
    So I tried

    configure_requires 'File::Copy::Recursive' => 0;
    require File::Copy::Recursive;

    but that still blows up when I run Makefile.PL
    That is to be expected. Something outside of Makefile.PL (i.e. the cpan
    client) needs to have read META.yml and resolved this beforehand.
    I wonder if this will work once it is packaged and when the META.yml
    has the configure_requires field already or if I need another way to
    make sure File::Copy::Recursive is installed before Makefile.PL is
    executed?
    Yes, if configure_requires is in the META.yml (and the client
    understands it), then those dependencies will be installed before
    Makefile.PL is ever run.

    You may elect to use eval and error-out with a nicer message for the
    sake of users running the .PL manually or with an obsolete client. But
    configure_requires is the way to make sure that an external dependency
    is available before the Makefile.PL/Build.PL runs.

    --Eric
    --
    The opinions expressed in this e-mail were randomly generated by
    the computer and do not necessarily reflect the views of its owner.
    --Management
    ---------------------------------------------------
    http://scratchcomputing.com
    ---------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmodule-authors @
categoriesperl
postedAug 9, '11 at 7:11a
activeAug 15, '11 at 6:40p
posts3
users3
websitecpan.org...

People

Translate

site design / logo © 2021 Grokbase