summaryrefslogtreecommitdiff
path: root/tw
diff options
context:
space:
mode:
authorTimo Wilken2023-01-19 23:22:03 +0100
committerTimo Wilken2023-01-19 23:22:03 +0100
commit8a8ea5700baa3f56a2edbdd08ebd013631a31e15 (patch)
tree798c839117a6cdde01de21b0b2f55723f8ad8df5 /tw
parentbd99c054ed81f266c4d8ae66de9196b67cd2bd91 (diff)
Add almost-working Python 3.11 package
Diffstat (limited to 'tw')
-rw-r--r--tw/packages/python.scm48
1 files changed, 48 insertions, 0 deletions
diff --git a/tw/packages/python.scm b/tw/packages/python.scm
new file mode 100644
index 00000000..be8271b8
--- /dev/null
+++ b/tw/packages/python.scm
@@ -0,0 +1,48 @@
+(define-module (tw packages python)
+ #:use-module (gnu packages)
+ #:use-module (gnu packages python)
+ #:use-module (guix packages)
+ #:use-module (guix utils))
+
+(define-public python-3.11
+ (package
+ (inherit python-3.9)
+ (version "3.11.1")
+ (source
+ (origin
+ (inherit (package-source python-3.9))
+ (uri (string-append "https://www.python.org/ftp/python/"
+ version "/Python-" version ".tar.xz"))
+ (patches (search-patches
+ ;; "python-3-arm-alignment.patch" ; merged upstream
+ ;; "python-3-no-static-lib.patch" ; Makefile has changed significantly, this doesn't apply cleanly any more
+ "python-3.11-fix-tests.patch" ; patched patch for 3.11
+ "python-3-deterministic-build-info.patch" ; from python-3.9
+ "python-3-hurd-configure.patch" ; from python-3.9
+ "python-3-search-paths.patch")) ; from python-3.9
+ (sha256 (base32 "13xmvw0pjqr96mr69xxpjkiybwzb95cr14n02v5mdzfgya9931w5"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments python-3.9)
+ ((#:configure-flags flags)
+ `(cons*
+ ;; FIXME: These flags make Python significantly faster, but make
+ ;; binaries non-reproducible.
+ "--with-lto" ; increase size by 20MB, but 15% speedup
+ "--enable-optimizations"
+ ,flags))
+ ((#:phases phases)
+ `(modify-phases ,phases
+ ;; Fix the "test_tools" test. This relies on `bash' or `bash-minimal' being an input.
+ (add-before 'configure 'patch-default-shell
+ (lambda* (#:key inputs configure-flags #:allow-other-keys)
+ (use-modules (ice-9 format))
+ (let ((/bin/sh (string-append (assoc-ref inputs "bash") "/bin/sh")))
+ ;; Patch ./configure to set the right CONFIG_SHELL fallback, not /bin/sh.
+ (substitute* "configure"
+ (("-/bin/sh") ; the "-" prevents us from patching the shebang
+ (string-append "-" /bin/sh))
+ (("^CONFIG_ARGS=.*$") ; the freeze test uses CONFIG_ARGS
+ (format #f "CONFIG_ARGS='~{\"~a\" ~}'" configure-flags)))
+ (substitute* "Makefile.pre.in"
+ (("^SHELL=[[:space:]]*/bin/sh$")
+ (string-append "SHELL=" /bin/sh))))))))))))