diff options
| author | Nicolas Graves <ngraves@ngraves.fr> | 2026-01-02 23:16:02 +0100 |
|---|---|---|
| committer | Andreas Enge <andreas@enge.fr> | 2026-02-07 12:28:24 +0100 |
| commit | 2dfc6c477c4e3f96b3849751369b46d8e6d0ce23 (patch) | |
| tree | 1ce353695522a081bfb6d1a3ac860a590c7b75af /gnu/packages/python-build.scm | |
| parent | 85a45ad58f7b48617b7fda50614779a8f2703710 (diff) | |
gnu: python-setuptools: Bootstrap the package properly.
This commit includes changes submitted in two merge requests:
- https://codeberg.org/guix/guix/pulls/5723
- https://codeberg.org/guix/guix/pulls/5362
Related issue with bootstraping and "guix pull":
- https://codeberg.org/guix/guix/issues/5813
* gnu/packages/python-build.scm (python-setuptools)
[arguments]<#:test-flags>: Ignore failing tests.
<#:phases>: Add phases 'build-bundled-wheel-for-tests, 'cleanup,
'configure-tests, 'drop-platformdirs-requirement,
'cleanup-installed-tests.
[propagated-inputs]: Add python-jaraco-functools, python-jaraco-text,
python-more-itertools, python-packaging, python-wheel.
[native-inputs]: Add python-autocommand, python-backports-tarfile,
python-filelock-bootstrap, python-inflect, python-jaraco-collections,
python-jaraco-context, python-jaraco-envs-bootstrap,
python-jaraco-functools, python-jaraco-path, python-jaraco-test,
python-jaraco-text, python-more-itertools, python-packaging,
python-path, python-platformdirs-bootstrap, python-pip,
python-pypa-build, python-pytest-bootstrap, python-tomli,
python-typing-extensions, python-typeguard, and python-wheel.
Change-Id: I2361b2626e7c0ca54fad7e9eeb0a616b2b66f6d9
Modified-by: Sharlatan Hellseher <sharlatanus@gmail.com>
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
Diffstat (limited to 'gnu/packages/python-build.scm')
| -rw-r--r-- | gnu/packages/python-build.scm | 137 |
1 files changed, 121 insertions, 16 deletions
diff --git a/gnu/packages/python-build.scm b/gnu/packages/python-build.scm index 73435623c70..f75b6758f3a 100644 --- a/gnu/packages/python-build.scm +++ b/gnu/packages/python-build.scm | |||
| @@ -248,7 +248,7 @@ invoked on those path objects directly.") | |||
| 248 | (arguments (list #:test-backend #~'unittest)) | 248 | (arguments (list #:test-backend #~'unittest)) |
| 249 | (native-inputs | 249 | (native-inputs |
| 250 | (list python-flit-core | 250 | (list python-flit-core |
| 251 | python-setuptools)) | 251 | python-setuptools-bootstrap)) |
| 252 | (home-page "https://github.com/cpburnz/python-pathspec") | 252 | (home-page "https://github.com/cpburnz/python-pathspec") |
| 253 | (synopsis "Utility library for gitignore style pattern matching of file paths") | 253 | (synopsis "Utility library for gitignore style pattern matching of file paths") |
| 254 | (description | 254 | (description |
| @@ -295,7 +295,7 @@ platform-specific directories, e.g. the ``user data dir''.") | |||
| 295 | (base32 "1wr2vnbb7gy9wlz01yvb7rn4iqzd3mwmidk11ywk7395fq5i7k3x")))) | 295 | (base32 "1wr2vnbb7gy9wlz01yvb7rn4iqzd3mwmidk11ywk7395fq5i7k3x")))) |
| 296 | (build-system pyproject-build-system) | 296 | (build-system pyproject-build-system) |
| 297 | (native-inputs | 297 | (native-inputs |
| 298 | (list python-setuptools | 298 | (list python-setuptools-bootstrap |
| 299 | python-setuptools-scm | 299 | python-setuptools-scm |
| 300 | python-wheel)) | 300 | python-wheel)) |
| 301 | (home-page "https://pypi.org/project/pluggy/") | 301 | (home-page "https://pypi.org/project/pluggy/") |
| @@ -345,7 +345,7 @@ tools for mocking system commands and recording calls to those.") | |||
| 345 | (arguments | 345 | (arguments |
| 346 | `(#:tests? #f)) ;no tests suite in release | 346 | `(#:tests? #f)) ;no tests suite in release |
| 347 | (native-inputs | 347 | (native-inputs |
| 348 | (list python-setuptools)) | 348 | (list python-setuptools-bootstrap)) |
| 349 | (home-page "https://github.com/uiri/toml") | 349 | (home-page "https://github.com/uiri/toml") |
| 350 | (synopsis "Library for TOML") | 350 | (synopsis "Library for TOML") |
| 351 | (description | 351 | (description |
| @@ -501,7 +501,7 @@ and many external plugins.") | |||
| 501 | (arguments | 501 | (arguments |
| 502 | (list #:build-backend "setuptools.build_meta" | 502 | (list #:build-backend "setuptools.build_meta" |
| 503 | #:tests? #f)) ;keep dependencies to a minimum | 503 | #:tests? #f)) ;keep dependencies to a minimum |
| 504 | (native-inputs (list python-setuptools python-wheel)) | 504 | (native-inputs (list python-setuptools-bootstrap)) |
| 505 | (home-page "https://github.com/pypa/trove-classifiers") | 505 | (home-page "https://github.com/pypa/trove-classifiers") |
| 506 | (synopsis "Canonical source for classifiers on PyPI") | 506 | (synopsis "Canonical source for classifiers on PyPI") |
| 507 | (description "This package is the canonical source for classifiers use on | 507 | (description "This package is the canonical source for classifiers use on |
| @@ -658,7 +658,7 @@ def contents() -> str: | |||
| 658 | (arguments | 658 | (arguments |
| 659 | '(#:tests? #f)) ; there are no tests in the pypi archive. | 659 | '(#:tests? #f)) ; there are no tests in the pypi archive. |
| 660 | (native-inputs | 660 | (native-inputs |
| 661 | (list python-setuptools)) | 661 | (list python-setuptools-bootstrap)) |
| 662 | (home-page "https://pip.pypa.io/") | 662 | (home-page "https://pip.pypa.io/") |
| 663 | (synopsis "Package manager for Python software") | 663 | (synopsis "Package manager for Python software") |
| 664 | (description | 664 | (description |
| @@ -669,6 +669,8 @@ Python Package Index (PyPI).") | |||
| 669 | (define-public python-setuptools | 669 | (define-public python-setuptools |
| 670 | (package | 670 | (package |
| 671 | (name "python-setuptools") | 671 | (name "python-setuptools") |
| 672 | ;; When updating python-setuptools, also check in the bundled sources | ||
| 673 | ;; the versions of some native-inputs if some new tests fail. | ||
| 672 | (version "80.9.0") | 674 | (version "80.9.0") |
| 673 | (source | 675 | (source |
| 674 | (origin | 676 | (origin |
| @@ -678,16 +680,119 @@ Python Package Index (PyPI).") | |||
| 678 | (base32 "175iixi2h2jz8y2bpwziak360hvv43jfhipwzbdniryd5r04fszk")) | 680 | (base32 "175iixi2h2jz8y2bpwziak360hvv43jfhipwzbdniryd5r04fszk")) |
| 679 | (modules '((guix build utils))) | 681 | (modules '((guix build utils))) |
| 680 | (snippet | 682 | (snippet |
| 681 | ;; TODO: setuptools now bundles the following libraries: | 683 | #~(begin |
| 682 | ;; packaging, pyparsing, six and appdirs. How to unbundle? | 684 | ;; Remove included binaries which are used to build self-extracting |
| 683 | ;; Remove included binaries which are used to build self-extracting | 685 | ;; installers for Windows. |
| 684 | ;; installers for Windows. | 686 | (for-each delete-file (find-files "setuptools" |
| 685 | '(for-each delete-file (find-files "setuptools" | 687 | "^(cli|gui).*\\.exe$")))))) |
| 686 | "^(cli|gui).*\\.exe$"))))) | ||
| 687 | (build-system pyproject-build-system) | 688 | (build-system pyproject-build-system) |
| 688 | ;; FIXME: Tests require pytest, which itself relies on setuptools. | 689 | (arguments |
| 689 | ;; One could bootstrap with an internal untested setuptools. | 690 | (list |
| 690 | (arguments (list #:tests? #f)) | 691 | #:test-flags |
| 692 | #~(list | ||
| 693 | ;; Avoid additional dependencies | ||
| 694 | "--ignore=setuptools/tests/config/test_apply_pyprojecttoml.py" | ||
| 695 | "--ignore=setuptools/tests/config/test_pyprojecttoml.py" | ||
| 696 | "--ignore=setuptools/tests/test_namespaces.py" ;nss-certs-for-test | ||
| 697 | "--ignore=tools" | ||
| 698 | ;; These tests try to access the network. | ||
| 699 | "-m" "not uses_network" | ||
| 700 | "-k" (string-join | ||
| 701 | (list "not test_dist_fetch_build_egg" ; network | ||
| 702 | ;; Those scripts are unbundled in the snippet above. | ||
| 703 | "test_wheel_includes_cli_scripts" | ||
| 704 | ;; Despite PRE_BUILT_SETUPTOOLS_WHEEL below, | ||
| 705 | ;; this test uses our unbundled setuptools and fails | ||
| 706 | ;; to find jaraco.functools. | ||
| 707 | "test_no_missing_dependencies" | ||
| 708 | ;; XXX: We have pytest in the path, probably | ||
| 709 | ;; because of the setenv "PYTHONPATH" below. | ||
| 710 | "test_ignore_errors" | ||
| 711 | ;; XXX: Unclear why this one fails. | ||
| 712 | "test_basic") | ||
| 713 | " and not ")) | ||
| 714 | #:phases | ||
| 715 | #~(modify-phases %standard-phases | ||
| 716 | ;; Build a first wheel bundled for tests. | ||
| 717 | (add-before 'build 'build-bundled-wheel-for-tests | ||
| 718 | (assoc-ref %standard-phases 'build)) | ||
| 719 | (add-after 'build-bundled-wheel-for-tests 'cleanup | ||
| 720 | (lambda _ | ||
| 721 | (let ((wheel (string-append "setuptools-" #$version | ||
| 722 | "-py3-none-any.whl"))) | ||
| 723 | (for-each | ||
| 724 | (lambda (file) | ||
| 725 | (rename-file file wheel)) | ||
| 726 | (find-files "dist" "\\.whl$"))) | ||
| 727 | (for-each delete-file-recursively | ||
| 728 | '("build" "dist" "setuptools/_vendor")))) ; unbundle | ||
| 729 | (add-before 'check 'configure-tests | ||
| 730 | (lambda* (#:key outputs #:allow-other-keys) | ||
| 731 | (setenv "HOME" (getcwd)) | ||
| 732 | ;; FIXME python-pytest still relies a bit on PYTHONPATH. | ||
| 733 | (setenv "PYTHONPATH" (getenv "GUIX_PYTHONPATH")) | ||
| 734 | ;; Inject our pre-built bundled wheel for tests. | ||
| 735 | (setenv "PRE_BUILT_SETUPTOOLS_WHEEL" | ||
| 736 | (string-append (getcwd) "/setuptools-" | ||
| 737 | #$version "-py3-none-any.whl")))) | ||
| 738 | ;; Platformdirs is a bit tedious to properly bootstrap and | ||
| 739 | ;; propagate, and is used in a single place that will be dropped | ||
| 740 | ;; soon, we might as well drop it now. | ||
| 741 | (add-before 'compile-bytecode 'drop-platformdirs-requirement | ||
| 742 | (lambda* (#:key inputs outputs #:allow-other-keys) | ||
| 743 | (with-directory-excursion (site-packages inputs outputs) | ||
| 744 | (substitute* "pkg_resources/__init__.py" | ||
| 745 | (("^from platformdirs import.*") | ||
| 746 | "") | ||
| 747 | (("_user_cache_dir\\(appname='Python-Eggs'\\)") | ||
| 748 | "f\"{os.environ.get('XDG_CACHE_HOME')}/Python-Eggs\"")) | ||
| 749 | (substitute* (string-append "setuptools-" #$version | ||
| 750 | ".dist-info/METADATA") | ||
| 751 | (("Requires-Dist: platformdirs.*") ""))))) | ||
| 752 | (add-after 'check 'cleanup-installed-tests | ||
| 753 | (lambda* (#:key inputs outputs #:allow-other-keys) | ||
| 754 | (let ((site (site-packages inputs outputs))) | ||
| 755 | (with-directory-excursion site | ||
| 756 | (for-each | ||
| 757 | delete-file-recursively | ||
| 758 | (find-files "." | ||
| 759 | (lambda (file stat) | ||
| 760 | (and (string= (basename file) "tests") | ||
| 761 | (eq? 'directory | ||
| 762 | (stat:type stat)))) | ||
| 763 | #:directories? #t))) | ||
| 764 | (substitute* (find-files site "RECORD") | ||
| 765 | ((".*/tests/.*") "")))))))) | ||
| 766 | (propagated-inputs | ||
| 767 | ;; See either bundled inputs or METADATA extra == "core" | ||
| 768 | (list python-jaraco-functools | ||
| 769 | python-jaraco-text | ||
| 770 | python-more-itertools | ||
| 771 | python-packaging | ||
| 772 | python-wheel)) | ||
| 773 | (native-inputs | ||
| 774 | (list python-autocommand | ||
| 775 | python-backports-tarfile | ||
| 776 | python-filelock-bootstrap | ||
| 777 | python-inflect | ||
| 778 | python-jaraco-collections | ||
| 779 | python-jaraco-context | ||
| 780 | python-jaraco-envs-bootstrap | ||
| 781 | python-jaraco-functools | ||
| 782 | python-jaraco-path | ||
| 783 | python-jaraco-test | ||
| 784 | python-jaraco-text | ||
| 785 | python-more-itertools | ||
| 786 | python-packaging | ||
| 787 | python-path | ||
| 788 | python-platformdirs-bootstrap | ||
| 789 | python-pip | ||
| 790 | python-pypa-build | ||
| 791 | python-pytest-bootstrap | ||
| 792 | python-tomli | ||
| 793 | python-typing-extensions | ||
| 794 | python-typeguard | ||
| 795 | python-wheel)) | ||
| 691 | (home-page "https://pypi.org/project/setuptools/") | 796 | (home-page "https://pypi.org/project/setuptools/") |
| 692 | (synopsis "Library designed to facilitate packaging Python projects") | 797 | (synopsis "Library designed to facilitate packaging Python projects") |
| 693 | (description "Setuptools is a fully-featured, stable library designed to | 798 | (description "Setuptools is a fully-featured, stable library designed to |
| @@ -1186,7 +1291,7 @@ system, then @code{flit_core} to build the package.") | |||
| 1186 | #:build-backend "setuptools.build_meta")) | 1291 | #:build-backend "setuptools.build_meta")) |
| 1187 | (propagated-inputs | 1292 | (propagated-inputs |
| 1188 | (list python-packaging-bootstrap | 1293 | (list python-packaging-bootstrap |
| 1189 | python-setuptools)) | 1294 | python-setuptools-bootstrap)) |
| 1190 | (home-page "https://github.com/pypa/setuptools_scm/") | 1295 | (home-page "https://github.com/pypa/setuptools_scm/") |
| 1191 | (synopsis "Manage Python package versions in SCM metadata") | 1296 | (synopsis "Manage Python package versions in SCM metadata") |
| 1192 | (description | 1297 | (description |
| @@ -1235,7 +1340,7 @@ them as the version argument or in a SCM managed file.") | |||
| 1235 | (build-system pyproject-build-system) | 1340 | (build-system pyproject-build-system) |
| 1236 | (native-inputs | 1341 | (native-inputs |
| 1237 | (list python-pytest-bootstrap | 1342 | (list python-pytest-bootstrap |
| 1238 | python-setuptools)) | 1343 | python-setuptools-bootstrap)) |
| 1239 | (home-page "https://pypi.org/project/six/") | 1344 | (home-page "https://pypi.org/project/six/") |
| 1240 | (synopsis "Python 2 and 3 compatibility utilities") | 1345 | (synopsis "Python 2 and 3 compatibility utilities") |
| 1241 | (description | 1346 | (description |
