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

Can ExtUtils::MakeMaker recommend to install optional modules?

by voj (Acolyte)
on Dec 08, 2011 at 11:04 UTC ( [id://942397]=perlquestion: print w/replies, xml ) Need Help??

voj has asked for the wisdom of the Perl Monks concerning the following question:

In ExtUtils::MakeMaker you specify required modules in PREREQ_PM. I have a module that recommends the GraphViz module but it can also be installed without. Can I somehow add a rule to Makefile.PL that triggers an attempt to install GraphViz? So if you have already installed the graphviz binary (which is needed by GraphViz module), installation of my module should also install GraphViz. But if this fails, because of missing graphviz binary, you should only get a message.
  • Comment on Can ExtUtils::MakeMaker recommend to install optional modules?

Replies are listed 'Best First'.
Re: Can ExtUtils::MakeMaker recommend to install optional modules?
by Dallaylaen (Chaplain) on Nov 30, 2017 at 23:57 UTC

    This article sums up dependencies pretty well.

    Here's how you specify recommended/suggested dependencies:

    use ExtUtils::MakeMaker 6.64; WriteMakefile( # other stuff META_MERGE => { "meta-spec" => { version => 2 }, prereqs => { test => { recommends => { 'CPAN::Meta' => '2.120900', }, }, runtime => { recommends => { 'Text::CSV_XS' => 0, }, }, }, }, );

      Here's how you specify recommended/suggested dependencies:

      For the record: there is a difference between recommends and suggests.

      The two (and requires and conflicts) exist so the module author has more control over, well, recommendations and suggestions. Not all versions of all clients support the newest spec, but recent ones do.

      Hope this helps!


      The way forward always starts with a minimal test.
      What if I don't want the recommended additional packages? How can I force the build to ignore the recommends? In my case a command line tool recommends, through a chain of dependencies, that I install the X server. I really don't want to do that.

        Default cpan client has recommends_policy and suggests_policy options under o conf just for that. Couldn't find anything in cpanm, but maybe it can, too. No idea about cpanplus.

        Btw installing raw CPAN on perlbrew was nontrivial, though not complicated after all. Maybe brew should bundle a script for that...

Re: Can ExtUtils::MakeMaker recommend to install optional modules?
by DrHyde (Prior) on Dec 09, 2011 at 11:50 UTC
    ... PREREQ_PM => { ... (`which graphviz`) ? (GraphViz => '2.08') : ()) }, ...

    Adapt as required to make it portable :-)

Re: Can ExtUtils::MakeMaker recommend to install optional modules?
by Anonymous Monk on Dec 08, 2011 at 13:15 UTC

    No.

    If you're using any of cpan/cpanp/cpanm... they will notice what MakeMaker says, and attempt to install the prerequisites

    You can use ExtUtils::AutoInstall - Automatic install of dependencies via CPAN

    or Module::AutoInstall - Automatic install of dependencies via CPAN

      yes! http://grokbase.com/t/perl.org/module-authors/2009/10/how-can-i-tell-makemaker-to-insert-recommended-modules-into-meta-yml/16vuqyqk4yiugwsm43ttanhirbry

        yes!...

        That has nothing to do with the question asked. META is generated from PREREQ_PM. MakeMaker doesn't download modules, cpan does.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-19 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found