Message ID | 20240425160010.6243-1-ngraves@ngraves.fr |
---|---|
State | New |
Headers | show |
Series | Python: Ignore unwanted development inputs. | expand |
Hi, > +(define pypi-ignored-inputs > + ;; This list contains packages that are useful for development or quality > + ;; testing, but that most of the time are not necessary to have as an input. > + (list "argparse" ; native > + "codecov" "coverage" ; coverage > + "black" "isort" "pycodestyle" "pep8" ; style > + "pyflakes" "flake8" "pylint" "mypy" ; style+lint > + "coveralls" "twine" ; upload integration tools > + "pytest-isort" "pytest-flake8" "pytest-cov" "pytest-black" > + "pytest-pep8" "pytest-mypy" "pytest-pep8" "pre-commit")) ; variants > + (let ((input-names (append > + '("python-setuptools" > + "python-pip" > + "python-pre-commit") > + pypi-ignored-inputs))) we should remove python-setuptools from this list now (since it actually should be an input on the python-team branch), python-pre-commit is also part of pypi-ignored-inputs and maybe we can just add pip to pypi-ignored-inputs and use only that list? Also note that check-inputs-should-not-be-an-input-at-all expects Guix package names (with python- prefix), whereas pypi-ignored-inputs uses Python package names, so you probably want to (map (cut (string-append "python-" <>) …) (or similar) here. Lars
On 2024-04-26 10:26, Lars-Dominik Braun wrote: > Hi, > >> +(define pypi-ignored-inputs >> + ;; This list contains packages that are useful for development or quality >> + ;; testing, but that most of the time are not necessary to have as an input. >> + (list "argparse" ; native >> + "codecov" "coverage" ; coverage >> + "black" "isort" "pycodestyle" "pep8" ; style >> + "pyflakes" "flake8" "pylint" "mypy" ; style+lint >> + "coveralls" "twine" ; upload integration tools >> + "pytest-isort" "pytest-flake8" "pytest-cov" "pytest-black" >> + "pytest-pep8" "pytest-mypy" "pytest-pep8" "pre-commit")) ; variants > >> + (let ((input-names (append >> + '("python-setuptools" >> + "python-pip" >> + "python-pre-commit") >> + pypi-ignored-inputs))) > > we should remove python-setuptools from this list now (since it actually > should be an input on the python-team branch), python-pre-commit is > also part of pypi-ignored-inputs and maybe we can just add pip to > pypi-ignored-inputs and use only that list? Yes, but then it should be done in an independent commit IMO to keep this one focused on native-inputs and pytest, and then add one for your other changes of the build system. But yes, I think they ought to be in the same list. > > Also note that check-inputs-should-not-be-an-input-at-all expects Guix > package names (with python- prefix), whereas pypi-ignored-inputs uses > Python package names, so you probably want to (map (cut (string-append > "python-" <>) …) (or similar) here. Perfectly right, thanks for noticing. About pre-commit : if we add the python- prefix, then we use the outdated variable. Maybe we should remove if pypi-ignored-inputs here, and add "pre-commit" idependently. > Lars > Another quick note : The plugin could also be several plugins (one per package) in the store added in the PYTHONPATH, which would enable us to not regenerate the file everytime, but it doesn't compile with (guix gexp) module. It might be more efficient / guixy this way, but I'm not able to do it. If you know how to, don't hesitate ;)
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm index 6719fde330..a43d4eca1d 100644 --- a/guix/import/pypi.scm +++ b/guix/import/pypi.scm @@ -14,6 +14,7 @@ ;;; Copyright © 2022 Vivien Kraus <vivien@planete-kraus.eu> ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com> ;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com> +;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr> ;;; ;;; This file is part of GNU Guix. ;;; @@ -61,6 +62,7 @@ (define-module (guix import pypi) #:use-module (guix upstream) #:use-module ((guix licenses) #:prefix license:) #:export (%pypi-base-url + pypi-ignored-inputs parse-requires.txt parse-wheel-metadata specification->requirement-name @@ -77,6 +79,17 @@ (define %pypi-base-url ;; Base URL of the PyPI API. (make-parameter "https://pypi.org/pypi/")) +(define pypi-ignored-inputs + ;; This list contains packages that are useful for development or quality + ;; testing, but that most of the time are not necessary to have as an input. + (list "argparse" ; native + "codecov" "coverage" ; coverage + "black" "isort" "pycodestyle" "pep8" ; style + "pyflakes" "flake8" "pylint" "mypy" ; style+lint + "coveralls" "twine" ; upload integration tools + "pytest-isort" "pytest-flake8" "pytest-cov" "pytest-black" + "pytest-pep8" "pytest-mypy" "pytest-pep8" "pre-commit")) ; variants + (define non-empty-string-or-false (match-lambda ("" #f) @@ -424,9 +437,10 @@ (define (compute-inputs source-url wheel-url archive) "Given the SOURCE-URL and WHEEL-URL of an already downloaded ARCHIVE, return the corresponding list of <upstream-input> records." (define (requirements->upstream-inputs deps type) - (filter-map (match-lambda - ("argparse" #f) - (name (upstream-input + (filter-map (lambda (name) + (if (member name pypi-ignored-inputs) + #f + (upstream-input (name name) (downstream-name (python->package-name name)) (type type)))) diff --git a/guix/lint.scm b/guix/lint.scm index 68d532968d..9867b71cfd 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -71,6 +71,7 @@ (define-module (guix lint) hg-reference-url) #:autoload (guix bzr-download) (bzr-reference? bzr-reference-url) + #:use-module ((guix import pypi) #:select (pypi-ignored-inputs)) #:use-module (guix import stackage) #:use-module (ice-9 match) #:use-module (ice-9 regex) @@ -557,14 +558,12 @@ (define (check-inputs-should-be-native package) "m4" "qttools-5" "yasm" "nasm" "fasm" - "python-coverage" "python-cython" "python-docutils" "python-mock" "python-nose" "python-pbr" "python-pytest" - "python-pytest-cov" "python-setuptools-scm" "python-sphinx" "scdoc" @@ -586,9 +585,11 @@ (define (check-inputs-should-be-native package) (define (check-inputs-should-not-be-an-input-at-all package) ;; Emit a warning if some inputs of PACKAGE are likely to should not be ;; an input at all. - (let ((input-names '("python-setuptools" - "python-pip" - "python-pre-commit"))) + (let ((input-names (append + '("python-setuptools" + "python-pip" + "python-pre-commit") + pypi-ignored-inputs))) (map (lambda (input) (make-warning package diff --git a/tests/pypi.scm b/tests/pypi.scm index 42b39cde73..fe01ab3beb 100644 --- a/tests/pypi.scm +++ b/tests/pypi.scm @@ -97,6 +97,7 @@ (define test-requires.txt "\ [test] pytest (>=2.5.0) +pytest-cov # read but ignored ") ;; Beaker contains only optional dependencies. @@ -244,7 +245,7 @@ (define-syntax-rule (with-pypi responses body ...) (map specification->requirement-name test-specifications)) (test-equal "parse-requires.txt" - (list '("foo" "bar") '("pytest")) + (list '("foo" "bar") '("pytest" "pytest-cov")) (mock ((ice-9 ports) call-with-input-file call-with-input-string) (parse-requires.txt test-requires.txt)))