110 lines
3.0 KiB
Python
110 lines
3.0 KiB
Python
import os
|
|
import shutil
|
|
|
|
from lib import arch, cpp
|
|
from lib.make import *
|
|
|
|
VERSION_BASE = "3.14"
|
|
VERSION_APPEND = "6"
|
|
|
|
VERSION_FULL = f"{VERSION_BASE}.{VERSION_APPEND}"
|
|
|
|
version(VERSION_FULL)
|
|
source_url(
|
|
f"https://www.python.org/ftp/python/{VERSION_FULL}/Python-{VERSION_FULL}.tar.xz"
|
|
)
|
|
|
|
builddep("shortcut/c")
|
|
builddep("shortcut/autotools")
|
|
builddep(f"liblzma-dev @{arch.get_target()}")
|
|
builddep(f"libzstd-dev @{arch.get_target()}")
|
|
builddep(f"libz-ng-dev @{arch.get_target()}")
|
|
builddep(f"aws-lc-dev @{arch.get_target()}")
|
|
builddep(f"libexpat-dev @{arch.get_target()}")
|
|
builddep(f"libsqlite-dev @{arch.get_target()}")
|
|
builddep(f"libncurses-dev @{arch.get_target()}")
|
|
builddep(f"libbzip2-dev @{arch.get_target()}")
|
|
builddep(f"libffi-dev @{arch.get_target()}")
|
|
builddep("pkgconf")
|
|
|
|
|
|
def build():
|
|
cpp.configure(
|
|
[
|
|
"--prefix=/",
|
|
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{VERSION_BASE}", f"lib/python{VERSION_BASE}"
|
|
)
|
|
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{VERSION_BASE}"
|
|
composer.makedir("lib")
|
|
composer.add_dir(f"lib/python{VERSION_BASE}", f"lib/python{VERSION_BASE}")
|
|
shutil.rmtree(f"{pystdpath}/test")
|
|
os.remove(
|
|
f"{pystdpath}/config-{VERSION_BASE}-{python_config_target()}/libpython{VERSION_BASE}.a"
|
|
)
|
|
os.remove(f"{pystdpath}/config-{VERSION_BASE}-{python_config_target()}/python.o")
|
|
|
|
# Pack native libraries
|
|
composer.addfile(
|
|
f"lib/libpython{VERSION_BASE}.so", f"lib/libpython{VERSION_BASE}.so"
|
|
)
|
|
composer.addfile(
|
|
f"lib/libpython{VERSION_BASE}.so.1.0", f"lib/libpython{VERSION_BASE}.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{VERSION_BASE}", "/bin/python3")
|
|
link(f"bin/python{VERSION_BASE}", "/bin/python")
|
|
|
|
package("libpython-dev")
|
|
dep("libpython (same)")
|
|
cpp.use_auto_pack(["dev"])
|
|
|
|
|
|
def pack_test(composer):
|
|
composer.makedirs(f"lib/python{VERSION_BASE}")
|
|
composer.add_dir(f"lib/python{VERSION_BASE}/test", f"lib/python{VERSION_BASE}/test")
|
|
|
|
|
|
package("python-test")
|
|
dep("libpython (same)")
|
|
on_pack(pack_test)
|