Skip to content

Commit 754dc4c

Browse files
WillAydjreback
authored andcommitted
Parallel Cythonization for spawned Processes (#30862)
1 parent 14f1982 commit 754dc4c

File tree

1 file changed

+49
-50
lines changed

1 file changed

+49
-50
lines changed

setup.py

+49-50
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import argparse
1010
from distutils.sysconfig import get_config_vars
1111
from distutils.version import LooseVersion
12+
import multiprocessing
1213
import os
1314
from os.path import join as pjoin
1415
import platform
@@ -35,17 +36,6 @@ def is_platform_mac():
3536
min_numpy_ver = "1.13.3"
3637
min_cython_ver = "0.29.13" # note: sync with pyproject.toml
3738

38-
setuptools_kwargs = {
39-
"install_requires": [
40-
"python-dateutil >= 2.6.1",
41-
"pytz >= 2017.2",
42-
f"numpy >= {min_numpy_ver}",
43-
],
44-
"setup_requires": [f"numpy >= {min_numpy_ver}"],
45-
"zip_safe": False,
46-
}
47-
48-
4939
try:
5040
import Cython
5141

@@ -532,11 +522,6 @@ def maybe_cythonize(extensions, *args, **kwargs):
532522
elif parsed.j:
533523
nthreads = parsed.j
534524

535-
# GH#30356 Cythonize doesn't support parallel on Windows
536-
if is_platform_windows() and nthreads > 0:
537-
print("Parallel build for cythonize ignored on Windows")
538-
nthreads = 0
539-
540525
kwargs["nthreads"] = nthreads
541526
build_ext.render_templates(_pxifiles)
542527
return cythonize(extensions, *args, **kwargs)
@@ -749,37 +734,51 @@ def srcpath(name=None, suffix=".pyx", subdir="src"):
749734
# ----------------------------------------------------------------------
750735

751736

752-
# The build cache system does string matching below this point.
753-
# if you change something, be careful.
754-
755-
setup(
756-
name=DISTNAME,
757-
maintainer=AUTHOR,
758-
version=versioneer.get_version(),
759-
packages=find_packages(include=["pandas", "pandas.*"]),
760-
package_data={"": ["templates/*", "_libs/*.dll"]},
761-
ext_modules=maybe_cythonize(extensions, compiler_directives=directives),
762-
maintainer_email=EMAIL,
763-
description=DESCRIPTION,
764-
license=LICENSE,
765-
cmdclass=cmdclass,
766-
url=URL,
767-
download_url=DOWNLOAD_URL,
768-
project_urls=PROJECT_URLS,
769-
long_description=LONG_DESCRIPTION,
770-
classifiers=CLASSIFIERS,
771-
platforms="any",
772-
python_requires=">=3.6.1",
773-
extras_require={
774-
"test": [
775-
# sync with setup.cfg minversion & install.rst
776-
"pytest>=4.0.2",
777-
"pytest-xdist",
778-
"hypothesis>=3.58",
779-
]
780-
},
781-
entry_points={
782-
"pandas_plotting_backends": ["matplotlib = pandas:plotting._matplotlib"]
783-
},
784-
**setuptools_kwargs,
785-
)
737+
def setup_package():
738+
setuptools_kwargs = {
739+
"install_requires": [
740+
"python-dateutil >= 2.6.1",
741+
"pytz >= 2017.2",
742+
f"numpy >= {min_numpy_ver}",
743+
],
744+
"setup_requires": [f"numpy >= {min_numpy_ver}"],
745+
"zip_safe": False,
746+
}
747+
748+
setup(
749+
name=DISTNAME,
750+
maintainer=AUTHOR,
751+
version=versioneer.get_version(),
752+
packages=find_packages(include=["pandas", "pandas.*"]),
753+
package_data={"": ["templates/*", "_libs/*.dll"]},
754+
ext_modules=maybe_cythonize(extensions, compiler_directives=directives),
755+
maintainer_email=EMAIL,
756+
description=DESCRIPTION,
757+
license=LICENSE,
758+
cmdclass=cmdclass,
759+
url=URL,
760+
download_url=DOWNLOAD_URL,
761+
project_urls=PROJECT_URLS,
762+
long_description=LONG_DESCRIPTION,
763+
classifiers=CLASSIFIERS,
764+
platforms="any",
765+
python_requires=">=3.6.1",
766+
extras_require={
767+
"test": [
768+
# sync with setup.cfg minversion & install.rst
769+
"pytest>=4.0.2",
770+
"pytest-xdist",
771+
"hypothesis>=3.58",
772+
]
773+
},
774+
entry_points={
775+
"pandas_plotting_backends": ["matplotlib = pandas:plotting._matplotlib"]
776+
},
777+
**setuptools_kwargs,
778+
)
779+
780+
781+
if __name__ == "__main__":
782+
# Freeze to support parallel compilation when using spawn instead of fork
783+
multiprocessing.freeze_support()
784+
setup_package()

0 commit comments

Comments
 (0)