Archived
1
0
Fork 0

gnu: python-black: Update to 21.12b0.

* gnu/packages/python-xyz.scm (python-black)[arguments]: Adjust file name
patching to cover more files.  Override check phase.
[propagated-inputs]: Add PYTHON-PLATFORMDIRS and PYTHON-TOMLI.  Remove
PYTHON-TOML.
[native-inputs]: Add PYTHON-PYTEST-AIOHTTP.
[home-page]: Update to current.
This commit is contained in:
Marius Bakke 2022-01-12 18:19:00 +01:00
parent 463b4d7bef
commit c2a4cb24ed
No known key found for this signature in database
GPG key ID: A2A06DF2A33A54FA

View file

@ -5211,74 +5211,68 @@ matching of file paths.")
(define-public python-black (define-public python-black
(package (package
(name "python-black") (name "python-black")
(version "20.8b1") (version "21.12b0")
(source (source
(origin (origin
(method url-fetch) (method url-fetch)
(uri (pypi-uri "black" version)) (uri (pypi-uri "black" version))
(sha256 (sha256
(base32 (base32
"1spv6sldp3mcxr740dh3ywp25lly9s8qlvs946fin44rl1x5a0hw")))) "1czjwr1bx9ax5l64xfi54sxb1ycdy4s9ciaqg592x7jn79lhzf3p"))))
(build-system python-build-system) (build-system python-build-system)
(arguments (arguments
`(#:phases `(#:phases
(modify-phases %standard-phases (modify-phases %standard-phases
(add-after 'patch-source-shebangs 'patch-extra-shebangs (add-after 'patch-source-shebangs 'use-absolute-file-names
(lambda _ (lambda* (#:key native-inputs inputs #:allow-other-keys)
(let ((python3 (which "python3"))) (let* ((inpts (or native-inputs inputs))
(substitute* '("tests/data/fmtonoff.py" (python3 (search-input-file inpts "/bin/python3"))
"tests/data/string_prefixes.py" (/bin/false (search-input-file inpts "/bin/false"))
"tests/data/function.py" (/bin/sleep (search-input-file inpts "/bin/sleep")))
"tests/data/python37.py") (substitute* (find-files "tests" "\\.py$")
(("#!/usr/bin/env python3(\\.[0-9]+)?" _ minor-version) (("#!/usr/bin/env python3(\\.[0-9]+)?" _ minor-version)
(string-append "#!" python3 (if (string? minor-version) (string-append "#!" python3 (if (string? minor-version)
minor-version minor-version
""))))) ""))))
#t)) (substitute* "tests/test_primer.py"
(("/bin/false") /bin/false)
(("/bin/sleep") /bin/sleep)))))
(add-after 'unpack 'disable-broken-tests (add-after 'unpack 'disable-broken-tests
(lambda* (#:key outputs inputs #:allow-other-keys) (lambda* (#:key outputs inputs #:allow-other-keys)
;; Make installed package available for running the tests ;; Make installed package available for running the tests
(setenv "PATH" (string-append (assoc-ref outputs "out") "/bin" (setenv "PATH" (string-append (assoc-ref outputs "out") "/bin"
":" (getenv "PATH"))) ":" (getenv "PATH")))
;; These tests are supposed to be skipped when the blackd ;; The source formatting test fails because we patch various
;; dependencies are missing, but this doesn't quite work. ;; files; just disable it.
(substitute* "tests/test_black.py" (substitute* "tests/test_format.py"
(("( *)class BlackDTestCase.*" match indent) (("def test_source_is_formatted" all)
(string-append indent "@unittest.skip(\"no blackd deps\")\n" (format #f "@pytest.mark.skip(\"Disabled by Guix.\")\n~a"
indent "class BlackDTestCase(unittest.TestCase):\n")) all)))))
(("web.Application") "False")
(("@unittest_run_loop") ""))
;; Patching the above file breaks the self test
(substitute* "tests/test_black.py"
(("( *)def test_self" match indent)
(string-append indent "@unittest.skip(\"guix\")\n" match)))
(substitute* "tests/test_black.py"
(("( *)def test_python38" match indent)
(string-append indent "@unittest.skip(\"guix\")\n" match)))
#t))
;; Remove blackd, because it depends on python-aiohttp and ;; Remove blackd, because it depends on python-aiohttp and
;; python-aiohttp-cors. ;; python-aiohttp-cors.
(add-after 'unpack 'remove-entrypoint (add-after 'unpack 'remove-entrypoint
(lambda _ (lambda _
(substitute* "setup.py" (substitute* "setup.py"
(("\\s*\"blackd=blackd:patched_main \\[d\\]\",\n") "") (("\\s*\"blackd=blackd:patched_main \\[d\\]\",\n") "")
(("\"blackd\", ") ""))))))) (("\"blackd\", ") ""))))
(replace 'check
(lambda* (#:key tests? #:allow-other-keys)
(when tests? (invoke "pytest" "-vv")))))))
(propagated-inputs (propagated-inputs
(list python-click (list python-click
python-attrs python-attrs
python-appdirs python-appdirs
python-pathspec python-pathspec
python-mypy-extensions python-mypy-extensions
python-platformdirs
python-regex python-regex
python-toml python-tomli
python-typed-ast python-typed-ast
python-typing-extensions)) python-typing-extensions))
(native-inputs (native-inputs
(list python-setuptools-scm)) (list python-pytest python-pytest-aiohttp python-setuptools-scm))
(home-page "https://github.com/ambv/black") (home-page "https://github.com/psf/black")
(synopsis "The uncompromising code formatter") (synopsis "The uncompromising code formatter")
(description "Black is the uncompromising Python code formatter.") (description "Black is the uncompromising Python code formatter.")
(license license:expat))) (license license:expat)))