Re: [RFC] perl prerequiste

[email protected] (Alexandr Ciornii)
Newsgroups perl.makemaker
Message-ID <[email protected]>
Michael G Schwern wrote:

> Alexandr Ciornii wrote:
>> Makefile.PL/ExtUtils::MakeMaker has no way to specify required perl
>> version except "use 5.006;".

> Thanks for the idea.  It's been proposed before...
> https://rt.cpan.org/Ticket/Display.html?id=28374
> 
> I'm fine with the idea as long as it's not adding to PREREQ_PM.  I'm not a fan
> of adding extra special meanings to things.  PREREQ_PM is the prerequisite
> perl modules and that's it.  It'll need a new key.  PREREQ_PERL is one idea.
> So is MIN_PERL_VERSION.  I don't really have a strong preference one way or
> the other.

I have discarded my patch and used parts of David's. Tested on Windows.
It yet not adds info to META.yml - that would be second patch.

-- 
Alexandr Ciornii, http://chorny.net
MakeMaker.pm.patch (text/plain, 1006 B)
--- 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
min_perl_version.t (text/plain, 1.2 KB)
#!/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';

}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.