Alien-CPython3
view release on metacpan or search on metacpan
$change_path->chmod('u+w');
my $path_rel_ver = $change_path->relative( $version_base );
if( $path_rel_ver->parent eq 'bin' || $path_rel_ver eq 'Resources/Python.app/Contents/MacOS/Python' ) {
my $exec_path_rpath = File::Spec->catfile(
'@executable_path',
$base->relative($change_path->parent),
);
$build->log("-add_rpath for $change_path: $exec_path_rpath\n");
IPC::Cmd::run( command => [
qw(install_name_tool -add_rpath),
$exec_path_rpath,
$change_path
]); # no or die to avoid duplicate rpath bits
}
if( $change_path->basename =~ /\.dylib$|^Python$/ ) {
my $to_python_framework_path = File::Spec->catfile(
$frameworks_path,
File::Spec->abs2rel($change_path, $base)
);
my $id_with_rpath = $rpathify->($to_python_framework_path);
$build->log("-id for $change_path: $id_with_rpath\n");
IPC::Cmd::run( command => [
qw(install_name_tool -id),
$id_with_rpath,
$change_path
]) or die;
}
$build->log("Processing libs for $change_path\n");
for my $lib (@$libs) {
my $lib_with_rpath_framework = $rpathify->($lib) or next;
$build->log("-change: $lib -> $lib_with_rpath_framework\n");
IPC::Cmd::run( command => [
qw(install_name_tool -change),
$lib,
$lib_with_rpath_framework,
$change_path
]) or die;
}
}
# python3 -c 'import sys; print( "\n".join(sys.path) )'
}
sub do_binary_macos {
requires 'Alien::Build::CommandSequence';
start_url 'https://www.python.org/downloads/macos/';
# Using universal2 installer.
plugin Download => (
filter => qr/python-([0-9\.]+)-macos11.pkg/,
version => qr/([0-9\.]+)/,
);
extract sub {
my ($build) = @_;
Alien::Build::CommandSequence->new([
qw(pkgutil --expand-full),
$build->install_prop->{download},
'python'
])->execute($build);
};
patch sub {
my ($build) = @_;
my @children = Path::Tiny->cwd->children;
$_->remove_tree for grep { $_->basename ne 'Python_Framework.pkg' } @children;
my $framework_src_dir = path('Python_Framework.pkg');
my $framework_dst_dir = path('Python.framework');
$framework_dst_dir->mkpath;
File::Copy::Recursive::rmove( "$framework_src_dir/Payload/*", $framework_dst_dir );
$framework_src_dir->remove_tree( { safe => 0 } );
macos_relocatable_python($build, $framework_dst_dir->parent);
};
plugin 'Build::Copy';
after build => sub {
my($build) = @_;
my $prefix = path($build->install_prop->{prefix});
$build->runtime_prop->{'style'} = 'binary';
$build->runtime_prop->{command} = 'python3';
my $framework_dst_dir = path('Python.framework');
my ($version_base) = $framework_dst_dir->child( qw(Versions) )->children( qr/^3\./ );
$build->runtime_prop->{share_bin_dir_rel} = $version_base->child('bin')->stringify;
};
}
share {
if( $^O eq 'MSWin32' ) {
do_binary_windows;
} elsif( $^O eq 'darwin' ) {
do_binary_macos;
} else {
do_source;
}
}
( run in 2.615 seconds using v1.01-cache-2.11-cpan-5b529ec07f3 )