Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Running setup.py in affiliated package is not possible unless numpy is already installed #402

Closed
@drdavella

Description

@drdavella

In a clean environment, running setup.py in any affiliated package will cause something like the error listed below. This is obviously unintuitive and undesirable behavior.

EDIT: This apparently only affects setup.py install/develop, but not setup.py egg_info, which is why it has not been detected in Astropy's CI builds.

It's not yet clear to me yet whether this can be fixed by putting some try/except logic around the imports below (and possibly elsewhere), or whether this is a more fundamental problem with the helpers strategy:

def get_numpy_include_path():
"""
Gets the path to the numpy headers.
"""
# We need to go through this nonsense in case setuptools
# downloaded and installed Numpy for us as part of the build or
# install, since Numpy may still think it's in "setup mode", when
# in fact we're ready to use it to build astropy now.
import builtins
if hasattr(builtins, '__NUMPY_SETUP__'):
del builtins.__NUMPY_SETUP__
import imp
import numpy
imp.reload(numpy)
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
return numpy_include

running build_ext
Traceback (most recent call last):
  File "./setup.py", line 143, in <module>
    **package_info
  File "/Users/ddavella/miniconda3/envs/ah-bottleneck/lib/python3.6/site-packages/setuptools/__init__.py", line 140, in setup
    return distutils.core.setup(**attrs)
  File "/Users/ddavella/miniconda3/envs/ah-bottleneck/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/Users/ddavella/miniconda3/envs/ah-bottleneck/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/Users/ddavella/miniconda3/envs/ah-bottleneck/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/ddavella/miniconda3/envs/ah-bottleneck/lib/python3.6/site-packages/setuptools/command/develop.py", line 38, in run
    self.install_for_development()
  File "/Users/ddavella/miniconda3/envs/ah-bottleneck/lib/python3.6/site-packages/setuptools/command/develop.py", line 138, in install_for_development
    self.run_command('build_ext')
  File "/Users/ddavella/miniconda3/envs/ah-bottleneck/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/Users/ddavella/miniconda3/envs/ah-bottleneck/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/ddavella/sandbox/ah-bottleneck/astropy_helpers/astropy_helpers/commands/build_ext.py", line 292, in run
    np_include = get_numpy_include_path()
  File "/Users/ddavella/sandbox/ah-bottleneck/astropy_helpers/astropy_helpers/utils.py", line 72, in get_numpy_include_path
    import numpy
ModuleNotFoundError: No module named 'numpy'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions