Files
2026-10-31 03:05:01 +00:00

108 lines
3.0 KiB
Python

import os
import shutil
from lib import arch, cpp
from lib.make import *
full_version = "3.15.2"
[major_version, minor_version, rev_version] = full_version.split('.')
base_version = f"{major_version}.{minor_version}"
version(full_version)
description("the Python programming language")
maintainer("sisungo <[email protected]>")
source_managed("github://python/cpython#v3.15.2")
builddep("shortcut/c")
builddep("shortcut/autotools")
builddep("liblzma-dev @target")
builddep("libzstd-dev @target")
builddep("libz-ng-dev @target")
builddep("aws-lc-dev @target")
builddep("libexpat-dev @target")
builddep("libsqlite-dev @target")
builddep("libncurses-dev @target")
builddep("libbzip2-dev @target")
builddep("libffi-dev @target")
builddep("pkgconf")
def build():
cpp.configure([
"--prefix=/",
f"--libdir={get_prefix('libpython')}/lib",
f"--bindir={get_prefix('python')}/bin",
f"--includedir={get_prefix('libpython-dev')}/include",
f"--with-platlibdir=lib/{arch.get_target()}",
"--enable-shared",
"--enable-safety",
"--enable-optimizations",
"--enable-loadable-sqlite-extensions",
"--enable-ipv6",
"--with-lto=thin",
"--with-tzpath=/share/zoneinfo",
"--with-system-expat",
"--with-system-libmpdec",
"--with-readline=editline",
"--with-tail-call-interp",
"--without-ensurepip",
"--with-ssl-default-suites=openssl",
])
cpp.make()
cpp.make_install()
os.rename(
f"lib/{arch.get_target()}/python{base_version}", f"lib/python{base_version}"
)
os.rmdir(f"lib/{arch.get_target()}")
on_build(build)
def python_config_target():
return arch.get_target().replace("-semios-linux", "-linux-musl")
def pack_libpython(composer):
# Pack the standard library
pystdpath = f"{composer.workdir}/bundle/lib/python{base_version}"
composer.makedir("lib")
composer.add_dir(f"lib/python{base_version}", f"lib/python{base_version}")
shutil.rmtree(f"{pystdpath}/test")
os.remove(
f"{pystdpath}/config-{base_version}-{python_config_target()}/libpython{base_version}.a"
)
os.remove(f"{pystdpath}/config-{base_version}-{python_config_target()}/python.o")
# Pack native libraries
composer.addfile(
f"lib/libpython{base_version}.so", f"lib/libpython{base_version}.so"
)
composer.addfile(
f"lib/libpython{base_version}.so.1.0", f"lib/libpython{base_version}.so.1.0"
)
composer.addfile("lib/libpython3.so", "lib/libpython3.so")
package("libpython")
dep("semi-libc @same-arch")
on_pack(pack_libpython)
package("python")
dep("libpython (same)")
cpp.use_auto_pack(["bin"])
link(f"bin/python{base_version}", "/bin/python3")
link(f"bin/python{base_version}", "/bin/python")
package("libpython-dev")
dep("libpython (same)")
cpp.use_auto_pack(["dev"])
def pack_test(composer):
composer.makedirs(f"lib/python{base_version}")
composer.add_dir(f"lib/python{base_version}/test", f"lib/python{base_version}/test")
package("python-test")
dep("libpython (same)")
on_pack(pack_test)