Skip Menu |

This queue is for tickets about the ExtUtils-MakeMaker CPAN distribution.

Report information
The Basics
Id: 28374
Status: resolved
Priority: 0/
Queue: ExtUtils-MakeMaker

People
Owner: Nobody in particular
Requestors: dagolden [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] add support for 'perl' in PREREQ_PM
Currently, 'perl' in PREREQ_PM warns that the perl module can't be found. (However, EU::MM does write it to the Makefile PREREQ_PM and META.yml, which is good for other tools like CPAN and CPAN::Reporter to use.) This patch adds special handling for 'perl' in PREREQ_PM as well as a special error message for PREREQ_FATAL if the perl prerequisite is not satisfied. Includes tests in t/prereq.t. (Tested on Win32 only, but should be generic.) Patch file is against r4021.
Subject: EUMM-perl-prereq.patch
=== lib/ExtUtils/MakeMaker.pm ================================================================== --- lib/ExtUtils/MakeMaker.pm (revision 3215) +++ lib/ExtUtils/MakeMaker.pm (local) @@ -400,13 +400,22 @@ my(%unsatisfied) = (); foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) { - # 5.8.0 has a bug with require Foo::Bar alone in an eval, so an - # extra statement is a workaround. - my $file = "$prereq.pm"; - $file =~ s{::}{/}g; - eval { require $file }; + my $pr_version; + if ( $prereq =~ /\Aperl\z/i ) { + $pr_version = $]; + # normalize 'perl' for other tools + $self->{PREREQ_PM}{'perl'} = delete $self->{PREREQ_PM}{$prereq}; + $prereq = lc $prereq; + } + else { + # 5.8.0 has a bug with require Foo::Bar alone in an eval, so an + # extra statement is a workaround. + my $file = "$prereq.pm"; + $file =~ s{::}{/}g; + eval { require $file }; - my $pr_version = $prereq->VERSION || 0; + $pr_version = $prereq->VERSION || 0; + } # convert X.Y_Z alpha version #s to X.YZ for easier comparisons $pr_version =~ s/(\d+)\.(\d+)_(\d+)/$1.$2$3/; @@ -497,12 +506,17 @@ if (%unsatisfied && $self->{PREREQ_FATAL}){ my $failedprereqs = join "\n", map {" $_ $unsatisfied{$_}"} sort { $a cmp $b } keys %unsatisfied; - die <<"END"; + my $fatal_prereq_message = <<"END"; MakeMaker FATAL: prerequisites not found. $failedprereqs -Please install these modules first and rerun 'perl Makefile.PL'. END + $fatal_prereq_message .= exists $unsatisfied{perl} + ? "This distribution won't work without a higher version of Perl.\n" + : "Please install these modules first and rerun 'perl Makefile.PL'.\n" + ; + + die $fatal_prereq_message; } === t/prereq.t ================================================================== --- t/prereq.t (revision 3215) +++ t/prereq.t (local) @@ -50,6 +50,22 @@ ); is $warnings, ''; + WriteMakefile( + NAME => 'Big::Dummy', + PREREQ_PM => { + perl => 5 + } + ); + is $warnings, ''; + + WriteMakefile( + NAME => 'Big::Dummy', + PREREQ_PM => { + Perl => 5 + } + ); + is $warnings, ''; + $warnings = ''; WriteMakefile( NAME => 'Big::Dummy', @@ -65,6 +81,17 @@ WriteMakefile( NAME => 'Big::Dummy', PREREQ_PM => { + perl => 99999 + } + ); + is $warnings, + sprintf("Warning: prerequisite perl 99999 not found. We have %s.\n", + $]); + + $warnings = ''; + WriteMakefile( + NAME => 'Big::Dummy', + PREREQ_PM => { "I::Do::Not::Exist" => 0, } ); @@ -107,4 +134,22 @@ Please install these modules first and rerun 'perl Makefile.PL'. END + $warnings = ''; + eval { + WriteMakefile( + NAME => 'Big::Dummy', + PREREQ_PM => { + "perl" => 99999, + }, + PREREQ_FATAL => 1, + ); + }; + + is $warnings, ''; + is $@, <<'END', "PREREQ_FATAL"; +MakeMaker FATAL: prerequisites not found. + perl 99999 + +This distribution won't work without a higher version of Perl. +END }
Show quoted text
> Patch file is against r4021.
Note -- doesn't yet handle dotted-decimal form.
Subject: Re: [rt.cpan.org #28374] [PATCH] add support for 'perl' in PREREQ_PM
Date: Thu, 19 Jul 2007 08:07:13 -0700
To: bug-ExtUtils-MakeMaker [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
via RT wrote: Show quoted text
> Thu Jul 19 01:25:16 2007: Request 28374 was acted upon. > Transaction: Ticket created by DAGOLDEN > Queue: ExtUtils-MakeMaker > Subject: [PATCH] add support for 'perl' in PREREQ_PM > Broken in: (no value) > Severity: Normal > Owner: Nobody > Requestors: DAGOLDEN@cpan.org > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=28374 > > > > Currently, 'perl' in PREREQ_PM warns that the perl module can't be > found. (However, EU::MM does write it to the Makefile PREREQ_PM and > META.yml, which is good for other tools like CPAN and CPAN::Reporter to > use.) > > This patch adds special handling for 'perl' in PREREQ_PM as well as a > special error message for PREREQ_FATAL if the perl prerequisite is not > satisfied. Includes tests in t/prereq.t. (Tested on Win32 only, but > should be generic.) > > Patch file is against r4021.
I like the idea of handling an explicit perl version dependency, but I'm not a fan of overloaded special meanings. PREREQ_PM is for modules. This will have to go into a new keyword. Probably something like MIN_PERL_VERSION.
From: DAGOLDEN [...] cpan.org
On Thu Jul 19 11:07:50 2007, schwern@pobox.com wrote: Show quoted text
> I like the idea of handling an explicit perl version dependency, but > I'm not a > fan of overloaded special meanings. PREREQ_PM is for modules. This > will have > to go into a new keyword. Probably something like MIN_PERL_VERSION.
I agree on overloaded special meanings -- but at this point, the de facto standard is that it gets specified just like other prerequisites. Module::Build started it, and now CPAN.pm checks for it there as well. I'm not sure what CPANPLUS does as I just can't follow the twisty maze of classes and methods. A new keyword works as long as CPAN.pm and Module::Build::Compat make the matching change.
Subject: Re: [rt.cpan.org #28374] [PATCH] add support for 'perl' in PREREQ_PM
Date: Thu, 19 Jul 2007 10:27:48 -0700
To: bug-ExtUtils-MakeMaker [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
via RT wrote: Show quoted text
> Queue: ExtUtils-MakeMaker > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=28374 > > > On Thu Jul 19 11:07:50 2007, schwern@pobox.com wrote:
>> I like the idea of handling an explicit perl version dependency, but >> I'm not a >> fan of overloaded special meanings. PREREQ_PM is for modules. This >> will have >> to go into a new keyword. Probably something like MIN_PERL_VERSION.
> > I agree on overloaded special meanings -- but at this point, the de > facto standard is that it gets specified just like other prerequisites. > Module::Build started it, and now CPAN.pm checks for it there as well. > I'm not sure what CPANPLUS does as I just can't follow the twisty maze > of classes and methods. > > A new keyword works as long as CPAN.pm and Module::Build::Compat make > the matching change.
The key in the Makefile.PL doesn't matter wrt any other part of the tool chain It all comes out the same in the META.yml and that's what the CPAN shell looks at.
From: DAGOLDEN [...] cpan.org
On Thu Jul 19 13:28:33 2007, schwern@pobox.com wrote: Show quoted text
> The key in the Makefile.PL doesn't matter wrt any other part of the > tool chain > It all comes out the same in the META.yml and that's what the CPAN > shell > looks at.
Only if YAML is available. YAML seems to fail on 5.6.2. See http://cpantesters.perl.org/show/YAML.html If YAML isn't available, CPAN falls back to parsing the Makefile for the embedded PREREQ_PM line. So any new keyword needs to be added to the generated Makefile and CPAN.pm has to be patched to look for that as well.
Subject: Re: [rt.cpan.org #28374] [PATCH] add support for 'perl' in PREREQ_PM
Date: Thu, 19 Jul 2007 12:03:14 -0700
To: bug-ExtUtils-MakeMaker [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
via RT wrote: Show quoted text
> Queue: ExtUtils-MakeMaker > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=28374 > > > On Thu Jul 19 13:28:33 2007, schwern@pobox.com wrote:
>> The key in the Makefile.PL doesn't matter wrt any other part of the >> tool chain >> It all comes out the same in the META.yml and that's what the CPAN >> shell >> looks at.
> > Only if YAML is available. YAML seems to fail on 5.6.2. > See http://cpantesters.perl.org/show/YAML.html
Ok, it'll have to be fixed. Show quoted text
> If YAML isn't available, CPAN falls back to parsing the Makefile for the > embedded PREREQ_PM line. So any new keyword needs to be added to the > generated Makefile and CPAN.pm has to be patched to look for that as well.
All the arguments to WriteMakefile show up in the Makefile automatically. That's what things like CPAN.pm are groveling through.
This is patch to add support for MIN_PERL_VERSION for Makefile.PL. Used parts of David's patch. Tested with latest version of EUMM on Windows. It yet not adds info to META.yml - that would be second patch. -- Alexandr Ciornii, http://chorny.net
--- MakeMaker.pm.dist Fri Feb 29 02:06:55 2008 +++ MakeMaker.pm Wed Apr 16 14:11:58 2008 @@ -236,7 +236,7 @@ LINKTYPE MAKE MAKEAPERL MAKEFILE MAKEFILE_OLD MAN1PODS MAN3PODS MAP_TARGET MYEXTLIB NAME NEEDS_LINKING NOECHO NO_META NORECURS NO_VC OBJECT OPTIMIZE PERL_MALLOC_OK PERL PERLMAINCC PERLRUN PERLRUNINST PERL_CORE - PERL_SRC PERM_RW PERM_RWX + PERL_SRC PERM_RW PERM_RWX MIN_PERL_VERSION PL_FILES PM PM_FILTER PMLIBDIRS PMLIBPARENTDIRS POLLUTE PPM_INSTALL_EXEC PPM_INSTALL_SCRIPT PREREQ_FATAL PREREQ_PM PREREQ_PRINT PRINT_PREREQ SIGN SKIP TYPEMAPS VERSION VERSION_FROM XS XSOPT XSPROTOARG @@ -389,6 +389,10 @@ check_hints($self); + if ($self->{MIN_PERL_VERSION} and $self->{MIN_PERL_VERSION} > $]) { + die "This distribution won't work without a higher version of Perl.\n"; + } + my %configure_att; # record &{$self->{CONFIGURE}} attributes my(%initial_att) = %$self; # record initial attributes
#!/usr/bin/perl -w # This is a test of the verification of the arguments to # WriteMakefile. BEGIN { if( $ENV{PERL_CORE} ) { chdir 't' if -d 't'; @INC = ('../lib', 'lib'); } else { unshift @INC, 't/lib'; } } use strict; use Test::More tests => 8; use TieOut; use MakeMaker::Test::Utils; use MakeMaker::Test::Setup::BFD; use ExtUtils::MakeMaker; chdir 't'; perl_lib(); ok( setup_recurs(), 'setup' ); END { ok( chdir File::Spec->updir ); ok( teardown_recurs(), 'teardown' ); } ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) || diag("chdir failed: $!"); { ok( my $stdout = tie *STDOUT, 'TieOut' ); my $warnings = ''; local $SIG{__WARN__} = sub { $warnings .= join '', @_; }; eval { WriteMakefile( NAME => 'Big::Dummy', MIN_PERL_VERSION => 5, ); }; is $warnings, ''; is $@, '','MIN_PERL_VERSION=5'; $warnings = ''; eval { WriteMakefile( NAME => 'Big::Dummy', MIN_PERL_VERSION => 999999, ); }; is $@, "This distribution won't work without a higher version of Perl.\n", 'MIN_PERL_VERSION=999999'; }
Subject: [PATCH] more complete patch adding MIN_PERL_VERSION
On Sat May 17 16:40:15 2008, CHORNY wrote: Show quoted text
> This is patch to add support for MIN_PERL_VERSION for Makefile.PL. > Used parts of David's patch. Tested with latest version of EUMM on > Windows. It yet not adds info to META.yml - that would be second patch.
I don't agree that MakeMaker should die when the current perl version does not match MIN_PERL_VERSION. As with other unmet requirements of the distro under examination, it should warn the user but carry on building a Makefile (unless PREREQ_FATAL is set). I have changed that accordingly and added the META.yml part and the ppd part and a test suite and some documentation. Of course, MakeMaker's own Makefile.PL can use the new parameter right away, so it is also included there. For PREREQ_PRINT I suggest a format extension that keeps perl version and module prerequisites conceptually apart. For PRINT_PREREQ (the RedHat thingy) I put "perl" among the modules, as in META.yml, but might have guessed wrong. The patch is against ExtUtils-MakeMaker-6.44 (latest from CPAN) as the subversion site did not work for me. I have tested it on various Unix flavours with perl-5.8.8 and perl-5.10. Michael, I would really appreciate this small but useful feature making it into an official release, which is why I spent some time on straightening it out. Enjoy. -Martin -- Martin Becker <becker-cpan@cozap.com>, <mhasch@cpan.org>
Download EUMM-rt28374-MinPerlVersion.patch.asc
application/octet-stream 487b

Message body not shown because it is not plain text.

Message body is not shown because it is too large.

Subject: [PATCH] Re: more complete patch adding MIN_PERL_VERSION
As an afterthought, I have made the check of the current perl version more robust with respect to rubbish in Makefile.PL. It now gives a recommendation as to the syntax of the perl version string if the comparison fails for some reason. The test suite covers this case now, too. The modified patch is against ExtUtils-MakeMaker-6.44, as before. -Martin -- Martin Becker <becker-cpan@cozap.com>, <mhasch@cpan.org>
Download EUMM-rt28374-MinPerlVersion-2.patch.asc
application/octet-stream 487b

Message body not shown because it is not plain text.

Message body is not shown because it is too large.

That's a very complete patch, thank you. I've added it with a few tweaks. MIN_PERL_VERSION will translate 5.6.1 format to 5.006001.