Alien-CPython3
view release on metacpan or search on metacpan
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;
};
my $arch_index_url = "${version_index_url}/${arch_id}/";
my ($version) = $version_index_url =~ m,/([0-9\.]+)$,;
$build->runtime_prop->{version} = $version;
do {
my $ret = $build->decode( $build->fetch($arch_index_url) );
$build->log(".msi list (all) " . join(" ", map $_->{filename}, @{ $ret->{list} }));
# filter out debugging .msi's
my @filtered_list = grep {
$_->{filename} !~ /(_d|_pdb)\.msi$/
} @{ $ret->{list} };
$build->log(".msi list (filter) " . join(" ", map $_->{filename}, @filtered_list));
# Need to skip:
#
# Reason: modify global environment
# - appendpath.msi
# - path.msi
#
# Reason: extra disk space
# - launcher.msi
# - doc.msi
#
# Reason: use ensurepip
# - pip.msi
my $msi_allow_filter = qr/
^
( tools
| dev
| ucrt
| exe
| core
| tcltk
| test
| lib
)
\.msi
$
/x;
my @downloads = grep { $_->{filename} =~ $msi_allow_filter } @filtered_list;
for my $download (@downloads) {
my $url = $download->{url};
$build->log("GET $url");
{
my $ret = $build->fetch($url);
if(defined $ret->{content})
{
path($ret->{filename})->spew_raw($ret->{content});
}
elsif(defined $ret->{path})
{
my $from = path($ret->{path});
my $to = $ret->{filename};
if($ret->{tmp})
{
$from->move($to);
}
else
{
$from->copy($to);
}
}
else
{
( run in 0.344 second using v1.01-cache-2.11-cpan-119454b85a5 )