guix_mirror_bot pushed a commit to branch python-team
in repository guix.

commit 2405fccc1135f0485fd21e17d0a2bceb6a52d09d
Author: Nicolas Graves <[email protected]>
AuthorDate: Fri Oct 31 00:46:40 2025 +0100

    gnu: Add python-setuptools-bootstrap.
    
    This change is a combined commits, proposed in the following merge
    requests:
    
    - https://codeberg.org/guix/guix/pulls/5034
    - https://codeberg.org/guix/guix/pulls/5770
    
    As they are related to a new addition they are squashed to prevent bad
    git bisects.
    
    * gnu/packages/python-build.scm (python-setuptools-bootstrap): New variable.
    
    Change-Id: I7677ede70a61b9cc39ae6e021fc2f1f1afaa8d25
    Modified-by: Sharlatan Hellseher <[email protected]>
    Signed-off-by: Sharlatan Hellseher <[email protected]>
---
 gnu/packages/python-build.scm | 65 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/gnu/packages/python-build.scm b/gnu/packages/python-build.scm
index 3bddb7a3dc..d841fd2644 100644
--- a/gnu/packages/python-build.scm
+++ b/gnu/packages/python-build.scm
@@ -41,6 +41,7 @@
 (define-module (gnu packages python-build)
   #:use-module (gnu packages)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
   #:use-module (guix build-system pyproject)
   #:use-module (guix gexp)
@@ -376,6 +377,70 @@ facilitate packaging Python projects, where packaging 
includes:
                    license:asl2.0       ;packaging is dual ASL2/BSD-2
                    license:bsd-2))))
 
+(define-public python-setuptools-bootstrap
+  (package/inherit python-setuptools
+    (name "python-setuptools-bootstrap")
+    ;; version and source are purposefully not inherited, to allow
+    ;; updating python-setuptools in the python-team scope, whereas
+    ;; python-setuptools-bootstrap is in the core-packages-team scope.
+    (version "80.9.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "setuptools" version))
+       (sha256
+        (base32 "175iixi2h2jz8y2bpwziak360hvv43jfhipwzbdniryd5r04fszk"))
+       (modules '((guix build utils)))
+       (snippet
+        ;; TODO: setuptools now bundles the following libraries:
+        ;; packaging, pyparsing, six and appdirs.  How to unbundle?
+        ;; Remove included binaries which are used to build self-extracting
+        ;; installers for Windows.
+        '(for-each delete-file (find-files "setuptools"
+                                           "^(cli|gui).*\\.exe$")))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:tests? #f                       ;disabled to avoid extra dependencies
+      ;; Essentially a lighter copy of the former python-build-system.
+      ;; Using it rather than pyproject-build-system allows to edit the latter
+      ;; without a world rebuild (for the meson package in particular).
+      #:phases
+      #~(modify-phases %standard-phases
+          (delete 'bootstrap)
+          (delete 'configure)
+          (replace 'build
+            (lambda _
+              (invoke "python" "./setup.py" "build")))
+          (replace 'install
+            (lambda _
+              (invoke "python" "./setup.py" "install"
+                      (string-append "--prefix=" #$output) "--no-compile")
+              (invoke "python" "-m" "compileall"
+                      "--invalidation-mode=unchecked-hash" #$output)))
+          ;; XXX: Despite using the same setup.py, it seems that the
+          ;; bootstrap version is not able to install the distutils hack.
+          (add-after 'install 'fix-installation
+            (lambda* (#:key outputs #:allow-other-keys)
+              (with-directory-excursion
+                  (car (find-files #$output "site-packages"
+                                   #:directories? #t))
+                (call-with-output-file "distutils-precedence.pth"
+                  (lambda (port)
+                    (display
+                     (string-join
+                      '("import os"
+                        "var = 'SETUPTOOLS_USE_DISTUTILS'"
+                        "enabled = os.environ.get(var, 'local') == 'local'"
+                        "enabled and 
__import__('_distutils_hack').add_shim();")
+                      "; ")
+                     port)))))))))
+    (native-inputs (list))
+    ;; Avoid introducing an additional module-dependency.
+    (inputs (list (module-ref (resolve-interface '(gnu packages python))
+                              'python-wrapper)))
+    (propagated-inputs (list))))
+
 (define-public python-setuptools-67
   (package
     (inherit python-setuptools)

Reply via email to