import: pypi: Ignore pypi-ignored-inputs.

* guix/import/pypi.scm (pypi-ignored-inputs): New variable.
  (compute-inputs): Use it.

* tests/pypi.scm (parse-requires.txt): Add ignored input to test the
  feature.

* guix/lint.scm (check-inputs-should-be-native): Adapt list.
  (check-inputs-should-not-be-an-input-at-all): Use pypi-ignored-list.

Change-Id: I297793b71f9ffdfbe7cc4e883777f8823941adf0
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
Nicolas Graves 2024-06-01 17:36:33 +02:00 committed by Andreas Enge
parent b325e29e52
commit 0f4cebcecf
No known key found for this signature in database
GPG key ID: F7D5C9BF765C61E3
3 changed files with 30 additions and 13 deletions

View file

@ -14,6 +14,7 @@
;;; Copyright © 2022 Vivien Kraus <vivien@planete-kraus.eu> ;;; Copyright © 2022 Vivien Kraus <vivien@planete-kraus.eu>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com> ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com> ;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -68,6 +69,7 @@
#:use-module (guix upstream) #:use-module (guix upstream)
#:use-module ((guix licenses) #:prefix license:) #:use-module ((guix licenses) #:prefix license:)
#:export (%pypi-base-url #:export (%pypi-base-url
pypi-ignored-inputs
parse-requires.txt parse-requires.txt
parse-wheel-metadata parse-wheel-metadata
specification->requirement-name specification->requirement-name
@ -84,6 +86,18 @@
;; Base URL of the PyPI API. ;; Base URL of the PyPI API.
(make-parameter "https://pypi.org/pypi/")) (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" "wheel" ; native
"tox" ; test wrapper for other environments
"codecov" "coverage" ; coverage
"black" "isort" "pycodestyle" "pep8" ; style
"check-manifest" "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 (define non-empty-string-or-false
(match-lambda (match-lambda
("" #f) ("" #f)
@ -499,12 +513,12 @@ cannot determine package dependencies from source archive: ~a~%")
"Given the SOURCE-URL and WHEEL-URL of an already downloaded ARCHIVE, return "Given the SOURCE-URL and WHEEL-URL of an already downloaded ARCHIVE, return
the corresponding list of <upstream-input> records." the corresponding list of <upstream-input> records."
(define (requirements->upstream-inputs deps type) (define (requirements->upstream-inputs deps type)
(filter-map (match-lambda (filter-map (lambda (name)
("argparse" #f) (and (not (member name pypi-ignored-inputs))
(name (upstream-input (upstream-input
(name name) (name name)
(downstream-name (python->package-name name)) (downstream-name (python->package-name name))
(type type)))) (type type))))
(sort deps string-ci<?))) (sort deps string-ci<?)))
(define (add-missing-native-inputs inputs) (define (add-missing-native-inputs inputs)

View file

@ -73,6 +73,7 @@
hg-reference-url) hg-reference-url)
#:autoload (guix bzr-download) (bzr-reference? #:autoload (guix bzr-download) (bzr-reference?
bzr-reference-url) bzr-reference-url)
#:use-module ((guix import pypi) #:select (pypi-ignored-inputs))
#:use-module (guix import stackage) #:use-module (guix import stackage)
#:use-module (ice-9 match) #:use-module (ice-9 match)
#:use-module (ice-9 regex) #:use-module (ice-9 regex)
@ -602,14 +603,12 @@ of a package, and INPUT-NAMES, a list of package specifications such as
"m4" "m4"
"qttools-5" "qttools-5"
"yasm" "nasm" "fasm" "yasm" "nasm" "fasm"
"python-coverage"
"python-cython" "python-cython"
"python-docutils" "python-docutils"
"python-mock" "python-mock"
"python-nose" "python-nose"
"python-pbr" "python-pbr"
"python-pytest" "python-pytest"
"python-pytest-cov"
"python-setuptools-scm" "python-setuptools-scm"
"python-sphinx" "python-sphinx"
"scdoc" "scdoc"
@ -631,10 +630,13 @@ of a package, and INPUT-NAMES, a list of package specifications such as
(define (check-inputs-should-not-be-an-input-at-all 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 ;; Emit a warning if some inputs of PACKAGE are likely to should not be
;; an input at all. ;; an input at all.
(let ((input-names '("python-pip" (let ((input-names (append
"python-pre-commit" '("python-pip"
"tzdata" "python-pre-commit"
"nss-certs"))) "tzdata"
"nss-certs")
(map (cut string-append "python-" <>)
pypi-ignored-inputs))))
(map (lambda (input) (map (lambda (input)
(make-warning (make-warning
package package

View file

@ -97,6 +97,7 @@ bar != 2
[test] [test]
pytest (>=2.5.0) pytest (>=2.5.0)
pytest-cov # read but ignored
") ")
;; Beaker contains only optional dependencies. ;; Beaker contains only optional dependencies.
@ -258,7 +259,7 @@ files specified by SPECS. Return its file name."
(map specification->requirement-name test-specifications)) (map specification->requirement-name test-specifications))
(test-equal "parse-requires.txt" (test-equal "parse-requires.txt"
(list '("foo" "bar") '("pytest")) (list '("foo" "bar") '("pytest" "pytest-cov"))
(mock ((ice-9 ports) call-with-input-file (mock ((ice-9 ports) call-with-input-file
call-with-input-string) call-with-input-string)
(parse-requires.txt test-requires.txt))) (parse-requires.txt test-requires.txt)))