Skip to content
Snippets Groups Projects
Commit e91faa14 authored by Joseph Weston's avatar Joseph Weston
Browse files

parse cython command line args using argparse

Move custom argument parsing to a single location in main(),
which populates the appropriate global variables.
parent a07bd1fa
Branches setup-argparse
No related tags found
No related merge requests found
Pipeline #
......@@ -42,14 +42,7 @@ def configure_extensions(exts, aliases=(), build_summary=None):
This function modifies `sys.argv`.
"""
global config_file, config_file_present
#### Determine the name of the configuration file.
config_file_option = 'configfile'
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--' + config_file_option)
cmdline_args, _ = parser.parse_known_args()
config_file = getattr(cmdline_args, config_file_option) or 'build.conf'
global config_file_present
#### Read build configuration file.
configs = configparser.ConfigParser()
......@@ -156,13 +149,7 @@ def init_cython():
"""
global cythonize, cython_help
cython_option = '--cython'
required_cython_version = (0, 22)
try:
sys.argv.remove(cython_option)
cythonize = True
except ValueError:
cythonize = version_is_from_git
if cythonize:
try:
......@@ -545,6 +532,20 @@ def main():
aliases = [('mumps', 'kwant.linalg._mumps')]
# Parse custom command-line parameters
config_file_option = 'configfile'
cython_option = 'cython'
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--' + config_file_option, default='build.conf')
parser.add_argument('--' + cython_option, action='store_true',
default=version_is_from_git)
cmdline_args, _ = parser.parse_known_args()
global config_file, cythonize
config_file = getattr(cmdline_args, config_file_option)
cythonize = getattr(cmdline_args, cython_option)
init_cython()
global build_summary
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment