Skip to content

Commit 387689d

Browse files
committed
Parallel build mechanisms for faster dev builds
1 parent e145485 commit 387689d

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ def __init__(self, ext):
173173

174174
sys.argv = [a for a in sys.argv if a not in ("--no-murmur3", "--no-libev", "--no-cython", "--no-extensions")]
175175

176+
build_concurrency = int(os.environ.get('CASS_DRIVER_BUILD_CONCURRENCY', '0'))
177+
176178

177179
class build_extensions(build_ext):
178180

@@ -234,6 +236,15 @@ def run(self):
234236
sys.stderr.write('%s\n' % str(exc))
235237
warnings.warn(self.error_message % "C extensions.")
236238

239+
def build_extensions(self):
240+
if build_concurrency > 1:
241+
self.check_extensions_list(self.extensions)
242+
243+
import multiprocessing.pool
244+
multiprocessing.pool.ThreadPool(processes=build_concurrency).map(self.build_extension, self.extensions)
245+
else:
246+
build_ext.build_extensions(self)
247+
237248
def build_extension(self, ext):
238249
try:
239250
build_ext.build_extension(self, ext)
@@ -264,8 +275,9 @@ def _setup_extensions(self):
264275
[Extension('cassandra.%s' % m, ['cassandra/%s.py' % m],
265276
extra_compile_args=compile_args)
266277
for m in cython_candidates],
278+
nthreads=build_concurrency,
267279
exclude_failures=True))
268-
self.extensions.extend(cythonize("cassandra/*.pyx"))
280+
self.extensions.extend(cythonize("cassandra/*.pyx", nthreads=build_concurrency))
269281
except Exception:
270282
sys.stderr.write("Cython is not available. Not compiling core driver files as extensions (optional).")
271283

0 commit comments

Comments
 (0)