diff options
| author | Nicolas Graves <ngraves@ngraves.fr> | 2026-03-24 01:42:00 +0100 |
|---|---|---|
| committer | Sharlatan Hellseher <sharlatanus@gmail.com> | 2026-05-24 10:14:42 +0100 |
| commit | 219b12a06a5f5b226973d0bb0f1f6779c8360fad (patch) | |
| tree | ebc8dc6a7d3e5ef724709676b98188401dc2a10e | |
| parent | 9fef6ccead1de98cc6bdf6354f53820076af7851 (diff) | |
tests: builders: Switch to pyproject-build-system.
* guix/build/pyproject-build-system.scm (set-version): Ensure source
is not #f before using it.
* tests/builders.scm
(make-python-dummy)[build-system]: Switch to pyproject-build-system.
[native-inputs]: Add python-setuptools.
(python-dummy-no-setuptools): Drop it.
(check-build-success, check-build-failure): Refresh tests.
(check-build-failure): Drop python-dummy-no-setuptools.
Change-Id: I892b45c34b506ff27634e2ef706009dc81e831ec
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
| -rw-r--r-- | guix/build/pyproject-build-system.scm | 5 | ||||
| -rw-r--r-- | tests/builders.scm | 31 |
2 files changed, 14 insertions, 22 deletions
diff --git a/guix/build/pyproject-build-system.scm b/guix/build/pyproject-build-system.scm index 641c3967960..f611afada24 100644 --- a/guix/build/pyproject-build-system.scm +++ b/guix/build/pyproject-build-system.scm | |||
| @@ -157,7 +157,7 @@ by Cython." | |||
| 157 | (format #t "Possible Cythonized file found: ~a~%" generated-file)))) | 157 | (format #t "Possible Cythonized file found: ~a~%" generated-file)))) |
| 158 | (find-files "." "\\.pyx$"))) | 158 | (find-files "." "\\.pyx$"))) |
| 159 | 159 | ||
| 160 | (define* (set-version #:key name inputs #:allow-other-keys) | 160 | (define* (set-version #:key name source inputs #:allow-other-keys) |
| 161 | "Provide the package version to Python build backend | 161 | "Provide the package version to Python build backend |
| 162 | that expects it to be derived from the version control information | 162 | that expects it to be derived from the version control information |
| 163 | that is not present in the source." | 163 | that is not present in the source." |
| @@ -182,7 +182,8 @@ that is not present in the source." | |||
| 182 | "python-setuptools-scm-bootstrap" | 182 | "python-setuptools-scm-bootstrap" |
| 183 | "python-versioneer")))) | 183 | "python-versioneer")))) |
| 184 | ;; Both git and hg use -checkout suffixes. | 184 | ;; Both git and hg use -checkout suffixes. |
| 185 | (version (and (string-suffix? "-checkout" (assoc-ref inputs "source")) | 185 | (version (and source |
| 186 | (string-suffix? "-checkout" source) | ||
| 186 | (public-version-identifier name)))) | 187 | (public-version-identifier name)))) |
| 187 | (cond ((null? version-backends) | 188 | (cond ((null? version-backends) |
| 188 | (format #t "Detected no Python build backend that expects") | 189 | (format #t "Detected no Python build backend that expects") |
diff --git a/tests/builders.scm b/tests/builders.scm index 44add1d13ea..7e89723bfff 100644 --- a/tests/builders.scm +++ b/tests/builders.scm | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | #:use-module (guix build-system gnu) | 25 | #:use-module (guix build-system gnu) |
| 26 | #:use-module (guix build gnu-build-system) | 26 | #:use-module (guix build gnu-build-system) |
| 27 | #:use-module (guix build utils) | 27 | #:use-module (guix build utils) |
| 28 | #:use-module (guix build-system python) | 28 | #:use-module (guix build-system pyproject) |
| 29 | #:use-module (guix store) | 29 | #:use-module (guix store) |
| 30 | #:use-module (guix monads) | 30 | #:use-module (guix monads) |
| 31 | #:use-module (guix utils) | 31 | #:use-module (guix utils) |
| @@ -37,6 +37,7 @@ | |||
| 37 | #:use-module (guix tests git) | 37 | #:use-module (guix tests git) |
| 38 | #:use-module (guix packages) | 38 | #:use-module (guix packages) |
| 39 | #:use-module (gnu packages bootstrap) | 39 | #:use-module (gnu packages bootstrap) |
| 40 | #:use-module (gnu packages python-build) | ||
| 40 | #:use-module ((ice-9 ftw) #:select (scandir)) | 41 | #:use-module ((ice-9 ftw) #:select (scandir)) |
| 41 | #:use-module (ice-9 match) | 42 | #:use-module (ice-9 match) |
| 42 | #:use-module (ice-9 textual-ports) | 43 | #:use-module (ice-9 textual-ports) |
| @@ -148,17 +149,16 @@ | |||
| 148 | 149 | ||
| 149 | 150 | ||
| 150 | ;;; | 151 | ;;; |
| 151 | ;;; Test the sanity-check phase of the Python build system. | 152 | ;;; Test the sanity-check phase of the Pyproject build system. |
| 152 | ;;; | 153 | ;;; |
| 153 | 154 | ||
| 154 | (define* (make-python-dummy name #:key (setup-py-extra "") | 155 | (define* (make-python-dummy name #:key (setup-py-extra "") |
| 155 | (init-py "") (use-setuptools? #t)) | 156 | (init-py "")) |
| 156 | (dummy-package (string-append "python-dummy-" name) | 157 | (dummy-package (string-append "python-dummy-" name) |
| 157 | (version "0.1") | 158 | (version "0.1") |
| 158 | (build-system python-build-system) | 159 | (build-system pyproject-build-system) |
| 159 | (arguments | 160 | (arguments |
| 160 | `(#:tests? #f | 161 | `(#:tests? #f |
| 161 | #:use-setuptools? ,use-setuptools? | ||
| 162 | #:phases | 162 | #:phases |
| 163 | (modify-phases %standard-phases | 163 | (modify-phases %standard-phases |
| 164 | (replace 'unpack | 164 | (replace 'unpack |
| @@ -170,27 +170,19 @@ | |||
| 170 | (with-output-to-file "setup.py" | 170 | (with-output-to-file "setup.py" |
| 171 | (lambda _ | 171 | (lambda _ |
| 172 | (format #t "\ | 172 | (format #t "\ |
| 173 | ~a | 173 | from setuptools import setup |
| 174 | setup( | 174 | setup( |
| 175 | name='dummy-~a', | 175 | name='dummy-~a', |
| 176 | version='0.1', | 176 | version='0.1', |
| 177 | packages=['dummy'], | 177 | packages=['dummy'], |
| 178 | ~a | 178 | ~a |
| 179 | )" | 179 | )" |
| 180 | (if ,use-setuptools? | 180 | ,name ,setup-py-extra)))))))) |
| 181 | "from setuptools import setup" | 181 | (native-inputs (list python-setuptools)))) |
| 182 | "from distutils.core import setup") | ||
| 183 | ,name ,setup-py-extra)))))))))) | ||
| 184 | 182 | ||
| 185 | (define python-dummy-ok | 183 | (define python-dummy-ok |
| 186 | (make-python-dummy "ok")) | 184 | (make-python-dummy "ok")) |
| 187 | 185 | ||
| 188 | ;; distutil won't install any metadata, so make sure our script does not fail | ||
| 189 | ;; on a otherwise fine package. | ||
| 190 | (define python-dummy-no-setuptools | ||
| 191 | (make-python-dummy | ||
| 192 | "no-setuptools" #:use-setuptools? #f)) | ||
| 193 | |||
| 194 | (define python-dummy-fail-requirements | 186 | (define python-dummy-fail-requirements |
| 195 | (make-python-dummy "fail-requirements" | 187 | (make-python-dummy "fail-requirements" |
| 196 | #:setup-py-extra "install_requires=['nonexistent'],")) | 188 | #:setup-py-extra "install_requires=['nonexistent'],")) |
| @@ -205,13 +197,13 @@ setup( | |||
| 205 | 197 | ||
| 206 | (define (check-build-success store p) | 198 | (define (check-build-success store p) |
| 207 | (unless store (test-skip 1)) | 199 | (unless store (test-skip 1)) |
| 208 | (test-assert (string-append "python-build-system: " (package-name p)) | 200 | (test-assert (string-append "pyproject-build-system: " (package-name p)) |
| 209 | (let* ((drv (package-derivation store p))) | 201 | (let* ((drv (package-derivation store p))) |
| 210 | (build-derivations store (list drv))))) | 202 | (build-derivations store (list drv))))) |
| 211 | 203 | ||
| 212 | (define (check-build-failure store p) | 204 | (define (check-build-failure store p) |
| 213 | (unless store (test-skip 1)) | 205 | (unless store (test-skip 1)) |
| 214 | (test-assert (string-append "python-build-system: " (package-name p)) | 206 | (test-assert (string-append "pyproject-build-system: " (package-name p)) |
| 215 | (let ((drv (package-derivation store p))) | 207 | (let ((drv (package-derivation store p))) |
| 216 | (guard (c ((store-protocol-error? c) | 208 | (guard (c ((store-protocol-error? c) |
| 217 | (pk 'failure c #t))) ;good! | 209 | (pk 'failure c #t))) ;good! |
| @@ -221,8 +213,7 @@ setup( | |||
| 221 | (with-external-store store | 213 | (with-external-store store |
| 222 | (for-each (lambda (p) (check-build-success store p)) | 214 | (for-each (lambda (p) (check-build-success store p)) |
| 223 | (list | 215 | (list |
| 224 | python-dummy-ok | 216 | python-dummy-ok)) |
| 225 | python-dummy-no-setuptools)) | ||
| 226 | (for-each (lambda (p) (check-build-failure store p)) | 217 | (for-each (lambda (p) (check-build-failure store p)) |
| 227 | (list | 218 | (list |
| 228 | python-dummy-fail-requirements | 219 | python-dummy-fail-requirements |
