gnu: python-xgboost: Fix build.

* gnu/packages/machine-learning.scm (python-xgboost)[build-system]: Use
pyproject-build-system.
[arguments]: Move test flags to #:test-flags; disable a few more tests, mostly
to account for a removed dataset; use G-expression; remove custom 'check phase.

Change-Id: I6841a8c159919df85acaa8558248a8775ec5be80
This commit is contained in:
Ricardo Wurmus 2024-01-24 17:36:06 +01:00
parent 2c5faa9ab8
commit c3353791a4
No known key found for this signature in database
GPG key ID: 197A5888235FACAC

View file

@ -3419,57 +3419,79 @@ (define-public python-xgboost
(inherit xgboost) (inherit xgboost)
(name "python-xgboost") (name "python-xgboost")
(source (package-source xgboost)) (source (package-source xgboost))
(build-system python-build-system) (build-system pyproject-build-system)
(arguments (arguments
`(#:phases (list
(modify-phases %standard-phases #:test-flags
(add-after 'unpack 'preparations '(list "tests/python"
(lambda _ ;; FIXME: CLI tests fail with PermissionError.
;; Move python-package content to parent directory to silence "--ignore" "tests/python/test_cli.py"
;; some warnings about files not being found if we chdir. "-k"
(rename-file "python-package/xgboost" "xgboost") (string-append
(rename-file "python-package/README.rst" "README.rst") "not test_cli_regression_demo"
(rename-file "python-package/setup.cfg" "setup.cfg") ;; These tests use the Boston dataset that has been
(rename-file "python-package/setup.py" "setup.py") ;; removed from scipy.
;; Skip rebuilding libxgboost.so. " and not test_sklearn_demo"
(substitute* "setup.py" " and not test_sklearn_parallel_demo"
(("ext_modules=\\[CMakeExtension\\('libxgboost'\\)\\],") "") " and not test_predict_shape"
(("'install_lib': InstallLib,") "")))) " and not test_num_parallel_tree"
(add-after 'install 'install-version-and-libxgboost " and not test_boston_housing_regression"
(lambda* (#:key inputs outputs #:allow-other-keys) " and not test_boston_housing_rf_regression"
(let* ((out (assoc-ref outputs "out")) " and not test_parameter_tuning"
(pylib (string-append out "/lib/python" " and not test_regression_with_custom_objective"
,(version-major+minor " and not test_RFECV"
(package-version python)) ;; Pandas incompatibility? Says:
"/site-packages")) ;; '_CalibratedClassifier' object has no attribute
(xgbdir (string-append pylib "/xgboost")) ;; 'base_estimator'
(version-file (string-append xgbdir "/VERSION")) " and not test_pandas_input"
(libxgboost (string-append (assoc-ref inputs "xgboost") ;; Accuracy problems?
"/lib/libxgboost.so"))) " and not test_exact"
(with-output-to-file version-file " and not test_approx"
(lambda () " and not test_hist"
(display ,(package-version xgboost)))) ;; The tests below open a network connection.
(mkdir-p (string-append xgbdir "/lib")) " and not test_model_compatibility"
(symlink libxgboost (string-append xgbdir "/lib" " and not test_get_group"
"/libxgboost.so"))))) " and not test_cv_no_shuffle"
(replace 'check " and not test_cv"
;; Python-specific tests are located in tests/python. " and not test_training"
(lambda* (#:key inputs outputs tests? #:allow-other-keys) ;; "'['./runexp.sh']' returned non-zero exit status 1"
(when tests? " and not test_cli_binary_classification"))
(add-installed-pythonpath inputs outputs) #:phases
(invoke "pytest" "tests/python" #~(modify-phases %standard-phases
;; FIXME: CLI tests fail with PermissionError. (add-after 'unpack 'preparations
"--ignore" "tests/python/test_cli.py" "-k" (lambda _
(string-append ;; Move python-package content to parent directory to silence
"not test_cli_regression_demo" ;; some warnings about files not being found if we chdir.
;; The tests below open a network connection. (rename-file "python-package/xgboost" "xgboost")
" and not test_model_compatibility" (rename-file "python-package/README.rst" "README.rst")
" and not test_get_group" (rename-file "python-package/setup.cfg" "setup.cfg")
" and not test_cv_no_shuffle" (rename-file "python-package/setup.py" "setup.py")
" and not test_cv" ;; Skip rebuilding libxgboost.so.
" and not test_training" (substitute* "setup.py"
;; "'['./runexp.sh']' returned non-zero exit status 1" (("ext_modules=\\[CMakeExtension\\('libxgboost'\\)\\],") "")
" and not test_cli_binary_classification")))))))) (("'install_lib': InstallLib,") ""))
;; Remove bad dataset. This has been removed in scipy.
(substitute* "tests/python/testing.py"
(("TestDataset\\('boston', get_boston, 'reg:squarederror', 'rmse'\\),")
"")
(("datasets.load_boston")
"datasets.load_digits"))))
(add-after 'install 'install-version-and-libxgboost
(lambda* (#:key inputs #:allow-other-keys)
(let* ((pylib (string-append #$output "/lib/python"
#$(version-major+minor
(package-version python))
"/site-packages"))
(xgbdir (string-append pylib "/xgboost"))
(version-file (string-append xgbdir "/VERSION"))
(libxgboost (string-append (assoc-ref inputs "xgboost")
"/lib/libxgboost.so")))
(with-output-to-file version-file
(lambda ()
(display #$(package-version xgboost))))
(mkdir-p (string-append xgbdir "/lib"))
(symlink libxgboost (string-append xgbdir "/lib"
"/libxgboost.so"))))))))
(native-inputs (native-inputs
(list python-pandas python-pytest python-scikit-learn)) (list python-pandas python-pytest python-scikit-learn))
(inputs (inputs