GalSim-developers / GalSim

The modular galaxy image simulation toolkit. Documentation:
http://galsim-developers.github.io/GalSim/
Other
224 stars 106 forks source link

RuntimeError: implement_array_function method already has a docstring #1076

Closed EiffL closed 4 years ago

EiffL commented 4 years ago

I am encountering errors when trying to install GalSim on a fresh Python:3.7.5 NumPy:1.18.1 environment. From looking around on the internet it looks that it might be a known NumPy issue that arises when the numpy module gets reloaded from some reason. See: https://github.com/numpy/numpy/issues/14384

Here is what I see when installing GalSim:

Installed /tmp/pip-install-g78c5tor/galsim/.eggs/eigency-1.77-py3.7-linux-x86_64.egg
    running egg_info
    creating /tmp/pip-install-g78c5tor/galsim/pip-egg-info/GalSim.egg-info
    writing /tmp/pip-install-g78c5tor/galsim/pip-egg-info/GalSim.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-install-g78c5tor/galsim/pip-egg-info/GalSim.egg-info/dependency_links.txt
    writing entry points to /tmp/pip-install-g78c5tor/galsim/pip-egg-info/GalSim.egg-info/entry_points.txt
    writing requirements to /tmp/pip-install-g78c5tor/galsim/pip-egg-info/GalSim.egg-info/requires.txt
    writing top-level names to /tmp/pip-install-g78c5tor/galsim/pip-egg-info/GalSim.egg-info/top_level.txt
    writing manifest file '/tmp/pip-install-g78c5tor/galsim/pip-egg-info/GalSim.egg-info/SOURCES.txt'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-g78c5tor/galsim/setup.py", line 1053, in <module>
        zip_safe=False,
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/site-packages/setuptools/command/egg_info.py", line 296, in run
        self.find_sources()
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/site-packages/setuptools/command/egg_info.py", line 303, in find_sources
        mm.run()
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/site-packages/setuptools/command/egg_info.py", line 534, in run
        self.add_defaults()
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/site-packages/setuptools/command/egg_info.py", line 570, in add_defaults
        sdist.add_defaults(self)
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/distutils/command/sdist.py", line 228, in add_defaults
        self._add_defaults_ext()
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/distutils/command/sdist.py", line 311, in _add_defaults_ext
        build_ext = self.get_finalized_command('build_ext')
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/distutils/cmd.py", line 299, in get_finalized_command
        cmd_obj.ensure_finalized()
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/tmp/pip-install-g78c5tor/galsim/setup.py", line 793, in finalize_options
        add_dirs(self, output=do_output)
      File "/tmp/pip-install-g78c5tor/galsim/setup.py", line 683, in add_dirs
        eigen_dir = find_eigen_dir(output=output)
      File "/tmp/pip-install-g78c5tor/galsim/setup.py", line 293, in find_eigen_dir
        import eigency
      File "/tmp/pip-install-g78c5tor/galsim/.eggs/eigency-1.77-py3.7-linux-x86_64.egg/eigency/__init__.py", line 2, in <module>
        import numpy as np
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/site-packages/numpy/__init__.py", line 142, in <module>
        from . import core
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/site-packages/numpy/core/__init__.py", line 24, in <module>
        from . import multiarray
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/site-packages/numpy/core/multiarray.py", line 14, in <module>
        from . import overrides
      File "/gpfslocalsup/pub/anaconda-py3/2019.10/lib/python3.7/site-packages/numpy/core/overrides.py", line 47, in <module>
        """)
    RuntimeError: implement_array_function method already has a docstring
    Looking for  libfftw3.so
       /gpfslocalsup/spack_soft/fftw/3.3.8/intel-19.0.4-erdqwqdj5v265sdojawkypoajub6vc2v/lib  (yes)
    Include directory for fftw3 is  /gpfslocalsup/spack_soft/fftw/3.3.8/intel-19.0.4-erdqwqdj5v265sdojawkypoajub6vc2v/include
Cleaning up...
  Removing source in /tmp/pip-install-g78c5tor/galsim
Removed galsim from https://files.pythonhosted.org/packages/77/24/dcaa9e935186c86f148c8f8a02dafe80de3cc8fa8d3c940d7991de2d5aa1/GalSim-2.2.3.tar.gz#sha256=ec1ceffc08f8c8d10c65bed698375685bc263923bac7c7dd4ee584b33e5c3cc7 from build tracker '/tmp/pip-req-tracker-vdeudad4'
Removed build tracker '/tmp/pip-req-tracker-vdeudad4'
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I'll try to figure out what's happening but thought I might report first.

EiffL commented 4 years ago

Looks like the problem comes from the find_eigen_dir function, that re-imports numpy, apparently, that's not cool ^^'

rmjarvis commented 4 years ago

It looks like you're using anaconda, in which case I'd recommend conda install galsim rather than installing by hand. That will use the conda installation of Eigen, which is probably more reliable than using eigency (the fallback option if GalSim can't find Eigen anywhere else).

EiffL commented 4 years ago

Ok, indeed that's a good point, didn't think of that. So I managed to install it nonetheless from source after cloning the repo and doing:

$ pip install --prefix=~/.local  .

For some reason, pip install --prefix=~/local -e . failed with the same error. I"m not sure what's the difference in terms of compile script.

Installing with conda is ok in this instance for me, but still looks like pip install will fail in some cases :-(

EiffL commented 4 years ago

Which I guess, is a reminder for myself to actually solve #1056 ^^'

rmjarvis commented 4 years ago

Unfortunately, I'm not sure that there is any action to take in GalSim for this issue. As you said, it seems to be a weird numpy bug where they don't properly guard something correctly for multiple imports. OK to close?

m-f-h commented 4 years ago

The same bug currently occurs on pythonanywhere.com (maybe only for recent accounts - those using Python 3.8?) and makes it nearly unusable. Appears to be rooted in this bug: https://github.com/numpy/numpy/issues/665

rmjarvis commented 4 years ago

I think I have a workaround for this on #1086