Subject: [bug#48046] [PATCH]: Gnu add astropy

From: Sharlatan Hellseher <[email-masked]>
Date: Sat, 22 May 2021 20:00:35 +0000

Hi Vinicius,

My attempt to make Astropy test working failed as well. the project
heavily depends on TOX which requires pip to install missing
dependencies for itself. I run test with pytest but it looks like it's
not allowed by this
https://github.com/astropy/astropy/blob/main/astropy/__init__.py#L139

I'll come back to conquer it once again when I have some fresh ideas.

On Wed, 19 May 2021 at 18:16, Vinicius Monego <[email-masked]> wrote:
>
> Hi,
>
> Em seg, 2021-04-26 às 20:01 +0000, Sharlatan Hellseher escreveu:
> > Hi Guix team!
> >
> > Here is my attempt to pack bulky python package -
> > https://www.astropy.org/
> > I've disabled test and add minor modification removing `_compiler.c'
> > file.
>
> I've tried to package AstroPy before but got stuck in the dependencies,
> more specifically pytest-astropy. There is a bug somewhere that pytest-
> filter-subpackage is not found by setup.py, even though it's listed in
> the inputs. I encountered that problem again here, after enabling the
> tests.
>
> > +     ;; NOTE: (Sharlatan-20210426T204315+0100): Tests require build
> > astropy
> > +     ;; module, it needs a good review on how to enable them.
> > +     `(#:tests? #f
>
> AstroPy uses pytest, which is not listed in your native-inputs. The
> other dependencies I had to add are python-hypothesis, python-pytest-
> cov, python-pytest-astropy and python-pytest-xdist. According to the
> documentation, it should be as simple as running pytest to run the
> entire test suite:
>
> https://docs.astropy.org/en/latest/development/testguide.html#running-tests
>
> If you end up in 'ModuleNotFoundError: No module named "astropy"', you
> may have to update PYTHONPATH after the install phase with (add-
> installed-pythonpath inputs outputs). That usually happens when
> replacing the check phase.
>
> > +    (inputs
> > +     `(("asdf" ,python-asdf)
> > +       ("beautifulsoup4" ,python-beautifulsoup4)
> > +       ("bleach" ,python-bleach)
> > +       ("bottleneck" ,python-bottleneck)
> > +       ("cfitsio" ,cfitsio)
> > +       ("dask" ,python-dask)
> > +       ("expat" ,expat)
> > +       ("graphviz" ,graphviz)
> > +       ("h5py" ,python-h5py)
> > +       ("html5lib" ,python-html5lib)
> > +       ("jplephem" ,python-jplephem)
> > +       ("matplotlib" ,python-matplotlib)
> > +       ("mpmath" ,python-mpmath)
> > +       ("numpy" ,python-numpy)
> > +       ("pandas" ,python-pandas)
> > +       ("pyerfa" ,python-pyerfa)
> > +       ("pytz" ,python-pytz)
> > +       ("pyyaml" ,python-pyyaml)
> > +       ("scipy" ,python-scipy)
> > +       ("sortedcontainers" ,python-sortedcontainers)
> > +       ("wcslib" ,wcslib)))
>
> AstroPy is a library, its Python inputs should be propagated here.
> See https://guix.gnu.org/manual/en/html_node/package-Reference.html#package-Reference
> for reference.
>
> Also, the documentation states that the only strict requirements are
> PyERFA and NumPy:
>
> https://docs.astropy.org/en/stable/install.html
>
> IMO we should only propagate these, and leave the rest in native-inputs
> as needed by tests.
>
> Now speaking of the astropy dependencies, pytest-astropy is supposed to
> propagate its six dependencies. AFAIK its purpose is to be a
> metapackage to install these other 6 pytest modules. PyERFA should also
> propagate numpy (liberfa can remain as normal input).
>
> I'll take a look at this package again next week. Could you test these
> suggestions in the meantime?
>
> Vinicius
>
>

-- 

… наш разум - превосходная объяснительная машина которая способна
найти смысл почти в чем угодно, истолковать любой феномен, но
совершенно не в состоянии принять мысль о непредсказуемости.
From 4b0d8e20915ee674054cb3bd1b3573a9f42bd08a Mon Sep 17 00:00:00 2001
From: Sharlatan Hellseher <[email-masked]>
Date: Sat, 22 May 2021 20:52:49 +0100
Subject: [PATCH] gnu: astropy: rc1

* gnu/packages/astronomy.scm (python-astropy)
 [inputs]: refactor inputs
 [package] Attemp to make test working no-successufl run, it failed with

starting phase `check'
/tmp/guix-build-python-astropy-4.2.1.drv-0/astropy-4.2.1/astropy/config/configuration.py:582: ConfigurationMissingWarning: Configuration defaults will be used due to FileNotFoundError:2 on None
  warn(ConfigurationMissingWarning(msg))
ImportError while loading conftest '/tmp/guix-build-python-astropy-4.2.1.drv-0/astropy-4.2.1/conftest.py'.
conftest.py:11: in <module>
    from astropy import __version__
astropy/__init__.py:248: in <module>
    _initialize_astropy()
astropy/__init__.py:203: in _initialize_astropy
    raise ImportError('You appear to be trying to import astropy from '
E   ImportError: You appear to be trying to import astropy from within a source checkout or from an editable installation without building the extension modules first. Either run:
E
E     pip install -e .
E
E   or
E
E     python setup.py build_ext --inplace
E
E   to make sure the extension modules are built
command "pytest" "-vv" failed with status 4
builder for `/gnu/store/syjzb0sjd01af6i13k5pa6snwxk1im3x-python-astropy-4.2.1.drv' failed with exit code 1
---
 gnu/packages/astronomy.scm | 71 +++++++++++++++++++++-----------------
 1 file changed, 40 insertions(+), 31 deletions(-)

