Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Module Makefile.PL conditional PREREQ_PM

by VinsWorldcom (Parson)
on Feb 02, 2012 at 20:27 UTC ( #951525=perlquestion: print w/replies, xml ) Need Help??
VinsWorldcom has asked for the wisdom of the Perl Monks concerning the following question:

My module does some IPv4/v6 stuff and since Perl support for that is still 'developing', I've had to do some workarounds for different Perl versions. I think I have the 'use Socket...' commands all right and tests pass on Perl versions 5.12 and 5.14. Now to build the distribution so anyone can use it...

For Perl < 5.014 I need:

Socket Socket6 Socket::GetAddrInfo

While Socket6 has the getaddrinfo subs, they do not return the same structure as the getaddrinfo natively in Socket for Perl >= 5.14. Socket::GetAddrInfo does this, but doesn't provide the inet_ntop function, so I need Socket6. Yadda yadda ...

For Perl >= 5.014 I need:


I would simply like to say: If you're on Perl < 5.014, then "Socket::GetAddrInfo" is required. My Makefile.PL

use ExtUtils::MakeMaker; my @prereq_pm; if ($] < 5.014) { push @prereq_pm, "Socket::GetAddrInfo"; push @prereq_pm, 0.21; } WriteMakefile( NAME => [... ... omitted for concise ...] PREREQ_PM => { Net::Frame => 1.09, @prereq_pm }, );

This "works"; however, when I 'make dist' the META.yml created is going to have the prerequisites as they are for the system I'm 'make dist'-ing on (say 5.12) - and when a user downloads my module and tries to build on 5.14, the META.yml in the distribution says Socket::GetAddrInfo is required. Of course, the opposite is also true if I build on 5.14 and the user tries to install on 5.12, Socket::GetAddrInfo won't show up as required - but it is.

The META.yml file seems to matter to the CPAN client when doing installs - how can I get it to evaluate required modules based on the version of Perl the module is currently being built / installed on? I'm thinking dynamically at build / install time versus at 'packing-the-distribution-tarball-gzip' time.

Replies are listed 'Best First'.
Re: Module Makefile.PL conditional PREREQ_PM
by bingos (Vicar) on Feb 02, 2012 at 20:49 UTC

    No CPAN client uses what is listed in META.yml to resolve prereqs, they all run Makefile.PL to determine those.

    CPAN clients will use the configure_requires field in META.yml to determine any prereqs that require resolving before Makefile.PL is executed.

    Any other prereqs listed in META.yml may or may not be accurate, this is the price for a Turing complete build system

    Both v1.4 of the META specification and CPAN::Meta::Spec deal with this using the 'dynamic_config' field.

      > No CPAN client uses what is listed in META.yml to resolve prereqs

      Depends on what you mean by client. Tools such as CPAN::FindDependencies and CPANdeps use META.yml for obvious reasons.

Re: Module Makefile.PL conditional PREREQ_PM
by Anonymous Monk on Feb 02, 2012 at 20:36 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://951525]
Approved by bingos
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2017-12-18 09:18 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (475 votes). Check out past polls.