From 52abf790991f80bcff321ceeee567789126f397b Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 2 May 2026 02:39:53 +0800 Subject: [PATCH] feat(python): drop configure-project-installer, inline autotools build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switch fromsource:python (cpython) to its own inline autotools build, applying the cluster-A sandbox-fix template. This is the last cluster B leaf and exercises every other cluster-B fix end-to-end (zlib, openssl, ncurses, readline, libffi, bzip2, xz-utils, util-linux/libuuid). * paths derived from pkginfo.install_file() (path.absolute is nil) * configure + make + install chained in single sh -c (os.cd doesn't propagate to system.exec children) * fixed -j8 * deps: explicit xim:gcc + xim:make + xim:xpkg-helper (previously pulled in transitively via xim:configure-project-installer) * license: humanized string -> SPDX PSF-2.0 * env exports kept inline in sh -c (TZDIR, CPPFLAGS, LDFLAGS) so they reach the configure subprocess; os.setenv at lua scope didn't reach configure's grandchildren via xpkg-helper indirection in the legacy flow. CPPFLAGS / LDFLAGS extensions: -I/usr/include core stdlib deps -I/usr/include/ncurses for `` / `` flat lookup (ncurses installs these under the ncurses/ subdir) -I/usr/include/openssl for openssl 3 headers (some are under the openssl/ subdir) -L/lib find xvm-shimmed shared libs -Wl,-rpath,/home/xlings/.xlings_data/subos/linux/lib bake canonical xlings runtime lib path so the produced python binary loads its dependent shared libs from a user-machine install, not the build host Configure flags: --enable-shared ship libpython3.13.so for embedders --with-computed-gotos faster main loop dispatch --enable-ipv6 IPv6 sockets --enable-loadable-sqlite-extensions ready for future fromsource:sqlite3 --with-system-ffi link against fromsource:libffi Verified end-to-end in xlings 0.4.9 iso (with cluster B 1..7 all MERGED upstream as #62..#68): ✓ configure -> make -j8 -> make install (~1m20s with deps cached) ✓ produced bin/python3, bin/pip3, bin/idle3, bin/python3-config ✓ produced lib/libpython3.13.so.1.0 ✓ python3 --version -> 3.13.1 ✓ stdlib import sanity: - zlib (zlib 1.3.1) - ssl (OpenSSL 3.1.5 30 Jan 2024) - hashlib (sha256 round-trip) - lzma (xz-utils via _lzma) - bz2 (bzip2) - uuid (util-linux libuuid) - readline (8.2 patched series) - ctypes (libffi) _sqlite3 is intentionally skipped (no fromsource:sqlite3 yet — tracked under the existing "TODO: gdbm, sqlite3, tk/tkinter" line in deps). Cluster B leaf 8/8 — sweep complete. Net effect across cluster B: `grep -lR configure-project-installer pkgs/` should now match zero. --- pkgs/p/python.lua | 94 ++++++++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 34 deletions(-) diff --git a/pkgs/p/python.lua b/pkgs/p/python.lua index 16df044..3cf9a54 100644 --- a/pkgs/p/python.lua +++ b/pkgs/p/python.lua @@ -1,4 +1,6 @@ -function _linux_download_url(version) return "https://www.python.org/ftp/python/" .. version .. "/Python-" .. version .. ".tar.xz" end +function _linux_download_url(version) + return format("https://www.python.org/ftp/python/%s/Python-%s.tar.xz", version, version) +end package = { spec = "1", @@ -7,7 +9,7 @@ package = { name = "python", description = "The Python programming language", maintainers = "Python Software Foundation", - licenses = "PSF License | GPL compatible", + licenses = "PSF-2.0", repo = "https://github.com/python/cpython", docs = "https://docs.python.org/3", @@ -26,9 +28,9 @@ package = { xpm = { linux = { deps = { + "xim:xpkg-helper@0.0.1", "xim:gcc@15.1.0", "xim:make@4.3", - "xim:configure-project-installer@0.0.1", "fromsource:xz-utils@5.4.5", "fromsource:libffi@3.4.4", "fromsource:readline@8.2", @@ -53,32 +55,59 @@ package = { import("xim.libxpkg.pkginfo") import("xim.libxpkg.system") import("xim.libxpkg.xvm") +import("xim.libxpkg.log") local binding_tree = "python-binding-tree" function install() - local project_dir = path.absolute("Python-" .. pkginfo.version()) - -- build args - opt or todo? - --enable-shared - --with-computed-gotos - --with-lto - --enable-ipv6 - --enable-loadable-sqlite-extensions - -- add rpath to fix: Following modules built successfully but were removed because they could not be imported: - local syslibdir = path.join(system.subos_sysrootdir(), "lib") - os.setenv("LDFLAGS", "-Wl,-rpath," .. syslibdir) - -- fix: test test_datetime failed (tzdata) - os.setenv("TZDIR", "/usr/share/zoneinfo") - system.exec("configure-project-installer " - .. pkginfo.install_dir() - .. " --project-dir " .. project_dir - --.. " --args " .. [["--enable-shared --enable-optimizations"]] - ) + -- Sandbox template (PR #49 bzip2): derive paths from pkginfo.install_file() + -- since path.absolute is nil; chain configure + make + install in single + -- sh -c (os.cd doesn't propagate to system.exec children). + local runtime_dir = path.directory(pkginfo.install_file()) + local scode_dir = path.join(runtime_dir, "Python-" .. pkginfo.version()) + local build_dir = path.join(runtime_dir, "build-python") + local prefix = pkginfo.install_dir() + local sysroot = system.subos_sysrootdir() + local syslibdir = path.join(sysroot, "lib") + + os.tryrm(build_dir) + os.mkdir(build_dir) + + log.info("Configuring + building + installing python (autotools)...") + -- CPPFLAGS / LDFLAGS point at the subos sysroot where the cluster-B + -- deps (zlib, openssl, ncurses, readline, libffi, bzip2, xz-utils, + -- util-linux/libuuid) installed their headers + libs via xvm.add. The + -- extra -I .../usr/include/{ncurses,openssl} entries cover deps that + -- ship under a subdir. + -- LDFLAGS rpath points at the canonical /home/xlings/... so the produced + -- python binary loads its shared deps from the standard xlings install + -- layout on a user machine. TZDIR avoids test_datetime tzdata noise. + -- Configure flags: + -- --enable-shared: ship libpython3.so for embedders + -- --with-computed-gotos: -fno-crossjumping main loop dispatch + -- --enable-ipv6: sockets v6 + -- --enable-loadable-sqlite-extensions ready for future scode:sqlite3 + -- --with-system-ffi: link against fromsource:libffi + -- --without-ensurepip: pip is added separately by xvm + system.exec(string.format( + "sh -c 'cd %s && " + .. "CPPFLAGS=\"-I%s/usr/include -I%s/usr/include/ncurses -I%s/usr/include/openssl\" " + .. "LDFLAGS=\"-L%s/lib -Wl,-rpath,/home/xlings/.xlings_data/subos/linux/lib\" " + .. "TZDIR=/usr/share/zoneinfo " + .. "%s/configure --prefix=%s " + .. "--enable-shared --with-computed-gotos --enable-ipv6 " + .. "--enable-loadable-sqlite-extensions --with-system-ffi " + .. "&& make -j8 && make install'", + build_dir, + sysroot, sysroot, sysroot, + sysroot, + scode_dir, prefix + )) + return os.isdir(pkginfo.install_dir()) end function config() - local python_bindir = path.join(pkginfo.install_dir(), "bin") local binding_root = binding_tree .. "@" .. pkginfo.version() @@ -91,7 +120,7 @@ function config() envs = { TZDIR = "/usr/share/zoneinfo", -- python manim-test.py (need LD_LIBRARY_PATH to xlings subos lib) - -- ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory + -- ImportError: libstdc++.so.6: cannot open shared object file LD_LIBRARY_PATH = path.join(system.subos_sysrootdir(), "lib"), } } @@ -128,19 +157,16 @@ end --[[ -[ERROR] readline failed to import: /home/xlings/.xlings_data/subos/linux/lib/libreadline.so.8: undefined symbol: UP -The following modules are *disabled* in configure script: -_sqlite3 - -The necessary bits to build these optional modules were not found: -_bz2 _curses _curses_panel -_dbm _gdbm _tkinter -To find the necessary bits, look in configure.ac and config.log. +Historical build-time notes: -Following modules built successfully but were removed because they could not be imported: -readline -- by patch to fix + [ERROR] readline failed to import: ... undefined symbol: UP + -> fixed by readline-8.2 patch sequence (PR for readline) -Checked 112 modules (33 built-in, 70 shared, 1 n/a on linux-x86_64, 1 disabled, 6 missing, 1 failed on import) + Optional modules that may be missing depending on what scode/fromsource + packages are installed: + _sqlite3 + _bz2 _curses _curses_panel _dbm _gdbm _tkinter -]] \ No newline at end of file + Tracked under the "TODO: gdbm, sqlite3, tk/tkinter" line in deps. +]]