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. +]]