diff --git a/ci/setup_env.sh b/ci/setup_env.sh index 3d79c0cfd7000..a58dbe09dec01 100755 --- a/ci/setup_env.sh +++ b/ci/setup_env.sh @@ -121,7 +121,7 @@ conda list pandas # Make sure any error below is reported as such echo "[Build extensions]" -python setup.py build_ext -q -i +python setup.py build_ext -q -i -j4 # XXX: Some of our environments end up with old versions of pip (10.x) # Adding a new enough version of pip to the requirements explodes the diff --git a/setup.py b/setup.py index e6a95d4e7afd8..f7eb467cca8bc 100755 --- a/setup.py +++ b/setup.py @@ -6,6 +6,7 @@ BSD license. Parts are from lxml (https://github.com/lxml/lxml) """ +import argparse from distutils.sysconfig import get_config_vars from distutils.version import LooseVersion import os @@ -129,12 +130,7 @@ def build_extensions(self): if cython: self.render_templates(_pxifiles) - numpy_incl = pkg_resources.resource_filename("numpy", "core/include") - - for ext in self.extensions: - if hasattr(ext, "include_dirs") and numpy_incl not in ext.include_dirs: - ext.include_dirs.append(numpy_incl) - _build_ext.build_extensions(self) + super().build_extensions() DESCRIPTION = "Powerful data structures for data analysis, time series, and statistics" @@ -530,6 +526,19 @@ def maybe_cythonize(extensions, *args, **kwargs): 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 compliation to cythonize + parser = argparse.ArgumentParser() + parser.add_argument("-j", type=int) + parser.add_argument("--parallel", type=int) + parsed, _ = parser.parse_known_args() + + nthreads = 0 + if parsed.parallel: + nthreads = parsed.parallel + elif parsed.j: + nthreads = parsed.j + + kwargs["nthreads"] = nthreads build_ext.render_templates(_pxifiles) return cythonize(extensions, *args, **kwargs) @@ -686,7 +695,7 @@ def srcpath(name=None, suffix=".pyx", subdir="src"): "_libs.window.aggregations": { "pyxfile": "_libs/window/aggregations", "language": "c++", - "suffix": ".cpp" + "suffix": ".cpp", }, "_libs.window.indexers": {"pyxfile": "_libs/window/indexers"}, "_libs.writers": {"pyxfile": "_libs/writers"},