Fixed #1429: "pip install numpy scipy" was failing #453

Merged
merged 4 commits into from Feb 27, 2013

Projects

None yet

4 participants

Contributor

It was failing because of the pre installation request from pip to ./setup.py egg_info (which is perfectly valid request and shouldn't fail), before numpy actually was installed.

This is pretty popular issue:
http://projects.scipy.org/scipy/ticket/1429
pypa/pip#25
pypa/pip#272
https://github.com/sjsrey/pysal/issues/207
http://bb10.com/python-testing-general/2011-06/msg00028.html
etc...

This really annoying when using tox - with this fix just set up requirements file and be sure that it will work on any machine (including on machines has already preinstalled numpy with different version that required).

Fix is straightforward - not to use numpy for commands that are not connected with build and install.

@ilblackdragon ilblackdragon Fixed #1429: pip install numpy scipy was failing because of the prein…
…stallation request from pip to scipy.setup egg_info, before numpy actually is installed
b6d90f1
Contributor

Btw, https://github.com/pydata/pandas did have the same issue pandas-dev/pandas#2732, but they fixed it pandas-dev/pandas@28e2a38 couple weeks ago

@pv pv commented on an outdated diff Feb 27, 2013
@@ -174,8 +167,25 @@ def setup_package():
license = 'BSD',
classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
platforms = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
- configuration=configuration)
+ )
+
+ # NumPy is required for install and build only
+ # for other cases just META_DATA is required and
+ # simple setuptools.setup will do the job
+ if sys.argv[1] in ('install', 'build'):
pv
pv Feb 27, 2013 Owner

There are also other commands (build_ext, sdist, ...) that require e.g. cython files be generated. Not sure if this should be whitelisting rather than blacklisting, or just add the missing commands. Both should do.

@pv pv commented on an outdated diff Feb 27, 2013
+
+ # NumPy is required for install and build only
+ # for other cases just META_DATA is required and
+ # simple setuptools.setup will do the job
+ if sys.argv[1] in ('install', 'build'):
+ from numpy.distutils.core import setup
+
+ # Rewrite the version file everytime
+ write_version_py()
+
+ # Generate Cython sources
+ generate_cython()
+
+ META_DATA['configuration'] = configuration
+ else:
+ from setuptools import setup
pv
pv Feb 27, 2013 Owner

Setuptools shouldn't be a build requirement, so this should be in try: except ImportError, and grab it from distutils otherwise.

ilblackdragon added some commits Feb 27, 2013
@ilblackdragon ilblackdragon Changed blacklist to whitelist of commands that are allowed to be use…
…d without numpy installed. If setuptools not found it falls to distutils. Corrected version generation and population in case of non-numpy usage.
89e8430
@ilblackdragon ilblackdragon Separated getting version from writing it to the version.py file in s…
…etup.py. Pre-installation case can call it directly without saving file.
11ac679
@ilblackdragon ilblackdragon Fixed loading scipy.version from get_version_info function - load it …
…directly without loading scipy/__init__.py
71e595f
Contributor

@pv I made changes according to your suggestions and fixed issues with handling version.py file. Please, review and let me know.

@pv pv merged commit 71e595f into scipy:master Feb 27, 2013
Owner
pv commented Feb 27, 2013

Thanks, seems to work.

Owner
rgommers commented Mar 2, 2013

We now have a working egg_info command, but the contents of SOURCES.txt are of course incomplete. Is that file used for anything by pip these days?

Owner
pv commented Mar 2, 2013

@rgommers: pip install at least succeeds. The generated SOURCES.txt is incomplete, but it wil be incomplete anyway if you have setuptools enabled (because numpy.distutils add_data* break when setuptools is active), see gh-454.

@vijaykramesh vijaykramesh pushed a commit to change/scikit-learn that referenced this pull request Oct 31, 2013
@GaelVaroquaux Abhijeet Kolhe + GaelVaroquaux Fix setup.py to resolve numpy requirement
during pre-install. This should allow
'pip install numpy cython scipy scikit-learn'
to install scikit.

This fix is based of issue and fixes in Scipy:
scipy/scipy#453
branden/scipy@ad0dd3e
8c71062
@pv pv added this to the 0.14.0 milestone Apr 27, 2014
@evertrol evertrol referenced this pull request in Unidata/netcdf4-python May 14, 2014
Merged

Allow setup.py/pip to run query commands without needing numpy. #257

I am wondering what happened to this issue. Cheeseshop scipy-0.14.0 setup.py still has from numpy.distutils.core import setup

@fnielsen fnielsen referenced this pull request in cournape/audiolab Dec 15, 2014
Open

pip install numpy #18

Owner
pv commented Dec 15, 2014

This issue is fixed, as explained above.

Owner
pv commented Dec 15, 2014

However, it's true that the fix will be included only in the next Scipy
version.

Sorry, I now see the 'if ... egg_info' has been added. Thanks

Owner
pv commented Dec 15, 2014

Actually, the fix in this PR was not enough to make a clean pip
install to work --- there's a second part in b615ea8 which is
also required, and which was not included in 0.14.0 (but will be in
the next ones).

@cgranade cgranade added a commit to cgranade/qutip that referenced this pull request Jun 7, 2016
@cgranade cgranade Brought fix from scipy/scipy#453. 64c4759
@jason-neal jason-neal referenced this pull request in sczesla/PyAstronomy Apr 24, 2017
Open

pip install numpy pyastronomy fails. #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment