My CPAN Cleaning, Day 2457034.500000
I've been playing with the Makefile.PL modulino idea this week as part of my CPAN cleaning. It's dangerous to have so much fun because I'll keep working on it. Someone might need to take my GitHub away.
Before I go on, I'm disappointed to report that the green boxes in my GitHub activity are relative to me. I was happy to make dark green boxes each day this month, showing the highest level of commit(ment)s. But then I made a few changes to about 120 repositories and pushed about 700 commits one night. Some of that was turning on GitHub pages for everything, I think. That box turned dark green, but all of my other dark green boxes disappeared because the extent is relative to me and not some level set across all of GitHub.
My idea about Makefile.PL modulinos comes out of work I've been doing for years. I want to see all that lovely build data without actually running the Makefile.PL. In Test::Prereq, a module I no longer particularly like, I overrode WriteMakefile
to see that stuff. The problem is that I still have to run the program, which might do other things. For my BackPAN archeology, I committed to running the build files, which means sandboxes and other precautions.
If I can isolate all that stuff, the rest of the program can be declarative. Even better, I can run the program with an older perl
than the actual module requires.
In this snippet which dos all the work, I grab most of the stuff I need from the arguments I'll pass to WriteMakefile
, including the minimum Perl version and the MakeMaker
I need (a full example).
sub do_it { require File::Spec; my $MM ='ExtUtils::MakeMaker'; my $MM_version = eval{ "$MM " . $WriteMakefile{'CONFIGURE_REQUIRES'}{$MM} } || "$MM 6.64"; eval "use $MM_version; 1" or die "Could not load $MM_version: $@"; eval "use Test::Manifest 1.21" if -e File::Spec->catfile( qw(t test_manifest) ); my $arguments = arguments(); my $minimum_perl = $arguments->{MIN_PERL_VERSION} || '5.008'; eval "require $minimum_perl;" or die $@;WriteMakefile( %$arguments );
}
That's not even the fun part though. Now that everything else is a Perl hash, I can use anything back to v5.8 to require
the Makefile.PL and get back a Perl hash. I can use that from within my yet unreleased CPAN::Critic. The big advantage for me is that I don't need anything other than core Perl to do it, I end up with the same data structure I'm going to make anyway, and I don't have to parse anything. I could get some of this if a META file was around (like in a distribution), but inside a repo it's not there. I can checkout a repo in a virtual machine and proceed without installing extra stuff.
I don't think anyone should try any of this yet. I don't even know if I should try it. I'll see what happens.
Leave a comment