From a9d0abe288bba9202ad44a29e8ea9638e954b425 Mon Sep 17 00:00:00 2001 From: VirosaLi <2EkF8qUgpNkj> Date: Mon, 9 Nov 2020 21:41:35 -0600 Subject: [PATCH 1/5] CLN: clean setup.py --- setup.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/setup.py b/setup.py index 9a9d12ce4d2ba..38179cbddaf8c 100755 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ """ import argparse +from distutils.command.build import build from distutils.sysconfig import get_config_vars from distutils.version import LooseVersion import multiprocessing @@ -17,9 +18,8 @@ import sys import pkg_resources -from setuptools import Command, find_packages, setup +from setuptools import Command, Extension, find_packages, setup -# versioning import versioneer cmdclass = versioneer.get_cmdclass() @@ -48,14 +48,9 @@ def is_platform_mac(): _CYTHON_INSTALLED = False cythonize = lambda x, *args, **kwargs: x # dummy func -# The import of Extension must be after the import of Cython, otherwise -# we do not get the appropriately patched class. -# See https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html # noqa -from distutils.extension import Extension # isort:skip -from distutils.command.build import build # isort:skip - if _CYTHON_INSTALLED: - from Cython.Distutils.old_build_ext import old_build_ext as _build_ext + # from Cython.Distutils.old_build_ext import old_build_ext as _build_ext + from Cython.Distutils.build_ext import build_ext as _build_ext cython = True from Cython import Tempita as tempita @@ -477,18 +472,10 @@ def run(self): directives["linetrace"] = True macros = [("CYTHON_TRACE", "1"), ("CYTHON_TRACE_NOGIL", "1")] -# in numpy>=1.16.0, silence build warnings about deprecated API usage -# we can't do anything about these warnings because they stem from -# cython+numpy version mismatches. +# silence build warnings about deprecated API usage +# we can't do anything about these warnings because they stem from +# cython+numpy version mismatches. macros.append(("NPY_NO_DEPRECATED_API", "0")) -if "-Werror" in extra_compile_args: - try: - import numpy as np - except ImportError: - pass - else: - if np.__version__ < LooseVersion("1.16.0"): - extra_compile_args.remove("-Werror") # ---------------------------------------------------------------------- From dab6871c0f49bbbf083af11ecc82ab2e437ae41a Mon Sep 17 00:00:00 2001 From: VirosaLi <2EkF8qUgpNkj> Date: Mon, 9 Nov 2020 21:50:05 -0600 Subject: [PATCH 2/5] CLN: clean setup.py --- setup.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 38179cbddaf8c..da87cdd2e6668 100755 --- a/setup.py +++ b/setup.py @@ -49,16 +49,11 @@ def is_platform_mac(): cythonize = lambda x, *args, **kwargs: x # dummy func if _CYTHON_INSTALLED: - # from Cython.Distutils.old_build_ext import old_build_ext as _build_ext from Cython.Distutils.build_ext import build_ext as _build_ext - - cython = True from Cython import Tempita as tempita else: from distutils.command.build_ext import build_ext as _build_ext - cython = False - _pxi_dep_template = { "algos": ["_libs/algos_common_helper.pxi.in", "_libs/algos_take_helper.pxi.in"], @@ -104,7 +99,7 @@ def render_templates(cls, pxifiles): def build_extensions(self): # if building from c files, don't need to # generate template output - if cython: + if _CYTHON_INSTALLED: self.render_templates(_pxifiles) super().build_extensions() @@ -399,7 +394,7 @@ def run(self): cmdclass.update({"clean": CleanCommand, "build": build}) cmdclass["build_ext"] = CheckingBuildExt -if cython: +if _CYTHON_INSTALLED: suffix = ".pyx" cmdclass["cython"] = CythonCommand else: @@ -494,7 +489,7 @@ def maybe_cythonize(extensions, *args, **kwargs): # See https://github.com/cython/cython/issues/1495 return extensions - elif not cython: + elif not _CYTHON_INSTALLED: # GH#28836 raise a helfpul error message if _CYTHON_VERSION: raise RuntimeError( From b13982c4a0af6e26aa47bb6a6808b89ec12351aa Mon Sep 17 00:00:00 2001 From: VirosaLi <2EkF8qUgpNkj> Date: Mon, 9 Nov 2020 22:28:08 -0600 Subject: [PATCH 3/5] CLN: clean setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index da87cdd2e6668..a217cfd47d57a 100755 --- a/setup.py +++ b/setup.py @@ -49,8 +49,8 @@ def is_platform_mac(): cythonize = lambda x, *args, **kwargs: x # dummy func if _CYTHON_INSTALLED: + from Cython import Tempita from Cython.Distutils.build_ext import build_ext as _build_ext - from Cython import Tempita as tempita else: from distutils.command.build_ext import build_ext as _build_ext @@ -91,7 +91,7 @@ def render_templates(cls, pxifiles): with open(pxifile) as f: tmpl = f.read() - pyxcontent = tempita.sub(tmpl) + pyxcontent = Tempita.sub(tmpl) with open(outfile, "w") as f: f.write(pyxcontent) From 41467284997f2194b46e6d834374a920abc8f868 Mon Sep 17 00:00:00 2001 From: VirosaLi <2EkF8qUgpNkj> Date: Fri, 13 Nov 2020 22:21:05 -0600 Subject: [PATCH 4/5] CLN: cleanup setup.py --- setup.py | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/setup.py b/setup.py index a217cfd47d57a..2971aefb4188c 100755 --- a/setup.py +++ b/setup.py @@ -17,8 +17,9 @@ import shutil import sys -import pkg_resources +import numpy from setuptools import Command, Extension, find_packages, setup +from setuptools.command.build_ext import build_ext as _build_ext import versioneer @@ -37,9 +38,7 @@ def is_platform_mac(): min_cython_ver = "0.29.21" # note: sync with pyproject.toml try: - import Cython - - _CYTHON_VERSION = Cython.__version__ + from Cython import Tempita, __version__ as _CYTHON_VERSION from Cython.Build import cythonize _CYTHON_INSTALLED = _CYTHON_VERSION >= LooseVersion(min_cython_ver) @@ -48,12 +47,6 @@ def is_platform_mac(): _CYTHON_INSTALLED = False cythonize = lambda x, *args, **kwargs: x # dummy func -if _CYTHON_INSTALLED: - from Cython import Tempita - from Cython.Distutils.build_ext import build_ext as _build_ext -else: - from distutils.command.build_ext import build_ext as _build_ext - _pxi_dep_template = { "algos": ["_libs/algos_common_helper.pxi.in", "_libs/algos_take_helper.pxi.in"], @@ -498,25 +491,18 @@ def maybe_cythonize(extensions, *args, **kwargs): ) raise RuntimeError("Cannot cythonize without Cython installed.") - numpy_incl = pkg_resources.resource_filename("numpy", "core/include") - # TODO: Is this really necessary here? - for ext in extensions: - if hasattr(ext, "include_dirs") and numpy_incl not in ext.include_dirs: - ext.include_dirs.append(numpy_incl) + # numpy_incl = pkg_resources.resource_filename("numpy", "core/include") + # # TODO: Is this really necessary here? + # for ext in extensions: + # if hasattr(ext, "include_dirs") and numpy_incl not in ext.include_dirs: + # ext.include_dirs.append(numpy_incl) # reuse any parallel arguments provided for compilation to cythonize parser = argparse.ArgumentParser() - parser.add_argument("-j", type=int) - parser.add_argument("--parallel", type=int) + parser.add_argument("--parallel", "-j", type=int, default=1) parsed, _ = parser.parse_known_args() - nthreads = 0 - if parsed.parallel: - nthreads = parsed.parallel - elif parsed.j: - nthreads = parsed.j - - kwargs["nthreads"] = nthreads + kwargs["nthreads"] = parsed.parallel build_ext.render_templates(_pxifiles) return cythonize(extensions, *args, **kwargs) @@ -661,7 +647,8 @@ def srcpath(name=None, suffix=".pyx", subdir="src"): sources.extend(data.get("sources", [])) - include = data.get("include") + include = data.get("include", []) + include.append(numpy.get_include()) obj = Extension( f"pandas.{name}", @@ -710,6 +697,7 @@ def srcpath(name=None, suffix=".pyx", subdir="src"): "pandas/_libs/src/ujson/python", "pandas/_libs/src/ujson/lib", "pandas/_libs/src/datetime", + numpy.get_include(), ], extra_compile_args=(["-D_GNU_SOURCE"] + extra_compile_args), extra_link_args=extra_link_args, From 740aeb6ae8a1b42ef9dddea036dabcde57063cb7 Mon Sep 17 00:00:00 2001 From: VirosaLi <2EkF8qUgpNkj> Date: Fri, 13 Nov 2020 22:24:33 -0600 Subject: [PATCH 5/5] CLN: cleanup setup.py --- setup.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/setup.py b/setup.py index 2971aefb4188c..78a789c808efb 100755 --- a/setup.py +++ b/setup.py @@ -491,12 +491,6 @@ def maybe_cythonize(extensions, *args, **kwargs): ) raise RuntimeError("Cannot cythonize without Cython installed.") - # numpy_incl = pkg_resources.resource_filename("numpy", "core/include") - # # TODO: Is this really necessary here? - # for ext in extensions: - # if hasattr(ext, "include_dirs") and numpy_incl not in ext.include_dirs: - # ext.include_dirs.append(numpy_incl) - # reuse any parallel arguments provided for compilation to cythonize parser = argparse.ArgumentParser() parser.add_argument("--parallel", "-j", type=int, default=1)