summaryrefslogtreecommitdiff
path: root/gnu/packages/python.scm
diff options
context:
space:
mode:
authorJosselin Poiret <dev@jpoiret.xyz>2024-05-16 13:56:17 +0200
committerLudovic Courtès <ludo@gnu.org>2024-08-31 10:45:03 +0200
commitfae667797949aba4e8e2b4a813b7035ba947f6f9 (patch)
tree47cf38f01a8e931567ae0305b7c2138fd99a348a /gnu/packages/python.scm
parent49c35eec114c20500d0d5eb6cc2e121f3bbd18eb (diff)
gnu: python-3.10: Ungraft removing bundled cacert.pem.
* gnu/packages/python.scm (python-3.10): Rename phase "remove-windows-binaries" to "remove-vendored-wheel-content", and use it to also remove "cacert.pem". Ungraft. (python-3.10/fixed): Remove variable. Change-Id: I0a1a5c7f597ef6e14ea165ccded9aa473c6d9122
Diffstat (limited to 'gnu/packages/python.scm')
-rw-r--r--gnu/packages/python.scm112
1 files changed, 35 insertions, 77 deletions
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 4deca6769d5..c5f98c3a46f 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -453,7 +453,6 @@ data types.")
453 (inherit python-2) 453 (inherit python-2)
454 (name "python") 454 (name "python")
455 (version "3.10.7") 455 (version "3.10.7")
456 (replacement python-3.10/fixed)
457 (source (origin 456 (source (origin
458 (method url-fetch) 457 (method url-fetch)
459 (uri (string-append "https://www.python.org/ftp/python/" 458 (uri (string-append "https://www.python.org/ftp/python/"
@@ -546,7 +545,7 @@ data types.")
546 (substitute* "Makefile.pre.in" 545 (substitute* "Makefile.pre.in"
547 (("-j0") "-j1"))))) 546 (("-j0") "-j1")))))
548 '()) 547 '())
549 (add-after 'unpack 'remove-windows-binaries 548 (add-after 'unpack 'remove-vendored-wheel-content
550 (lambda _ 549 (lambda _
551 ;; Delete .exe from embedded .whl (zip) files 550 ;; Delete .exe from embedded .whl (zip) files
552 (for-each 551 (for-each
@@ -560,6 +559,40 @@ data types.")
560 (for-each delete-file 559 (for-each delete-file
561 (find-files "." "\\.exe$")) 560 (find-files "." "\\.exe$"))
562 (delete-file whl) 561 (delete-file whl)
562
563 ;; Search for cacert.pem, delete it, and rewrite the
564 ;; file which directs python to look for it.
565 (let ((cacert (find-files "." "cacert\\.pem")))
566 (unless (null? cacert)
567 (let ((certifi (dirname (car cacert))))
568 (delete-file (string-append certifi "/cacert.pem"))
569 (delete-file (string-append certifi "/core.py"))
570 (with-output-to-file (string-append certifi "/core.py")
571 (lambda _
572 (display "\"\"\"
573certifi.py
574~~~~~~~~~~
575This file is a Guix-specific version of core.py.
576
577This module returns the installation location of SSL_CERT_FILE or
578/etc/ssl/certs/ca-certificates.crt, or its contents.
579\"\"\"
580import os
581
582_CA_CERTS = None
583
584try:
585 _CA_CERTS = os.environ [\"SSL_CERT_FILE\"]
586except:
587 _CA_CERTS = os.path.join(\"/etc\", \"ssl\", \"certs\", \"ca-certificates.crt\")
588
589def where() -> str:
590 return _CA_CERTS
591
592def contents() -> str:
593 with open(where(), \"r\", encoding=\"ascii\") as data:
594 return data.read()"))))))
595
563 ;; Reset timestamps to prevent them from ending 596 ;; Reset timestamps to prevent them from ending
564 ;; up in the Zip archive. 597 ;; up in the Zip archive.
565 (ftw "." (lambda (file stat flag) 598 (ftw "." (lambda (file stat flag)
@@ -1014,81 +1047,6 @@ data types.")
1014 (properties '((cpe-name . "python"))) 1047 (properties '((cpe-name . "python")))
1015 (license license:psfl))) 1048 (license license:psfl)))
1016 1049
1017(define python-3.10/fixed
1018 (package
1019 (inherit python-3.10)
1020 (arguments
1021 (substitute-keyword-arguments (package-arguments python-3.10)
1022 ((#:phases phases)
1023 #~(modify-phases #$phases
1024 ;; Also remove the bundled CA certificates.
1025 ;; TODO: Rename this phase when merging back into python.
1026 (replace 'remove-windows-binaries
1027 (lambda _
1028 ;; Delete .exe from embedded .whl (zip) files
1029 (for-each
1030 (lambda (whl)
1031 (let ((dir "whl-content")
1032 (circa-1980 (* 10 366 24 60 60)))
1033 (mkdir-p dir)
1034 (with-directory-excursion dir
1035 (let ((whl (string-append "../" whl)))
1036 (invoke "unzip" whl)
1037 (for-each delete-file
1038 (find-files "." "\\.exe$"))
1039 (delete-file whl)
1040
1041 ;; Search for cacert.pem, delete it, and rewrite the
1042 ;; file which directs python to look for it.
1043 (let ((cacert (find-files "." "cacert\\.pem")))
1044 (unless (null? cacert)
1045 (let ((certifi (dirname (car cacert))))
1046 (delete-file (string-append certifi "/cacert.pem"))
1047 (delete-file (string-append certifi "/core.py"))
1048 (with-output-to-file (string-append certifi "/core.py")
1049 (lambda _
1050 (display "\"\"\"
1051certifi.py
1052~~~~~~~~~~
1053This file is a Guix-specific version of core.py.
1054
1055This module returns the installation location of SSL_CERT_FILE or
1056/etc/ssl/certs/ca-certificates.crt, or its contents.
1057\"\"\"
1058import os
1059
1060_CA_CERTS = None
1061
1062try:
1063 _CA_CERTS = os.environ [\"SSL_CERT_FILE\"]
1064except:
1065 _CA_CERTS = os.path.join(\"/etc\", \"ssl\", \"certs\", \"ca-certificates.crt\")
1066
1067def where() -> str:
1068 return _CA_CERTS
1069
1070def contents() -> str:
1071 with open(where(), \"r\", encoding=\"ascii\") as data:
1072 return data.read()"))))))
1073
1074 ;; Reset timestamps to prevent them from ending
1075 ;; up in the Zip archive.
1076 (ftw "." (lambda (file stat flag)
1077 (utime file circa-1980 circa-1980)
1078 #t))
1079 (apply invoke "zip" "-X" whl
1080 (find-files "." #:directories? #t))))
1081 (delete-file-recursively dir)))
1082 (find-files "Lib/ensurepip" "\\.whl$"))))))))
1083 (native-search-paths
1084 (list (guix-pythonpath-search-path (package-version python-3.10))
1085 $SSL_CERT_FILE
1086 ;; Used to locate tzdata by the zoneinfo module introduced in
1087 ;; Python 3.9.
1088 (search-path-specification
1089 (variable "PYTHONTZPATH")
1090 (files (list "share/zoneinfo")))))))
1091
1092;; Next 3.x version. 1050;; Next 3.x version.
1093(define-public python-next python-3.12) 1051(define-public python-next python-3.12)
1094 1052