Skip to content

Commit 52abf79

Browse files
committed
feat(python): drop configure-project-installer, inline autotools build
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<sysroot>/usr/include core stdlib deps -I<sysroot>/usr/include/ncurses for `<termcap.h>` / `<curses.h>` flat lookup (ncurses installs these under the ncurses/ subdir) -I<sysroot>/usr/include/openssl for openssl 3 headers (some are under the openssl/ subdir) -L<sysroot>/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.
1 parent f3629b3 commit 52abf79

1 file changed

Lines changed: 60 additions & 34 deletions

File tree

pkgs/p/python.lua

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function _linux_download_url(version) return "https://www.python.org/ftp/python/" .. version .. "/Python-" .. version .. ".tar.xz" end
1+
function _linux_download_url(version)
2+
return format("https://www.python.org/ftp/python/%s/Python-%s.tar.xz", version, version)
3+
end
24

35
package = {
46
spec = "1",
@@ -7,7 +9,7 @@ package = {
79
name = "python",
810
description = "The Python programming language",
911
maintainers = "Python Software Foundation",
10-
licenses = "PSF License | GPL compatible",
12+
licenses = "PSF-2.0",
1113
repo = "https://github.com/python/cpython",
1214
docs = "https://docs.python.org/3",
1315

@@ -26,9 +28,9 @@ package = {
2628
xpm = {
2729
linux = {
2830
deps = {
31+
"xim:xpkg-helper@0.0.1",
2932
"xim:gcc@15.1.0",
3033
"xim:make@4.3",
31-
"xim:configure-project-installer@0.0.1",
3234
"fromsource:xz-utils@5.4.5",
3335
"fromsource:libffi@3.4.4",
3436
"fromsource:readline@8.2",
@@ -53,32 +55,59 @@ package = {
5355
import("xim.libxpkg.pkginfo")
5456
import("xim.libxpkg.system")
5557
import("xim.libxpkg.xvm")
58+
import("xim.libxpkg.log")
5659

5760
local binding_tree = "python-binding-tree"
5861

5962
function install()
60-
local project_dir = path.absolute("Python-" .. pkginfo.version())
61-
-- build args - opt or todo?
62-
--enable-shared
63-
--with-computed-gotos
64-
--with-lto
65-
--enable-ipv6
66-
--enable-loadable-sqlite-extensions
67-
-- add rpath to fix: Following modules built successfully but were removed because they could not be imported:
68-
local syslibdir = path.join(system.subos_sysrootdir(), "lib")
69-
os.setenv("LDFLAGS", "-Wl,-rpath," .. syslibdir)
70-
-- fix: test test_datetime failed (tzdata)
71-
os.setenv("TZDIR", "/usr/share/zoneinfo")
72-
system.exec("configure-project-installer "
73-
.. pkginfo.install_dir()
74-
.. " --project-dir " .. project_dir
75-
--.. " --args " .. [["--enable-shared --enable-optimizations"]]
76-
)
63+
-- Sandbox template (PR #49 bzip2): derive paths from pkginfo.install_file()
64+
-- since path.absolute is nil; chain configure + make + install in single
65+
-- sh -c (os.cd doesn't propagate to system.exec children).
66+
local runtime_dir = path.directory(pkginfo.install_file())
67+
local scode_dir = path.join(runtime_dir, "Python-" .. pkginfo.version())
68+
local build_dir = path.join(runtime_dir, "build-python")
69+
local prefix = pkginfo.install_dir()
70+
local sysroot = system.subos_sysrootdir()
71+
local syslibdir = path.join(sysroot, "lib")
72+
73+
os.tryrm(build_dir)
74+
os.mkdir(build_dir)
75+
76+
log.info("Configuring + building + installing python (autotools)...")
77+
-- CPPFLAGS / LDFLAGS point at the subos sysroot where the cluster-B
78+
-- deps (zlib, openssl, ncurses, readline, libffi, bzip2, xz-utils,
79+
-- util-linux/libuuid) installed their headers + libs via xvm.add. The
80+
-- extra -I .../usr/include/{ncurses,openssl} entries cover deps that
81+
-- ship under a subdir.
82+
-- LDFLAGS rpath points at the canonical /home/xlings/... so the produced
83+
-- python binary loads its shared deps from the standard xlings install
84+
-- layout on a user machine. TZDIR avoids test_datetime tzdata noise.
85+
-- Configure flags:
86+
-- --enable-shared: ship libpython3.so for embedders
87+
-- --with-computed-gotos: -fno-crossjumping main loop dispatch
88+
-- --enable-ipv6: sockets v6
89+
-- --enable-loadable-sqlite-extensions ready for future scode:sqlite3
90+
-- --with-system-ffi: link against fromsource:libffi
91+
-- --without-ensurepip: pip is added separately by xvm
92+
system.exec(string.format(
93+
"sh -c 'cd %s && "
94+
.. "CPPFLAGS=\"-I%s/usr/include -I%s/usr/include/ncurses -I%s/usr/include/openssl\" "
95+
.. "LDFLAGS=\"-L%s/lib -Wl,-rpath,/home/xlings/.xlings_data/subos/linux/lib\" "
96+
.. "TZDIR=/usr/share/zoneinfo "
97+
.. "%s/configure --prefix=%s "
98+
.. "--enable-shared --with-computed-gotos --enable-ipv6 "
99+
.. "--enable-loadable-sqlite-extensions --with-system-ffi "
100+
.. "&& make -j8 && make install'",
101+
build_dir,
102+
sysroot, sysroot, sysroot,
103+
sysroot,
104+
scode_dir, prefix
105+
))
106+
77107
return os.isdir(pkginfo.install_dir())
78108
end
79109

80110
function config()
81-
82111
local python_bindir = path.join(pkginfo.install_dir(), "bin")
83112
local binding_root = binding_tree .. "@" .. pkginfo.version()
84113

@@ -91,7 +120,7 @@ function config()
91120
envs = {
92121
TZDIR = "/usr/share/zoneinfo",
93122
-- python manim-test.py (need LD_LIBRARY_PATH to xlings subos lib)
94-
-- ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory
123+
-- ImportError: libstdc++.so.6: cannot open shared object file
95124
LD_LIBRARY_PATH = path.join(system.subos_sysrootdir(), "lib"),
96125
}
97126
}
@@ -128,19 +157,16 @@ end
128157

129158
--[[
130159
131-
[ERROR] readline failed to import: /home/xlings/.xlings_data/subos/linux/lib/libreadline.so.8: undefined symbol: UP
132-
The following modules are *disabled* in configure script:
133-
_sqlite3
134-
135-
The necessary bits to build these optional modules were not found:
136-
_bz2 _curses _curses_panel
137-
_dbm _gdbm _tkinter
138-
To find the necessary bits, look in configure.ac and config.log.
160+
Historical build-time notes:
139161
140-
Following modules built successfully but were removed because they could not be imported:
141-
readline -- by patch to fix
162+
[ERROR] readline failed to import: ... undefined symbol: UP
163+
-> fixed by readline-8.2 patch sequence (PR for readline)
142164
143-
Checked 112 modules (33 built-in, 70 shared, 1 n/a on linux-x86_64, 1 disabled, 6 missing, 1 failed on import)
165+
Optional modules that may be missing depending on what scode/fromsource
166+
packages are installed:
144167
168+
_sqlite3
169+
_bz2 _curses _curses_panel _dbm _gdbm _tkinter
145170
146-
]]
171+
Tracked under the "TODO: gdbm, sqlite3, tk/tkinter" line in deps.
172+
]]

0 commit comments

Comments
 (0)