Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Gather and check dependencies w/o Makefile.PL

by flowdy (Scribe)
on Aug 18, 2014 at 20:05 UTC ( [id://1097896]=perlquestion: print w/replies, xml ) Need Help??

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

Hallo Monks,

What I've written tonight in the endeavor to make my project ready for GitHub makes me humbly feel that I reinvented the wheel once again. I know there is Dist::Zilla and what not, but my FlowTime project is bloody alpha and not yet at all ready to pack an installable distribution. I just want to simplify for others who clone my repository the process of making sure all requirements are met to run the program in the first place.

Could you tell me if there is a standard way to go? However, I would consider it weird to introduce new dependencies just to check dependencies. So, I want to get along without if this is possible.

Here, the section of my README file:

Check the dependencies ----------------------- Please run the following script now: script/gather_check_dependencies Someday there will certainly be an automatic installation routine that + would resolve all dependencies as needed. In the meantime, you need +to make sure yourself that all required CPAN modules are installed. Y +ou may want to prefer prebuilt packages to install from your distribu +tion repository (for Ubuntu or Debian e.g. lib-algorithm-dependency-p +erl etc.). The indicated versions I tested work, earlier might do as +well. Please note that I deleted lines of modules used internally in +the following example run: $ script/gather_check_dependencies Algorithm::Dependency::Ordered => OK, 1.110 Algorithm::Dependency::Source::HoA => OK, 1.110 Benchmark => OK, 1.15 Bit::Vector => OK, 7.3 Carp => OK, 1.29 Date::Calc => OK, 6.3 FindBin => OK, 1.51 JSON => OK, 2.61 List::MoreUtils => OK, 0.33 List::Util => OK, 1.27 Mojo::Base => OK, loaded (just version unknown) Mojolicious::Commands => OK, loaded (just version unknown) Moose => OK, 2.1210 Moose::Role => OK, 2.1210 Moose::Util::TypeConstraints => OK, 2.1210 POSIX => OK, 1.32 Scalar::Util => OK, 1.27 Test::More => OK, 0.98 Time::Local => OK, 1.2300

The gather_check_dependencies script:

#!/bin/sh egrep -rh '^[\s;]*(use|require) ' lib script t \ | sed -rne 's/ *(use|require) //; /^[A-Z]/p' \ | sort | uniq | perl -Ilib -ne "$(cat <<'PERL')" BEGIN { %seen = () } chomp; $i++; my ($mod,$name,$version) = /(([^\s;]+)(?: (\d[^\s;]+))?)/; warn("Not parsed: $_\n") && next if !$mod; next if $seen{$mod}++; print $name, " => ", eval(qq{ package TestLoad$i; use $mod (); "OK, ".(\$${name}::VERSION // "loaded (just version unknown)") }) // $@, "\n"; PERL

Any advice welcome, thank you!
--flowdy

Replies are listed 'Best First'.
Re: Gather and check dependencies w/o Makefile.PL
by Corion (Patriarch) on Aug 18, 2014 at 20:31 UTC

    Instead of relying on egrep, sed and multiline shell commands being aailable, why don't you just run that script once (or after each checking) and output a fresh Makefile.PL?

    A Makefile.PL is not hard to write and it immediately enables many tools to automatically test and install your distribution and all of its (listed) prerequisites.

    ExtUtils::Makemaker lists a very simple Makefile.PL:

    use ExtUtils::MakeMaker; WriteMakefile( NAME => "Foo::Bar", VERSION_FROM => "lib/Foo/Bar.pm", );

    You would likely expand that with the appropriate PREREQ_PM section:

    use ExtUtils::MakeMaker; WriteMakefile( NAME => "Foo::Bar", VERSION_FROM => "lib/Foo/Bar.pm", PREREQ_PM => { # Require other prerequisites "Acme::Buffy" => 0, ... } );

    If you're feeling extra crafty, you could generate that Makefile.PL automatically, but as such mechanisms usually fail or require special cases, I prefer manually maintaining such lists.

      Hi Corion,

      Okay, thanks, I built a Makefile.PL with ExtUtils::MakeMaker that has the advantage of being a core module I just looked it up (I am absolutely new to building makefiles and CPAN distributions). Did I overlook something or doesn't the generated Makefile contain a target for installing dependencies? Whatever, with cpanm --installdeps it works well.

      --flowdy

        Installing dependencies is done by the surrounding tool, be it cpan, cpanm or cpanp. It's not the task of the Makefile generated by Makefile.PL.

Re: Gather and check dependencies w/o Makefile.PL
by tobyink (Canon) on Aug 18, 2014 at 20:26 UTC

Log In?
Username:
Password:

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

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

    No recent polls found