From 7d449b212d35768b60379e57de8e2d843040a2c5 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 6 Mar 2019 16:39:50 -0600 Subject: [PATCH] Backport PR #25568: BLD: Fixed pip install with no numpy --- doc/source/whatsnew/v0.24.2.rst | 1 + setup.py | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/source/whatsnew/v0.24.2.rst b/doc/source/whatsnew/v0.24.2.rst index f864fcd04e3d4..4ca9d57f3a2e5 100644 --- a/doc/source/whatsnew/v0.24.2.rst +++ b/doc/source/whatsnew/v0.24.2.rst @@ -30,6 +30,7 @@ Fixed Regressions - Fixed regression in :class:`TimedeltaIndex` where ``np.sum(index)`` incorrectly returned a zero-dimensional object instead of a scalar (:issue:`25282`) - Fixed regression in ``IntervalDtype`` construction where passing an incorrect string with 'Interval' as a prefix could result in a ``RecursionError``. (:issue:`25338`) - Fixed regression in :class:`Categorical`, where constructing it from a categorical ``Series`` and an explicit ``categories=`` that differed from that in the ``Series`` created an invalid object which could trigger segfaults. (:issue:`25318`) +- Fixed pip installing from source into an environment without NumPy (:issue:`25193`) .. _whatsnew_0242.enhancements: diff --git a/setup.py b/setup.py index 52a67f147121c..2a67b21414f63 100755 --- a/setup.py +++ b/setup.py @@ -472,6 +472,11 @@ def maybe_cythonize(extensions, *args, **kwargs): # Avoid running cythonize on `python setup.py clean` # See https://github.com/cython/cython/issues/1495 return extensions + if not cython: + # Avoid trying to look up numpy when installing from sdist + # https://github.com/pandas-dev/pandas/issues/25193 + # TODO: See if this can be removed after pyproject.toml added. + return extensions numpy_incl = pkg_resources.resource_filename('numpy', 'core/include') # TODO: Is this really necessary here? @@ -480,11 +485,8 @@ def maybe_cythonize(extensions, *args, **kwargs): numpy_incl not in ext.include_dirs): ext.include_dirs.append(numpy_incl) - if cython: - build_ext.render_templates(_pxifiles) - return cythonize(extensions, *args, **kwargs) - else: - return extensions + build_ext.render_templates(_pxifiles) + return cythonize(extensions, *args, **kwargs) def srcpath(name=None, suffix='.pyx', subdir='src'):