From 0056568ad0dc957e630508e16ec1130699ae57c3 Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Fri, 17 Nov 2017 09:51:58 -0800 Subject: [PATCH 1/2] remove have_setuptools branching --- setup.py | 69 +++++++++++++++++--------------------------------------- 1 file changed, 21 insertions(+), 48 deletions(-) diff --git a/setup.py b/setup.py index 33251d9aabedc..18cff622ca72a 100755 --- a/setup.py +++ b/setup.py @@ -38,46 +38,24 @@ def is_platform_mac(): except ImportError: _CYTHON_INSTALLED = False -try: - import pkg_resources - from setuptools import setup, Command - _have_setuptools = True -except ImportError: - # no setuptools installed - from distutils.core import setup, Command - _have_setuptools = False -setuptools_kwargs = {} +from setuptools import setup, Command +import pkg_resources + + min_numpy_ver = '1.9.0' -if sys.version_info[0] >= 3: - setuptools_kwargs = {'zip_safe': False, - 'install_requires': ['python-dateutil >= 2', - 'pytz >= 2011k', - 'numpy >= %s' % min_numpy_ver], - 'setup_requires': ['numpy >= %s' % min_numpy_ver]} - if not _have_setuptools: - sys.exit("need setuptools/distribute for Py3k" - "\n$ pip install distribute") +setuptools_kwargs = {'test_suite': 'nose.collector', + 'zip_safe': False, + 'setup_requires': ['numpy >= %s' % min_numpy_ver], + 'install_requires': ['pytz >= 2011k', + 'numpy >= %s' % min_numpy_ver]} +if sys.version_info[0] >= 3: + setuptools_kwargs['install_requires'].append('python-dateutil >= 2') else: - setuptools_kwargs = { - 'install_requires': ['python-dateutil', - 'pytz >= 2011k', - 'numpy >= %s' % min_numpy_ver], - 'setup_requires': ['numpy >= %s' % min_numpy_ver], - 'zip_safe': False, - } - - if not _have_setuptools: - try: - import numpy # noqa:F401 - import dateutil # noqa:F401 - setuptools_kwargs = {} - except ImportError: - sys.exit("install requires: 'python-dateutil < 2','numpy'." - " use pip or easy_install." - "\n $ pip install 'python-dateutil < 2' 'numpy'") + setuptools_kwargs['install_requires'].append('python-dateutil') + from distutils.extension import Extension # noqa:E402 from distutils.command.build import build # noqa:E402 @@ -151,7 +129,8 @@ def build_extensions(self): with open(outfile, "w") as f: f.write(pyxcontent) - numpy_incl = pkg_resources.resource_filename('numpy', 'core/include') + assert len(numpy_incls) == 1 + numpy_incl = numpy_incls[0] for ext in self.extensions: if (hasattr(ext, 'include_dirs') and @@ -363,8 +342,8 @@ def run(self): else: for pyxfile in self._pyxfiles: cfile = pyxfile[:-3] + 'c' - msg = "C-source file '%s' not found." % (cfile) +\ - " Run 'setup.py cython' before sdist." + msg = ("C-source file '{cfile}' not found. Run " + "'setup.py cython' before sdist.".format(cfile=cfile)) assert os.path.isfile(cfile), msg sdist_class.run(self) @@ -452,7 +431,6 @@ def srcpath(name=None, suffix='.pyx', subdir='src'): lib_depends.append('pandas/_libs/src/util.pxd') else: lib_depends = [] - plib_depends = [] common_include = ['pandas/_libs/src/klib', 'pandas/_libs/src'] @@ -461,12 +439,10 @@ def pxd(name): return os.path.abspath(pjoin('pandas', name + '.pxd')) -if _have_setuptools: - # Note: this is a list, whereas `numpy_incl` in build_ext.build_extensions - # is a string - numpy_incls = [pkg_resources.resource_filename('numpy', 'core/include')] -else: - numpy_incls = [] +# Note: this is a list, whereas `numpy_incl` in build_ext.build_extensions +# is a string +numpy_incls = [pkg_resources.resource_filename('numpy', 'core/include')] + # args to ignore warnings if is_platform_windows(): @@ -720,9 +696,6 @@ def pxd(name): extensions.append(_move_ext) -if _have_setuptools: - setuptools_kwargs["test_suite"] = "nose.collector" - # The build cache system does string matching below this point. # if you change something, be careful. From 8ea38e8b8740286331bdcf881442a500d774a678 Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Sat, 18 Nov 2017 17:43:16 -0800 Subject: [PATCH 2/2] remove per request --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 18cff622ca72a..aa0f3951e6328 100755 --- a/setup.py +++ b/setup.py @@ -45,8 +45,7 @@ def is_platform_mac(): min_numpy_ver = '1.9.0' -setuptools_kwargs = {'test_suite': 'nose.collector', - 'zip_safe': False, +setuptools_kwargs = {'zip_safe': False, 'setup_requires': ['numpy >= %s' % min_numpy_ver], 'install_requires': ['pytz >= 2011k', 'numpy >= %s' % min_numpy_ver]}