Skip to content

A patch to make pandas install and use numpy if it doesn't find it on the target host #2740

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,31 @@
" use pip or easy_install."
"\n $ pip install 'python-dateutil < 2' 'numpy'")

try:
import numpy as np
except ImportError:
nonumpy_msg = ("# numpy needed to finish setup. run:\n\n"
" $ pip install numpy # or easy_install numpy\n")
sys.exit(nonumpy_msg)

if np.__version__ < '1.6.1':
msg = "pandas requires NumPy >= 1.6.1 due to datetime64 dependency"
sys.exit(msg)

from distutils.extension import Extension
from distutils.command.build import build
from distutils.command.sdist import sdist
from distutils.command.build_ext import build_ext
from distutils.command.build_ext import build_ext as _build_ext

try:
from Cython.Distutils import build_ext
from Cython.Distutils import build_ext as _build_ext
# from Cython.Distutils import Extension # to get pyrex debugging symbols
cython = True
except ImportError:
cython = False

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


class build_ext(_build_ext):
def build_extensions(self):
numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')

for ext in self.extensions:
if hasattr(ext, 'include_dirs') and not numpy_incl in ext.include_dirs:
ext.include_dirs.append(numpy_incl)
_build_ext.build_extensions(self)


DESCRIPTION = ("Powerful data structures for data analysis, time series,"
"and statistics")
LONG_DESCRIPTION = """
Expand Down Expand Up @@ -340,10 +340,7 @@ def check_cython_extensions(self, extensions):

def build_extensions(self):
self.check_cython_extensions(self.extensions)
self.check_extensions_list(self.extensions)

for ext in self.extensions:
self.build_extension(ext)
build_ext.build_extensions(self)


class CompilationCacheMixin(object):
Expand Down Expand Up @@ -576,7 +573,7 @@ def srcpath(name=None, suffix='.pyx', subdir='src'):
lib_depends = []
plib_depends = []

common_include = [np.get_include(), 'pandas/src/klib', 'pandas/src']
common_include = ['pandas/src/klib', 'pandas/src']


def pxd(name):
Expand Down Expand Up @@ -635,7 +632,7 @@ def pxd(name):

sparse_ext = Extension('pandas._sparse',
sources=[srcpath('sparse', suffix=suffix)],
include_dirs=[np.get_include()],
include_dirs=[],
libraries=libraries)


Expand All @@ -657,7 +654,7 @@ def pxd(name):
cppsandbox_ext = Extension('pandas._cppsandbox',
language='c++',
sources=[srcpath('cppsandbox', suffix=suffix)],
include_dirs=[np.get_include()])
include_dirs=[])

extensions.extend([sparse_ext, parser_ext])

Expand Down