mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
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
This commit is contained in:
parent
49c35eec11
commit
fae6677979
1 changed files with 35 additions and 77 deletions
|
@ -453,7 +453,6 @@ (define-public python-3.10
|
||||||
(inherit python-2)
|
(inherit python-2)
|
||||||
(name "python")
|
(name "python")
|
||||||
(version "3.10.7")
|
(version "3.10.7")
|
||||||
(replacement python-3.10/fixed)
|
|
||||||
(source (origin
|
(source (origin
|
||||||
(method url-fetch)
|
(method url-fetch)
|
||||||
(uri (string-append "https://www.python.org/ftp/python/"
|
(uri (string-append "https://www.python.org/ftp/python/"
|
||||||
|
@ -546,7 +545,7 @@ (define-public python-3.10
|
||||||
(substitute* "Makefile.pre.in"
|
(substitute* "Makefile.pre.in"
|
||||||
(("-j0") "-j1")))))
|
(("-j0") "-j1")))))
|
||||||
'())
|
'())
|
||||||
(add-after 'unpack 'remove-windows-binaries
|
(add-after 'unpack 'remove-vendored-wheel-content
|
||||||
(lambda _
|
(lambda _
|
||||||
;; Delete .exe from embedded .whl (zip) files
|
;; Delete .exe from embedded .whl (zip) files
|
||||||
(for-each
|
(for-each
|
||||||
|
@ -560,6 +559,40 @@ (define-public python-3.10
|
||||||
(for-each delete-file
|
(for-each delete-file
|
||||||
(find-files "." "\\.exe$"))
|
(find-files "." "\\.exe$"))
|
||||||
(delete-file whl)
|
(delete-file whl)
|
||||||
|
|
||||||
|
;; Search for cacert.pem, delete it, and rewrite the
|
||||||
|
;; file which directs python to look for it.
|
||||||
|
(let ((cacert (find-files "." "cacert\\.pem")))
|
||||||
|
(unless (null? cacert)
|
||||||
|
(let ((certifi (dirname (car cacert))))
|
||||||
|
(delete-file (string-append certifi "/cacert.pem"))
|
||||||
|
(delete-file (string-append certifi "/core.py"))
|
||||||
|
(with-output-to-file (string-append certifi "/core.py")
|
||||||
|
(lambda _
|
||||||
|
(display "\"\"\"
|
||||||
|
certifi.py
|
||||||
|
~~~~~~~~~~
|
||||||
|
This file is a Guix-specific version of core.py.
|
||||||
|
|
||||||
|
This module returns the installation location of SSL_CERT_FILE or
|
||||||
|
/etc/ssl/certs/ca-certificates.crt, or its contents.
|
||||||
|
\"\"\"
|
||||||
|
import os
|
||||||
|
|
||||||
|
_CA_CERTS = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
_CA_CERTS = os.environ [\"SSL_CERT_FILE\"]
|
||||||
|
except:
|
||||||
|
_CA_CERTS = os.path.join(\"/etc\", \"ssl\", \"certs\", \"ca-certificates.crt\")
|
||||||
|
|
||||||
|
def where() -> str:
|
||||||
|
return _CA_CERTS
|
||||||
|
|
||||||
|
def contents() -> str:
|
||||||
|
with open(where(), \"r\", encoding=\"ascii\") as data:
|
||||||
|
return data.read()"))))))
|
||||||
|
|
||||||
;; Reset timestamps to prevent them from ending
|
;; Reset timestamps to prevent them from ending
|
||||||
;; up in the Zip archive.
|
;; up in the Zip archive.
|
||||||
(ftw "." (lambda (file stat flag)
|
(ftw "." (lambda (file stat flag)
|
||||||
|
@ -1014,81 +1047,6 @@ (define-public python-3.12
|
||||||
(properties '((cpe-name . "python")))
|
(properties '((cpe-name . "python")))
|
||||||
(license license:psfl)))
|
(license license:psfl)))
|
||||||
|
|
||||||
(define python-3.10/fixed
|
|
||||||
(package
|
|
||||||
(inherit python-3.10)
|
|
||||||
(arguments
|
|
||||||
(substitute-keyword-arguments (package-arguments python-3.10)
|
|
||||||
((#:phases phases)
|
|
||||||
#~(modify-phases #$phases
|
|
||||||
;; Also remove the bundled CA certificates.
|
|
||||||
;; TODO: Rename this phase when merging back into python.
|
|
||||||
(replace 'remove-windows-binaries
|
|
||||||
(lambda _
|
|
||||||
;; Delete .exe from embedded .whl (zip) files
|
|
||||||
(for-each
|
|
||||||
(lambda (whl)
|
|
||||||
(let ((dir "whl-content")
|
|
||||||
(circa-1980 (* 10 366 24 60 60)))
|
|
||||||
(mkdir-p dir)
|
|
||||||
(with-directory-excursion dir
|
|
||||||
(let ((whl (string-append "../" whl)))
|
|
||||||
(invoke "unzip" whl)
|
|
||||||
(for-each delete-file
|
|
||||||
(find-files "." "\\.exe$"))
|
|
||||||
(delete-file whl)
|
|
||||||
|
|
||||||
;; Search for cacert.pem, delete it, and rewrite the
|
|
||||||
;; file which directs python to look for it.
|
|
||||||
(let ((cacert (find-files "." "cacert\\.pem")))
|
|
||||||
(unless (null? cacert)
|
|
||||||
(let ((certifi (dirname (car cacert))))
|
|
||||||
(delete-file (string-append certifi "/cacert.pem"))
|
|
||||||
(delete-file (string-append certifi "/core.py"))
|
|
||||||
(with-output-to-file (string-append certifi "/core.py")
|
|
||||||
(lambda _
|
|
||||||
(display "\"\"\"
|
|
||||||
certifi.py
|
|
||||||
~~~~~~~~~~
|
|
||||||
This file is a Guix-specific version of core.py.
|
|
||||||
|
|
||||||
This module returns the installation location of SSL_CERT_FILE or
|
|
||||||
/etc/ssl/certs/ca-certificates.crt, or its contents.
|
|
||||||
\"\"\"
|
|
||||||
import os
|
|
||||||
|
|
||||||
_CA_CERTS = None
|
|
||||||
|
|
||||||
try:
|
|
||||||
_CA_CERTS = os.environ [\"SSL_CERT_FILE\"]
|
|
||||||
except:
|
|
||||||
_CA_CERTS = os.path.join(\"/etc\", \"ssl\", \"certs\", \"ca-certificates.crt\")
|
|
||||||
|
|
||||||
def where() -> str:
|
|
||||||
return _CA_CERTS
|
|
||||||
|
|
||||||
def contents() -> str:
|
|
||||||
with open(where(), \"r\", encoding=\"ascii\") as data:
|
|
||||||
return data.read()"))))))
|
|
||||||
|
|
||||||
;; Reset timestamps to prevent them from ending
|
|
||||||
;; up in the Zip archive.
|
|
||||||
(ftw "." (lambda (file stat flag)
|
|
||||||
(utime file circa-1980 circa-1980)
|
|
||||||
#t))
|
|
||||||
(apply invoke "zip" "-X" whl
|
|
||||||
(find-files "." #:directories? #t))))
|
|
||||||
(delete-file-recursively dir)))
|
|
||||||
(find-files "Lib/ensurepip" "\\.whl$"))))))))
|
|
||||||
(native-search-paths
|
|
||||||
(list (guix-pythonpath-search-path (package-version python-3.10))
|
|
||||||
$SSL_CERT_FILE
|
|
||||||
;; Used to locate tzdata by the zoneinfo module introduced in
|
|
||||||
;; Python 3.9.
|
|
||||||
(search-path-specification
|
|
||||||
(variable "PYTHONTZPATH")
|
|
||||||
(files (list "share/zoneinfo")))))))
|
|
||||||
|
|
||||||
;; Next 3.x version.
|
;; Next 3.x version.
|
||||||
(define-public python-next python-3.12)
|
(define-public python-next python-3.12)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue