Skip to content

Commit a89df10

Browse files
WillAydjreback
authored andcommitted
Parallelized Build / CI (#30214)
1 parent 96bb151 commit a89df10

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

ci/setup_env.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ conda list pandas
121121
# Make sure any error below is reported as such
122122

123123
echo "[Build extensions]"
124-
python setup.py build_ext -q -i
124+
python setup.py build_ext -q -i -j4
125125

126126
# XXX: Some of our environments end up with old versions of pip (10.x)
127127
# Adding a new enough version of pip to the requirements explodes the

setup.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
BSD license. Parts are from lxml (https://github.com/lxml/lxml)
77
"""
88

9+
import argparse
910
from distutils.sysconfig import get_config_vars
1011
from distutils.version import LooseVersion
1112
import os
@@ -129,12 +130,7 @@ def build_extensions(self):
129130
if cython:
130131
self.render_templates(_pxifiles)
131132

132-
numpy_incl = pkg_resources.resource_filename("numpy", "core/include")
133-
134-
for ext in self.extensions:
135-
if hasattr(ext, "include_dirs") and numpy_incl not in ext.include_dirs:
136-
ext.include_dirs.append(numpy_incl)
137-
_build_ext.build_extensions(self)
133+
super().build_extensions()
138134

139135

140136
DESCRIPTION = "Powerful data structures for data analysis, time series, and statistics"
@@ -530,6 +526,19 @@ def maybe_cythonize(extensions, *args, **kwargs):
530526
if hasattr(ext, "include_dirs") and numpy_incl not in ext.include_dirs:
531527
ext.include_dirs.append(numpy_incl)
532528

529+
# reuse any parallel arguments provided for compliation to cythonize
530+
parser = argparse.ArgumentParser()
531+
parser.add_argument("-j", type=int)
532+
parser.add_argument("--parallel", type=int)
533+
parsed, _ = parser.parse_known_args()
534+
535+
nthreads = 0
536+
if parsed.parallel:
537+
nthreads = parsed.parallel
538+
elif parsed.j:
539+
nthreads = parsed.j
540+
541+
kwargs["nthreads"] = nthreads
533542
build_ext.render_templates(_pxifiles)
534543
return cythonize(extensions, *args, **kwargs)
535544

@@ -686,7 +695,7 @@ def srcpath(name=None, suffix=".pyx", subdir="src"):
686695
"_libs.window.aggregations": {
687696
"pyxfile": "_libs/window/aggregations",
688697
"language": "c++",
689-
"suffix": ".cpp"
698+
"suffix": ".cpp",
690699
},
691700
"_libs.window.indexers": {"pyxfile": "_libs/window/indexers"},
692701
"_libs.writers": {"pyxfile": "_libs/writers"},

0 commit comments

Comments
 (0)