diff mbox series

[bug#62801,1/4] gnu: Add python-astroscrappy.

Message ID 20230412210529.30189-1-sharlatanus@gmail.com
State New
Headers show
Series : gnu: python-astroalign: Update to 2.4.2. | expand

Commit Message

Sharlatan Hellseher April 12, 2023, 9:05 p.m. UTC
* gnu/packages/astronomy.scm (python-astroscrappy): New variable.
---
 gnu/packages/astronomy.scm | 48 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

Comments

Maxim Cournoyer April 20, 2023, 1:48 a.m. UTC | #1
Hello,

Sharlatan Hellseher <sharlatanus@gmail.com> writes:

> * gnu/packages/astronomy.scm (python-astroscrappy): New variable.
> ---
>  gnu/packages/astronomy.scm | 48 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>
> diff --git a/gnu/packages/astronomy.scm b/gnu/packages/astronomy.scm
> index db290f5987..f162be6006 100644
> --- a/gnu/packages/astronomy.scm
> +++ b/gnu/packages/astronomy.scm
> @@ -1302,6 +1302,54 @@ (define-public python-astroquery
>  to access online Astronomical data.  Each web service has its own sub-package.")
>      (license license:bsd-3)))
>  
> +(define-public python-astroscrappy
> +  (package
> +    (name "python-astroscrappy")
> +    (version "1.1.0")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (pypi-uri "astroscrappy" version))
> +       (sha256
> +        (base32 "0shmfilvzpmlwz4fh0bx4kqmzr0y39fgga6vipxb5d1rx1y6q6by"))))
> +    (build-system pyproject-build-system)
> +    (arguments
> +     (list
> +      #:phases
> +      #~(modify-phases %standard-phases
> +          (add-after 'unpack 'preparations
> +            (lambda _ (setenv "HOME" "/tmp")))
> +          (add-before 'install 'writable-compiler
> +            (lambda _ (make-file-writable "astroscrappy/_compiler.c")))
> +          (add-before 'check 'writable-compiler
> +            (lambda _ (make-file-writable "astroscrappy/_compiler.c")))
> +          (replace 'check
> +            (lambda* (#:key inputs outputs tests? #:allow-other-keys)
> +              (when tests?
> +                (add-installed-pythonpath inputs outputs)

The 'add-install-to-pythonpath' is not needed; this is implicitly
already done before the check phase in the python build systems.

> +                ;; Extensions have to be rebuilt before running the tests.
> +                (invoke "python" "setup.py" "build_ext" "--inplace")

I think it'd be a bit cleaner to move this in a distinct phase named
e.g. 'build-extension.  Then the check phase of pyproject-build-system
could be left alone.  If the '--pyargs' argument is really required, it
can be provided via the #:test-flags #~(list "--pyargs" "astroscrappy")
argument.

> +                (invoke "python" "-m" "pytest" "--pyargs" "astroscrappy")))))))
> +    (native-inputs
> +     (list python-cython
> +           python-extension-helpers
> +           python-h5py
> +           python-pandas
> +           python-pytest-astropy
> +           python-scikit-image
> +           python-setuptools-scm
> +           python-scipy))

The last input should appear earlier (sort).
diff mbox series

Patch

diff --git a/gnu/packages/astronomy.scm b/gnu/packages/astronomy.scm
index db290f5987..f162be6006 100644
--- a/gnu/packages/astronomy.scm
+++ b/gnu/packages/astronomy.scm
@@ -1302,6 +1302,54 @@  (define-public python-astroquery
 to access online Astronomical data.  Each web service has its own sub-package.")
     (license license:bsd-3)))
 
+(define-public python-astroscrappy
+  (package
+    (name "python-astroscrappy")
+    (version "1.1.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "astroscrappy" version))
+       (sha256
+        (base32 "0shmfilvzpmlwz4fh0bx4kqmzr0y39fgga6vipxb5d1rx1y6q6by"))))
+    (build-system pyproject-build-system)
+    (arguments
+     (list
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'preparations
+            (lambda _ (setenv "HOME" "/tmp")))
+          (add-before 'install 'writable-compiler
+            (lambda _ (make-file-writable "astroscrappy/_compiler.c")))
+          (add-before 'check 'writable-compiler
+            (lambda _ (make-file-writable "astroscrappy/_compiler.c")))
+          (replace 'check
+            (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+              (when tests?
+                (add-installed-pythonpath inputs outputs)
+                ;; Extensions have to be rebuilt before running the tests.
+                (invoke "python" "setup.py" "build_ext" "--inplace")
+                (invoke "python" "-m" "pytest" "--pyargs" "astroscrappy")))))))
+    (native-inputs
+     (list python-cython
+           python-extension-helpers
+           python-h5py
+           python-pandas
+           python-pytest-astropy
+           python-scikit-image
+           python-setuptools-scm
+           python-scipy))
+    (propagated-inputs (list python-astropy python-numpy))
+    (home-page "https://github.com/astropy/astroscrappy")
+    (synopsis "Speedy Cosmic Ray Annihilation Package in Python")
+    (description
+     "Astro-SCRAPPY is designed to detect cosmic rays in images (numpy
+arrays), based on Pieter van Dokkum's L.A.Cosmic algorithm.  Much of this was
+originally adapted from cosmics.py written by Malte Tewes.  This is designed to
+be as fast as possible so some of the readability has been sacrificed,
+specifically in the C code.")
+    (license license:bsd-3)))
+
 (define-public python-cdflib
   (package
     (name "python-cdflib")