diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2022-08-03 10:53:28 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2022-08-03 10:53:57 +0200 |
commit | 5fbac16da26e1cbddeafd9fa9c98d31ce8b5e19d (patch) | |
tree | b13e727f5f563ff5294e9ba234a503052fc486bb /setup.py | |
parent | d1db86b1e2560afe2e0ec4ce7d6c25628023e16b (diff) | |
download | cython-5fbac16da26e1cbddeafd9fa9c98d31ce8b5e19d.tar.gz |
Allow passing Cython build options via env vars, not only via CLI.
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 42 |
1 files changed, 16 insertions, 26 deletions
@@ -183,37 +183,27 @@ def compile_cython_modules(profile=False, coverage=False, compile_minimal=False, setup_args['ext_modules'] = extensions -cython_profile = '--cython-profile' in sys.argv -if cython_profile: - sys.argv.remove('--cython-profile') +def check_option(name): + cli_arg = "--" + name + if cli_arg in sys.argv: + sys.argv.remove(cli_arg) + return True -cython_coverage = '--cython-coverage' in sys.argv -if cython_coverage: - sys.argv.remove('--cython-coverage') + env_var = name.replace("-", "_").upper() + if os.environ.get(env_var) == "true": + return True -try: - sys.argv.remove("--cython-compile-all") - cython_compile_more = True -except ValueError: - cython_compile_more = False + return False -try: - sys.argv.remove("--cython-compile-minimal") - cython_compile_minimal = True -except ValueError: - cython_compile_minimal = False -try: - sys.argv.remove("--cython-with-refnanny") - cython_with_refnanny = True -except ValueError: - cython_with_refnanny = False +cython_profile = check_option('cython-profile') +cython_coverage = check_option('cython-coverage') +cython_with_refnanny = check_option('cython-with-refnanny') -try: - sys.argv.remove("--no-cython-compile") - compile_cython_itself = False -except ValueError: - compile_cython_itself = True +compile_cython_itself = not check_option('no-cython-compile') +if compile_cython_itself: + cython_compile_more = check_option('cython-compile-all') + cython_compile_minimal = check_option('cython-compile-minimal') setup_args.update(setuptools_extra_args) |