diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 31e794f7..89a21d2c 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -76,7 +76,7 @@ def get_python_configurations(build_selector): return [c for c in python_configurations if matches_platform(c.identifier) and build_selector(c.identifier)] -def build(opt: BuildOptions): +def build(options: BuildOptions): try: subprocess.check_call(['docker', '--version']) except Exception: @@ -86,14 +86,14 @@ def build(opt: BuildOptions): file=sys.stderr) exit(2) - python_configurations = get_python_configurations(opt.build_selector) + python_configurations = get_python_configurations(options.build_selector) platforms = [ - ('cp', 'manylinux_x86_64', opt.manylinux_images['x86_64']), - ('cp', 'manylinux_i686', opt.manylinux_images['i686']), - ('cp', 'manylinux_aarch64', opt.manylinux_images['aarch64']), - ('cp', 'manylinux_ppc64le', opt.manylinux_images['ppc64le']), - ('cp', 'manylinux_s390x', opt.manylinux_images['s390x']), - ('pp', 'manylinux_x86_64', opt.manylinux_images['pypy_x86_64']), + ('cp', 'manylinux_x86_64', options.manylinux_images['x86_64']), + ('cp', 'manylinux_i686', options.manylinux_images['i686']), + ('cp', 'manylinux_aarch64', options.manylinux_images['aarch64']), + ('cp', 'manylinux_ppc64le', options.manylinux_images['ppc64le']), + ('cp', 'manylinux_s390x', options.manylinux_images['s390x']), + ('pp', 'manylinux_x86_64', options.manylinux_images['pypy_x86_64']), ] for implementation, platform_tag, docker_image in platforms: @@ -112,14 +112,14 @@ def build(opt: BuildOptions): '/bin/bash']) call(['docker', 'cp', - os.path.abspath(opt.project_dir) + '/.', + os.path.abspath(options.project_dir) + '/.', container_name + ':/project']) call(['docker', 'start', container_name]) for config in platform_configs: - if opt.dependency_constraints: - constraints_file = opt.dependency_constraints.get_for_python_version(config.version) + if options.dependency_constraints: + constraints_file = options.dependency_constraints.get_for_python_version(config.version) # `docker cp` causes 'no space left on device' error when # a container is running and the host filesystem is @@ -234,32 +234,32 @@ def build(opt: BuildOptions): done '''.format( config_python_bin=config.path + '/bin', - test_requires=' '.join(opt.test_requires), - test_extras=opt.test_extras, + test_requires=' '.join(options.test_requires), + test_extras=options.test_extras, test_command=shlex.quote( - prepare_command(opt.test_command, project='/project') if opt.test_command else '' + prepare_command(options.test_command, project='/project') if options.test_command else '' ), before_build=shlex.quote( - prepare_command(opt.before_build, project='/project') if opt.before_build else '' + prepare_command(options.before_build, project='/project') if options.before_build else '' ), - build_verbosity_flag=' '.join(get_build_verbosity_extra_flags(opt.build_verbosity)), + build_verbosity_flag=' '.join(get_build_verbosity_extra_flags(options.build_verbosity)), repair_command=shlex.quote( - prepare_command(opt.repair_command, wheel='"$1"', dest_dir='/tmp/repaired_wheels') if opt.repair_command else '' + prepare_command(options.repair_command, wheel='"$1"', dest_dir='/tmp/repaired_wheels') if options.repair_command else '' ), - environment_exports='\n'.join(opt.environment.as_shell_commands()), + environment_exports='\n'.join(options.environment.as_shell_commands()), uid=os.getuid(), gid=os.getgid(), before_test=shlex.quote( - prepare_command(opt.before_test, project='/project') if opt.before_test else '' + prepare_command(options.before_test, project='/project') if options.before_test else '' ), - dependency_install_flags='-c /constraints.txt' if opt.dependency_constraints else '', + dependency_install_flags='-c /constraints.txt' if options.dependency_constraints else '', ) ) # copy the output back into the host call(['docker', 'cp', container_name + ':/output/.', - os.path.abspath(opt.output_dir)]) + os.path.abspath(options.output_dir)]) except subprocess.CalledProcessError: exit(1) finally: diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 30d02558..d0d264c6 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -167,48 +167,48 @@ def setup_python(python_configuration, dependency_constraint_flags, environment) return env -def build(opt: BuildOptions): - abs_project_dir = os.path.abspath(opt.project_dir) +def build(options: BuildOptions): + abs_project_dir = os.path.abspath(options.project_dir) temp_dir = tempfile.mkdtemp(prefix='cibuildwheel') built_wheel_dir = os.path.join(temp_dir, 'built_wheel') repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel') - python_configurations = get_python_configurations(opt.build_selector) + python_configurations = get_python_configurations(options.build_selector) for config in python_configurations: dependency_constraint_flags = [] - if opt.dependency_constraints: + if options.dependency_constraints: dependency_constraint_flags = [ - '-c', opt.dependency_constraints.get_for_python_version(config.version) + '-c', options.dependency_constraints.get_for_python_version(config.version) ] - env = setup_python(config, dependency_constraint_flags, opt.environment) + env = setup_python(config, dependency_constraint_flags, options.environment) # run the before_build command - if opt.before_build: - before_build_prepared = prepare_command(opt.before_build, project=abs_project_dir) + if options.before_build: + before_build_prepared = prepare_command(options.before_build, project=abs_project_dir) call(before_build_prepared, env=env, shell=True) # build the wheel if os.path.exists(built_wheel_dir): shutil.rmtree(built_wheel_dir) os.makedirs(built_wheel_dir) - call(['pip', 'wheel', abs_project_dir, '-w', built_wheel_dir, '--no-deps'] + get_build_verbosity_extra_flags(opt.build_verbosity), env=env) + call(['pip', 'wheel', abs_project_dir, '-w', built_wheel_dir, '--no-deps'] + get_build_verbosity_extra_flags(options.build_verbosity), env=env) built_wheel = glob(os.path.join(built_wheel_dir, '*.whl'))[0] # repair the wheel if os.path.exists(repaired_wheel_dir): shutil.rmtree(repaired_wheel_dir) os.makedirs(repaired_wheel_dir) - if built_wheel.endswith('none-any.whl') or not opt.repair_command: + if built_wheel.endswith('none-any.whl') or not options.repair_command: # pure Python wheel or empty repair command shutil.move(built_wheel, repaired_wheel_dir) else: - repair_command_prepared = prepare_command(opt.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir) + repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir) call(repair_command_prepared, env=env, shell=True) repaired_wheel = glob(os.path.join(repaired_wheel_dir, '*.whl'))[0] - if opt.test_command: + if options.test_command: # set up a virtual environment to install and test from, to make sure # there are no dependencies that were pulled in at build time. call(['pip', 'install', 'virtualenv'] + dependency_constraint_flags, env=env) @@ -228,26 +228,26 @@ def build(opt: BuildOptions): # check that we are using the Python from the virtual environment call(['which', 'python'], env=virtualenv_env) - if opt.before_test: - before_test_prepared = prepare_command(opt.before_test, project=abs_project_dir) + if options.before_test: + before_test_prepared = prepare_command(options.before_test, project=abs_project_dir) call(before_test_prepared, env=virtualenv_env, shell=True) # install the wheel - call(['pip', 'install', repaired_wheel + opt.test_extras], env=virtualenv_env) + call(['pip', 'install', repaired_wheel + options.test_extras], env=virtualenv_env) # test the wheel - if opt.test_requires: - call(['pip', 'install'] + opt.test_requires, env=virtualenv_env) + if options.test_requires: + call(['pip', 'install'] + options.test_requires, env=virtualenv_env) # run the tests from $HOME, with an absolute path in the command # (this ensures that Python runs the tests against the installed wheel # and not the repo code) - test_command_prepared = prepare_command(opt.test_command, project=abs_project_dir) + test_command_prepared = prepare_command(options.test_command, project=abs_project_dir) call(test_command_prepared, cwd=os.environ['HOME'], env=virtualenv_env, shell=True) # clean up shutil.rmtree(venv_dir) # we're all done here; move it to output (overwrite existing) - dst = os.path.join(opt.output_dir, os.path.basename(repaired_wheel)) + dst = os.path.join(options.output_dir, os.path.basename(repaired_wheel)) shutil.move(repaired_wheel, dst) diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index f720786c..db5fc48a 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -142,8 +142,8 @@ def setup_python(python_configuration, dependency_constraint_flags, environment) return env -def build(opt: BuildOptions): - abs_project_dir = os.path.abspath(opt.project_dir) +def build(options: BuildOptions): + abs_project_dir = os.path.abspath(options.project_dir) temp_dir = tempfile.mkdtemp(prefix='cibuildwheel') built_wheel_dir = os.path.join(temp_dir, 'built_wheel') repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel') @@ -152,42 +152,42 @@ def build(opt: BuildOptions): nuget = 'C:\\cibw\\nuget.exe' download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget) - python_configurations = get_python_configurations(opt.build_selector) + python_configurations = get_python_configurations(options.build_selector) for config in python_configurations: dependency_constraint_flags = [] - if opt.dependency_constraints: + if options.dependency_constraints: dependency_constraint_flags = [ - '-c', opt.dependency_constraints.get_for_python_version(config.version) + '-c', options.dependency_constraints.get_for_python_version(config.version) ] # install Python - env = setup_python(config, dependency_constraint_flags, opt.environment) + env = setup_python(config, dependency_constraint_flags, options.environment) # run the before_build command - if opt.before_build: - before_build_prepared = prepare_command(opt.before_build, project=abs_project_dir) + if options.before_build: + before_build_prepared = prepare_command(options.before_build, project=abs_project_dir) shell([before_build_prepared], env=env) # build the wheel if os.path.exists(built_wheel_dir): shutil.rmtree(built_wheel_dir) os.makedirs(built_wheel_dir) - shell(['pip', 'wheel', abs_project_dir, '-w', built_wheel_dir, '--no-deps'] + get_build_verbosity_extra_flags(opt.build_verbosity), env=env) + shell(['pip', 'wheel', abs_project_dir, '-w', built_wheel_dir, '--no-deps'] + get_build_verbosity_extra_flags(options.build_verbosity), env=env) built_wheel = glob(os.path.join(built_wheel_dir, '*.whl'))[0] # repair the wheel if os.path.exists(repaired_wheel_dir): shutil.rmtree(repaired_wheel_dir) os.makedirs(repaired_wheel_dir) - if built_wheel.endswith('none-any.whl') or not opt.repair_command: + if built_wheel.endswith('none-any.whl') or not options.repair_command: # pure Python wheel or empty repair command shutil.move(built_wheel, repaired_wheel_dir) else: - repair_command_prepared = prepare_command(opt.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir) + repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir) shell([repair_command_prepared], env=env) repaired_wheel = glob(os.path.join(repaired_wheel_dir, '*.whl'))[0] - if opt.test_command: + if options.test_command: # set up a virtual environment to install and test from, to make sure # there are no dependencies that were pulled in at build time. shell(['pip', 'install', 'virtualenv'] + dependency_constraint_flags, env=env) @@ -212,28 +212,28 @@ def build(opt: BuildOptions): # check that we are using the Python from the virtual environment shell(['which', 'python'], env=virtualenv_env) - if opt.before_test: - before_test_prepared = prepare_command(opt.before_test, project=abs_project_dir) + if options.before_test: + before_test_prepared = prepare_command(options.before_test, project=abs_project_dir) shell([before_test_prepared], env=virtualenv_env) # install the wheel - shell(['pip', 'install', repaired_wheel + opt.test_extras], env=virtualenv_env) + shell(['pip', 'install', repaired_wheel + options.test_extras], env=virtualenv_env) # test the wheel - if opt.test_requires: - shell(['pip', 'install'] + opt.test_requires, env=virtualenv_env) + if options.test_requires: + shell(['pip', 'install'] + options.test_requires, env=virtualenv_env) # run the tests from c:\, with an absolute path in the command # (this ensures that Python runs the tests against the installed wheel # and not the repo code) - test_command_prepared = prepare_command(opt.test_command, project=abs_project_dir) + test_command_prepared = prepare_command(options.test_command, project=abs_project_dir) shell([test_command_prepared], cwd='c:\\', env=virtualenv_env) # clean up shutil.rmtree(venv_dir) # we're all done here; move it to output (remove if already exists) - dst = os.path.join(opt.output_dir, os.path.basename(repaired_wheel)) + dst = os.path.join(options.output_dir, os.path.basename(repaired_wheel)) if os.path.isfile(dst): os.remove(dst) shutil.move(repaired_wheel, dst)