Alien-CPython3
view release on metacpan or search on metacpan
use alienfile;
use Path::Tiny qw( path );
use File::Copy::Recursive ();
use IPC::Cmd ();
use File::Spec ();
use File::Find;
use File::Which qw(which);
use Sort::Versions qw(versioncmp);
my $IS_UNIX = $^O ne 'MSWin32';
# This currently requires the ability to link to Python for embedding.
if( $IS_UNIX ) {
#plugin PkgConfig => 'python3-embed';
}
my $probe = 0;
for my $command (qw(python3 python)) {
next unless which($command);
plugin 'Probe::CommandLine' => (
command => $command,
args => [ '--version' ],
version => qr/^Python (3\.[0-9\.]+)$/,
#secondary => $IS_UNIX,
);
$probe = 1;
}
unless( $probe ) {
probe sub { 'share' };
}
sub do_source {
start_url 'https://www.python.org/downloads/';
plugin Download => (
filter => qr/^Python-3\..*\.tar\.xz$/,
version => qr/([0-9\.]+)/,
);
plugin Extract => 'tar.xz';
plugin 'Build::Autoconf';
build [
'%{configure} --enable-static --disable-shared',
'%{make}',
'%{make} install',
];
after build => sub {
my($build) = @_;
$build->runtime_prop->{'style'} = 'source';
$build->runtime_prop->{command} = 'python3';
};
plugin 'Gather::IsolateDynamic';
}
sub do_binary_windows {
requires 'Alien::Build::CommandSequence';
start_url 'https://www.python.org/downloads/windows/';
my $arch_name = meta->prop->{platform}{cpu}{arch}{name};
my ($filter, $arch_id);
if( $arch_name eq 'x86' ) {
$filter = qr/python-([0-9\.]+)\.exe/;
$arch_id = 'win32';
} elsif( $arch_name eq 'x86_64' ) {
$filter = qr/python-([0-9\.]+)-amd64.exe/;
$arch_id = 'amd64';
} else {
die "Unknown architecture for Windows. Please file a bug report.";
}
plugin 'Download';
plugin 'Decode::Mojo';
download sub {
my ($build) = @_;
$build->log( "GET @{[ meta->prop->{start_url} ]}");
my $version_index_url = do {
my $ret = $build->decode( $build->fetch );
my ($first) =
sort { my @v = map { ($_->{filename} =~ $filter)[0] } $a, $b; versioncmp($v[1], $v[0]) }
grep { $_->{filename} =~ $filter } @{ $ret->{list} };
# from: https://www.python.org/ftp/python/3.11.1/python-3.11.1-amd64.exe
# to: https://www.python.org/ftp/python/3.11.1
(my $url = $first->{url}) =~ s,/[^/]+$,,;
$url;
( run in 0.980 second using v1.01-cache-2.11-cpan-39bf76dae61 )