gnu: khmer: Cythonize source files.

* gnu/packages/bioinformatics.scm (khmer)[source]: Remove generated files.
[arguments]: Add phase 'do-use-cython to patch the setup.py to generate cpp
files from Cython sources; add 'build-extensions phase; replace 'check phase.
This commit is contained in:
Ricardo Wurmus 2021-12-08 12:00:48 +01:00
parent 9a19e8f609
commit 298a8d0b89
No known key found for this signature in database
GPG key ID: 197A5888235FACAC

View file

@ -5082,7 +5082,9 @@ (define-public khmer
(("# libraries = z,bz2") (("# libraries = z,bz2")
"libraries = z,bz2") "libraries = z,bz2")
(("include:third-party/zlib:third-party/bzip2") (("include:third-party/zlib:third-party/bzip2")
"include:")))))) "include:"))
;; Delete generated Cython CPP files.
(for-each delete-file (find-files "khmer/_oxli/" "\\.cpp$"))))))
(build-system python-build-system) (build-system python-build-system)
(arguments (arguments
`(#:phases `(#:phases
@ -5095,13 +5097,24 @@ (define-public khmer
(substitute* "sandbox/sweep-reads.py" (substitute* "sandbox/sweep-reads.py"
(("time\\.clock") (("time\\.clock")
"time.process_time")))) "time.process_time"))))
(add-before 'reset-gzip-timestamps 'make-files-writable (add-after 'unpack 'do-use-cython
(lambda* (#:key outputs #:allow-other-keys) (lambda _
;; Make sure .gz files are writable so that the (substitute* "setup.py"
;; 'reset-gzip-timestamps' phase can do its work. (("from setuptools import Extension as CyExtension")
(let ((out (assoc-ref outputs "out"))) "from Cython.Distutils import Extension as CyExtension")
(for-each make-file-writable (("from setuptools.command.build_ext import build_ext as _build_ext")
(find-files out "\\.gz$")))))))) "from Cython.Distutils import build_ext as _build_ext")
(("HAS_CYTHON = False") "HAS_CYTHON = True")
(("cy_ext = 'cpp'") "cy_ext = 'pyx'"))))
(add-before 'build 'build-extensions
(lambda _
;; Cython extensions have to be built before running the tests.
(invoke "python" "setup.py" "build_ext" "--inplace")))
(replace 'check
(lambda* (#:key tests? inputs outputs #:allow-other-keys)
(when tests?
(add-installed-pythonpath inputs outputs)
(invoke "pytest" "-v")))))))
(native-inputs (native-inputs
`(("python-cython" ,python-cython) `(("python-cython" ,python-cython)
("python-pytest" ,python-pytest) ("python-pytest" ,python-pytest)