diff --git a/gnu/packages/astronomy.scm b/gnu/packages/astronomy.scm
index b607fbd3d7..8ea665380e 100644
--- a/gnu/packages/astronomy.scm
+++ b/gnu/packages/astronomy.scm
@@ -1085,13 +1085,17 @@ orbit around the Earth.")
     (arguments
      ;; NOTE: (Sharlatan-20210426T204315+0100): Tests require build astropy
      ;; module, it needs a good review on how to enable them.
-     `(#:tests? #f
+     `(;#:tests? #f
        #:phases
        (modify-phases %standard-phases
          (add-before 'build 'setenv-astropy-system-all
            (lambda _
              (setenv "ASTROPY_USE_SYSTEM_ALL" "1")
              #t))
+         (replace 'check
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (add-installed-pythonpath inputs outputs)
+             (invoke "pytest" "-vv")))
          ;; NOTE: (Sharlatan-20210426T200127+0100): it fails during install
          ;; phases without the file is removed
          ;;
@@ -1108,37 +1112,42 @@ orbit around the Earth.")
              #t)))))
     (native-inputs
      `(("cfitsio" ,cfitsio)
-       ("coverage" ,python-coverage)
-       ("cython" ,python-cython)
-       ("extension-helpers" ,python-extension-helpers)
-       ("ipython" ,python-ipython)
-       ("objgraph" ,python-objgraph)
-       ("pkg-config" ,pkg-config)
-       ("setuptools-scm" ,python-setuptools-scm)
-       ("sgp4" ,python-sgp4)
-       ("skyfield" ,python-skyfield)))
-    (inputs
-     `(("asdf" ,python-asdf)
-       ("beautifulsoup4" ,python-beautifulsoup4)
-       ("bleach" ,python-bleach)
-       ("bottleneck" ,python-bottleneck)
-       ("cfitsio" ,cfitsio)
-       ("dask" ,python-dask)
-       ("expat" ,expat)
-       ("graphviz" ,graphviz)
-       ("h5py" ,python-h5py)
-       ("html5lib" ,python-html5lib)
-       ("jplephem" ,python-jplephem)
-       ("matplotlib" ,python-matplotlib)
-       ("mpmath" ,python-mpmath)
-       ("numpy" ,python-numpy)
-       ("pandas" ,python-pandas)
-       ("pyerfa" ,python-pyerfa)
-       ("pytz" ,python-pytz)
-       ("pyyaml" ,python-pyyaml)
-       ("scipy" ,python-scipy)
-       ("sortedcontainers" ,python-sortedcontainers)
+       ("python-asdf" ,python-asdf)("expat" ,expat)
+       ("python-beautifulsoup4" ,python-beautifulsoup4)
+       ("python-bleach" ,python-bleach)
+       ("python-bottleneck" ,python-bottleneck)
+       ("python-coverage" ,python-coverage)
+       ("python-cython" ,python-cython)
+       ("python-dask" ,python-dask)
+       ("python-extension-helpers" ,python-extension-helpers)
+       ("python-graphviz" ,graphviz)
+       ("python-h5py" ,python-h5py)
+       ("python-html5lib" ,python-html5lib)
+       ("python-hypothesis" ,python-hypothesis)
+       ("python-ipython" ,python-ipython)
+       ("python-jplephem" ,python-jplephem)
+       ("python-matplotlib" ,python-matplotlib)
+       ("python-mpmath" ,python-mpmath)
+       ("python-objgraph" ,python-objgraph)
+       ("python-pandas" ,python-pandas)
+       ("python-pkg-config" ,pkg-config)
+       ("python-pytest" ,python-pytest)
+       ("python-pytest-astropy" ,python-pytest-astropy)
+       ("python-pytest-cov" ,python-pytest-cov)
+       ("python-pytest-xdist" ,python-pytest-xdist)
+       ("python-pytz" ,python-pytz)
+       ("python-pyyaml" ,python-pyyaml)
+       ("python-scipy" ,python-scipy)
+       ("python-setuptools" ,python-setuptools)
+       ("python-setuptools-scm" ,python-setuptools-scm)
+       ("python-sgp4" ,python-sgp4)
+       ("python-skyfield" ,python-skyfield)
+       ("python-sortedcontainers" ,python-sortedcontainers)
+       ("python-tox" ,python-tox)
        ("wcslib" ,wcslib)))
+    (propagated-inputs
+     `(("python-numpy" ,python-numpy)
+       ("python-pyerfa" ,python-pyerfa)))
     (home-page "https://astropy.org/")
     (synopsis "Astronomy and astrophysics core library")
     (description
-- 
2.31.1