|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | import os |
16 | | -import shutil |
17 | 16 | import sys |
18 | 17 | import json |
19 | 18 | import warnings |
@@ -201,8 +200,6 @@ def eval_env_var_as_array(varname): |
201 | 200 | try_murmur3 = try_extensions and "--no-murmur3" not in sys.argv |
202 | 201 | try_libev = try_extensions and "--no-libev" not in sys.argv and not is_pypy and not os.environ.get('CASS_DRIVER_NO_LIBEV') |
203 | 202 | try_cython = try_extensions and "--no-cython" not in sys.argv and not is_pypy and not os.environ.get('CASS_DRIVER_NO_CYTHON') |
204 | | -try_cython &= 'egg_info' not in sys.argv # bypass setup_requires for pip egg_info calls, which will never have --install-option"--no-cython" coming fomr pip |
205 | | - |
206 | 203 | sys.argv = [a for a in sys.argv if a not in ("--no-murmur3", "--no-libev", "--no-cython", "--no-extensions")] |
207 | 204 |
|
208 | 205 | build_concurrency = int(os.environ.get('CASS_DRIVER_BUILD_CONCURRENCY', '0')) |
@@ -358,80 +355,12 @@ def fix_extension_class(ext: Extension) -> Extension: |
358 | 355 | return ext |
359 | 356 |
|
360 | 357 |
|
361 | | -def pre_build_check(): |
362 | | - """ |
363 | | - Try to verify build tools |
364 | | - """ |
365 | | - if os.environ.get('CASS_DRIVER_NO_PRE_BUILD_CHECK'): |
366 | | - return True |
367 | | - |
368 | | - try: |
369 | | - from setuptools._distutils.ccompiler import new_compiler |
370 | | - from setuptools._distutils.sysconfig import customize_compiler |
371 | | - from setuptools.dist import Distribution |
372 | | - |
373 | | - # base build_ext just to emulate compiler option setup |
374 | | - be = build_ext(Distribution()) |
375 | | - be.initialize_options() |
376 | | - be.finalize_options() |
377 | | - |
378 | | - # First, make sure we have a Python include directory |
379 | | - have_python_include = any(os.path.isfile(os.path.join(p, 'Python.h')) for p in be.include_dirs) |
380 | | - if not have_python_include: |
381 | | - sys.stderr.write("Did not find 'Python.h' in %s.\n" % (be.include_dirs,)) |
382 | | - return False |
383 | | - |
384 | | - compiler = new_compiler(compiler=be.compiler) |
385 | | - customize_compiler(compiler) |
386 | | - |
387 | | - try: |
388 | | - # We must be able to initialize the compiler if it has that method |
389 | | - if hasattr(compiler, "initialize"): |
390 | | - compiler.initialize() |
391 | | - except: |
392 | | - return False |
393 | | - |
394 | | - executables = [] |
395 | | - if compiler.compiler_type in ('unix', 'cygwin'): |
396 | | - executables = [compiler.executables[exe][0] for exe in ('compiler_so', 'linker_so')] |
397 | | - elif compiler.compiler_type == 'nt': |
398 | | - executables = [getattr(compiler, exe) for exe in ('cc', 'linker')] |
399 | | - |
400 | | - if executables: |
401 | | - for exe in executables: |
402 | | - if not shutil.which(exe): |
403 | | - sys.stderr.write("Failed to find %s for compiler type %s.\n" % (exe, compiler.compiler_type)) |
404 | | - return False |
405 | | - |
406 | | - except Exception as exc: |
407 | | - sys.stderr.write('%s\n' % str(exc)) |
408 | | - sys.stderr.write("Failed pre-build check. Attempting anyway.\n") |
409 | | - |
410 | | - # if we are unable to positively id the compiler type, or one of these assumptions fails, |
411 | | - # just proceed as we would have without the check |
412 | | - return True |
413 | | - |
414 | | - |
415 | 358 | def run_setup(extensions): |
416 | 359 |
|
417 | 360 | kw = {'cmdclass': {'doc': DocCommand}} |
418 | 361 | kw['cmdclass']['build_ext'] = build_extensions |
419 | 362 | kw['ext_modules'] = [Extension('DUMMY', [])] # dummy extension makes sure build_ext is called for install |
420 | 363 |
|
421 | | - if try_cython: |
422 | | - # precheck compiler before adding to setup_requires |
423 | | - # we don't actually negate try_cython because: |
424 | | - # 1.) build_ext eats errors at compile time, letting the install complete while producing useful feedback |
425 | | - # 2.) there could be a case where the python environment has cython installed but the system doesn't have build tools |
426 | | - if pre_build_check(): |
427 | | - cython_dep = 'Cython>=3.0.11,<4' |
428 | | - user_specified_cython_version = os.environ.get('CASS_DRIVER_ALLOWED_CYTHON_VERSION') |
429 | | - if user_specified_cython_version is not None: |
430 | | - cython_dep = 'Cython==%s' % (user_specified_cython_version,) |
431 | | - kw['setup_requires'] = [cython_dep] |
432 | | - else: |
433 | | - sys.stderr.write("Bypassing Cython setup requirement\n") |
434 | | - |
435 | 364 | setup(**kw) |
436 | 365 |
|
437 | 366 | run_setup(None) |
|
0 commit comments