Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLD: optional numpy import #39416

Closed
fangchenli opened this issue Jan 26, 2021 · 4 comments
Closed

BLD: optional numpy import #39416

fangchenli opened this issue Jan 26, 2021 · 4 comments
Labels
Build Library building on various platforms

Comments

@fangchenli
Copy link
Member

The added workflow pip installs pandas without the requirements pre-installed. Seems to pull in requirements OK. (I also wanted to test with other versions of setuptools locally though before approving this PR)

OT for the sdist build step we do python setup.py clean --quiet. This fails if numpy not installed.

Originally posted by @simonjayhawkins in #38852 (comment)

@fangchenli
Copy link
Member Author

fangchenli commented Jan 26, 2021

If using PEP 517, I think setuptools ensure NumPy is installed. xref #39415. But currently, we probably should raise an error msg if NumPy is not installed.

@fangchenli fangchenli added the Build Library building on various platforms label Jan 26, 2021
@jorisvandenbossche jorisvandenbossche changed the title BLD: optinal numpy import BLD: optional numpy import Jun 15, 2021
@jorisvandenbossche
Copy link
Member

What's exactly the action item in this issue?

@simonjayhawkins
Copy link
Member

from #38852 (comment)

python setup.py clean --quiet without numpy installed.

extracting source from tarball

(build_pandas) simon@P340:~/pandas-1.3.0rc1$ python setup.py clean
Traceback (most recent call last):
  File "/home/simon/pandas-1.3.0rc1/setup.py", line 18, in <module>
    import numpy
ModuleNotFoundError: No module named 'numpy'
(build_pandas) simon@P340:~/pandas-1.3.0rc1$ python setup.py build_ext -i -j8
Traceback (most recent call last):
  File "/home/simon/pandas-1.3.0rc1/setup.py", line 18, in <module>
    import numpy
ModuleNotFoundError: No module named 'numpy'
(build_pandas) simon@P340:~/pandas-1.3.0rc1$ python setup.py
Traceback (most recent call last):
  File "/home/simon/pandas-1.3.0rc1/setup.py", line 18, in <module>
    import numpy
ModuleNotFoundError: No module named 'numpy'
(build_pandas) simon@P340:~/pandas-1.3.0rc1$ python setup.py sdist --formats=gztar --quiet
Traceback (most recent call last):
  File "/home/simon/pandas-1.3.0rc1/setup.py", line 18, in <module>
    import numpy
ModuleNotFoundError: No module named 'numpy'
(build_pandas) simon@P340:~/pandas-1.3.0rc1$ python setup.py install
Traceback (most recent call last):
  File "/home/simon/pandas-1.3.0rc1/setup.py", line 18, in <module>
    import numpy
ModuleNotFoundError: No module named 'numpy'
(build_pandas) simon@P340:~/pandas-1.3.0rc1$ python -m pip install -e . --no-build-isolation --no-use-pep517
Obtaining file:///home/simon/pandas-1.3.0rc1
    ERROR: Command errored out with exit status 1:
     command: /home/simon/miniconda3/envs/build_pandas/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/simon/pandas-1.3.0rc1/setup.py'"'"'; __file__='"'"'/home/simon/pandas-1.3.0rc1/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-pzhrcoiq
         cwd: /home/simon/pandas-1.3.0rc1/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/simon/pandas-1.3.0rc1/setup.py", line 18, in <module>
        import numpy
    ModuleNotFoundError: No module named 'numpy'
    ----------------------------------------
WARNING: Discarding file:///home/simon/pandas-1.3.0rc1. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

whereas if we do a basic install from the tarball (again no numpy), the requirements are automatically satisfied.

(build_pandas) simon@P340:~$ pip install pandas-1.3.0rc1.tar.gz 
Processing ./pandas-1.3.0rc1.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting python-dateutil>=2.7.3
  Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting pytz>=2017.3
  Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting numpy>=1.17.3
  Using cached numpy-1.20.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.4 MB)
Collecting six>=1.5
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Building wheels for collected packages: pandas
  Building wheel for pandas (PEP 517) ... done
  Created wheel for pandas: filename=pandas-1.3.0rc1-cp39-cp39-linux_x86_64.whl size=12076718 sha256=3a30de40c758cb724cab981dad353bb25e47b6def4c2e1e860a159381933126e
  Stored in directory: /home/simon/.cache/pip/wheels/4d/06/d9/807062b570235f3ece521a32f5355ec0b0bf50d67265290598
Successfully built pandas
Installing collected packages: six, pytz, python-dateutil, numpy, pandas
Successfully installed numpy-1.20.3 pandas-1.3.0rc1 python-dateutil-2.8.1 pytz-2021.1 six-1.16.0
(build_pandas) simon@P340:~$ 

we have numpy as a top level import in setup.py. but not needed for some setup related tasks (i.e clean and create the sdist in a ci workflow). so the issue is that maybe numpy doesn't need to be a top-level import in setup.py?

@fangchenli
Copy link
Member Author

closed by #49115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Library building on various platforms
Projects
None yet
Development

No branches or pull requests

3 participants