Skip to content

Commit 28e2a38

Browse files
takinbowesm
authored andcommitted
removed the requirement of pandas to have numpy
already installed on the target before it can be installed A patch to fix issue #2732
1 parent e356f98 commit 28e2a38

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

setup.py

+17-20
Original file line numberDiff line numberDiff line change
@@ -85,31 +85,31 @@
8585
" use pip or easy_install."
8686
"\n $ pip install 'python-dateutil < 2' 'numpy'")
8787

88-
try:
89-
import numpy as np
90-
except ImportError:
91-
nonumpy_msg = ("# numpy needed to finish setup. run:\n\n"
92-
" $ pip install numpy # or easy_install numpy\n")
93-
sys.exit(nonumpy_msg)
94-
95-
if np.__version__ < '1.6.1':
96-
msg = "pandas requires NumPy >= 1.6.1 due to datetime64 dependency"
97-
sys.exit(msg)
98-
9988
from distutils.extension import Extension
10089
from distutils.command.build import build
10190
from distutils.command.sdist import sdist
102-
from distutils.command.build_ext import build_ext
91+
from distutils.command.build_ext import build_ext as _build_ext
10392

10493
try:
105-
from Cython.Distutils import build_ext
94+
from Cython.Distutils import build_ext as _build_ext
10695
# from Cython.Distutils import Extension # to get pyrex debugging symbols
10796
cython = True
10897
except ImportError:
10998
cython = False
11099

111100
from os.path import splitext, basename, join as pjoin
112101

102+
103+
class build_ext(_build_ext):
104+
def build_extensions(self):
105+
numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')
106+
107+
for ext in self.extensions:
108+
if hasattr(ext, 'include_dirs') and not numpy_incl in ext.include_dirs:
109+
ext.include_dirs.append(numpy_incl)
110+
_build_ext.build_extensions(self)
111+
112+
113113
DESCRIPTION = ("Powerful data structures for data analysis, time series,"
114114
"and statistics")
115115
LONG_DESCRIPTION = """
@@ -341,10 +341,7 @@ def check_cython_extensions(self, extensions):
341341

342342
def build_extensions(self):
343343
self.check_cython_extensions(self.extensions)
344-
self.check_extensions_list(self.extensions)
345-
346-
for ext in self.extensions:
347-
self.build_extension(ext)
344+
build_ext.build_extensions(self)
348345

349346

350347
class CompilationCacheMixin(object):
@@ -577,7 +574,7 @@ def srcpath(name=None, suffix='.pyx', subdir='src'):
577574
lib_depends = []
578575
plib_depends = []
579576

580-
common_include = [np.get_include(), 'pandas/src/klib', 'pandas/src']
577+
common_include = ['pandas/src/klib', 'pandas/src']
581578

582579

583580
def pxd(name):
@@ -636,7 +633,7 @@ def pxd(name):
636633

637634
sparse_ext = Extension('pandas._sparse',
638635
sources=[srcpath('sparse', suffix=suffix)],
639-
include_dirs=[np.get_include()],
636+
include_dirs=[],
640637
libraries=libraries)
641638

642639

@@ -658,7 +655,7 @@ def pxd(name):
658655
cppsandbox_ext = Extension('pandas._cppsandbox',
659656
language='c++',
660657
sources=[srcpath('cppsandbox', suffix=suffix)],
661-
include_dirs=[np.get_include()])
658+
include_dirs=[])
662659

663660
extensions.extend([sparse_ext, parser_ext])
664661

0 commit comments

Comments
 (0)