gnu: python-astropy: Improve packages style.

* gnu/packages/astronomy.scm (python-astropy): Adjust package style.
[arguments] <#:phases>: Simplify 'preparations, move step setting up
HOME env to 'prepare-test-environment phase.
Add 'prepare-test-environment phase, consolidating all pre test
procedures.
{check}: Add option to run test in parallel to accelerate them. Remove
from disabled list tests which were passed successfully.

Change-Id: I306ab60b6e155c81035de9584fbd9d06a6381045
This commit is contained in:
Sharlatan Hellseher 2024-01-27 13:08:21 +00:00
parent e8c1c87c34
commit 38b6670c7a
No known key found for this signature in database
GPG key ID: 76D727BFF62CD2B5

View file

@ -1499,14 +1499,13 @@ (define-public python-astropy
(for-each delete-file-recursively '("expat" "wcslib"))))))) (for-each delete-file-recursively '("expat" "wcslib")))))))
(build-system python-build-system) (build-system python-build-system)
(arguments (arguments
`(#:phases (list
(modify-phases %standard-phases #:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'preparations (add-after 'unpack 'preparations
(lambda _ (lambda _
;; Use our own libraries in place of bundles. ;; Use our own libraries in place of bundles.
(setenv "ASTROPY_USE_SYSTEM_ALL" "1") (setenv "ASTROPY_USE_SYSTEM_ALL" "1")
;; Some tests require a writable home.
(setenv "HOME" "/tmp")
;; Relax xfail tests. ;; Relax xfail tests.
(substitute* "pyproject.toml" (substitute* "pyproject.toml"
(("xfail_strict = true") "xfail_strict = false")) (("xfail_strict = true") "xfail_strict = false"))
@ -1514,29 +1513,36 @@ (define-public python-astropy
(substitute* "astropy/utils/parsing.py" (substitute* "astropy/utils/parsing.py"
(("astropy.extern.ply") "ply")) (("astropy.extern.ply") "ply"))
;; Replace reference to external configobj. ;; Replace reference to external configobj.
(with-directory-excursion "astropy/config" (substitute* "astropy/config/configuration.py"
(substitute* "configuration.py" (("from astropy.extern.configobj ") ""))))
(("from astropy.extern.configobj ") "")))))
;; This file is opened in both install and check phases. ;; This file is opened in both install and check phases.
(add-before 'install 'writable-compiler (add-before 'install 'writable-compiler
(lambda _ (make-file-writable "astropy/_compiler.c"))) (lambda _
(add-before 'check 'writable-compiler (make-file-writable "astropy/_compiler.c")))
(lambda _ (make-file-writable "astropy/_compiler.c"))) (add-before 'check 'prepare-test-environment
(replace 'check (lambda _
(lambda* (#:key inputs outputs tests? #:allow-other-keys) ;; Some tests require a writable home.
(when tests? (setenv "HOME" "/tmp")
(add-installed-pythonpath inputs outputs) (make-file-writable "astropy/_compiler.c")
;; Extensions have to be rebuilt before running the tests. ;; Extensions have to be rebuilt before running the tests.
(invoke "python" "setup.py" "build_ext" "--inplace") (invoke "python" "setup.py" "build_ext" "--inplace"
"-j" (number->string (parallel-job-count)))))
;; TODO: The swap to pyproject-build-system introduced all tests
;; failed due to pytest could not load conftest.py, find out how
;; to resolve it and migrate completely to pyproject-build-system.
(replace 'check
(lambda* (#:key tests? #:allow-other-keys)
(when tests?
(invoke "python" "-m" "pytest" "--pyargs" "astropy" (invoke "python" "-m" "pytest" "--pyargs" "astropy"
;; Skip tests that need remote data. ;; with -n : 133.00s
;; without -n : 326.14s
"-n" (number->string (parallel-job-count))
"-k" (string-append "-k" (string-append
;; Skip tests that need remote data.
"not remote_data" "not remote_data"
;; XXX: Check why this tests failing. ;; E astropy.samp.errors.SAMPProxyError:
" and not test_ignore_sigint" ;; <SAMPProxyError 1: 'Timeout expired!'>
" and not test_parquet_filter" " and not test_main"
;; See https://github.com/astropy/astropy/issues/15537
" and not test_pvstar"
;; E ModuleNotFoundError: No module named 'wofz' ;; E ModuleNotFoundError: No module named 'wofz'
" and not test_pickle_functional")))))))) " and not test_pickle_functional"))))))))
(native-inputs (native-inputs