From a4602c32dd72874152f528781f6db2de4850d53c Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 6 Apr 2020 16:55:15 +0200 Subject: [PATCH] move calculate constraints outside python setup --- cibuildwheel/macos.py | 19 ++++++++++--------- cibuildwheel/windows.py | 18 +++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index d6511c2e..714e37e5 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -108,7 +108,7 @@ def install_pypy(version, url): return installation_bin_path -def setup_python(python_configuration, dependency_constraints, environment): +def setup_python(python_configuration, dependency_constraint_flags, environment): if python_configuration.identifier.startswith('cp'): installation_bin_path = install_cpython(python_configuration.version, python_configuration.url) elif python_configuration.identifier.startswith('pp'): @@ -140,12 +140,6 @@ def setup_python(python_configuration, dependency_constraints, environment): print("cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.", file=sys.stderr) exit(1) - dependency_constraint_flags = [] - if dependency_constraints: - dependency_constraint_flags = [ - '-c', dependency_constraints.get_for_python_version(python_configuration.version) - ] - # install pip & wheel call(['python', get_pip_script] + dependency_constraint_flags, env=env, cwd="/tmp") assert os.path.exists(os.path.join(installation_bin_path, 'pip')) @@ -168,7 +162,7 @@ def setup_python(python_configuration, dependency_constraints, environment): if 'MACOSX_DEPLOYMENT_TARGET' not in env: env['MACOSX_DEPLOYMENT_TARGET'] = '10.9' - return env, dependency_constraint_flags + return env def build(project_dir, output_dir, test_command, before_test, test_requires, test_extras, before_build, build_verbosity, build_selector, repair_command, environment, dependency_constraints): @@ -180,7 +174,14 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes python_configurations = get_python_configurations(build_selector) for config in python_configurations: - env, dependency_constraint_flags = setup_python(config, dependency_constraints, environment) + + dependency_constraint_flags = [] + if dependency_constraints: + dependency_constraint_flags = [ + '-c', dependency_constraints.get_for_python_version(config.version) + ] + + env = setup_python(config, dependency_constraint_flags, environment) # run the before_build command diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 5d340207..11cc33f1 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -89,7 +89,7 @@ def install_pypy(version, arch, url): return installation_path -def setup_python(python_configuration, dependency_constraints, environment): +def setup_python(python_configuration, dependency_constraint_flags, environment): nuget = 'C:\\cibw\\nuget.exe' if not os.path.exists(nuget): download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget) @@ -124,12 +124,6 @@ def setup_python(python_configuration, dependency_constraints, environment): print("cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.", file=sys.stderr) exit(1) - dependency_constraint_flags = [] - if dependency_constraints: - dependency_constraint_flags = [ - '-c', dependency_constraints.get_for_python_version(python_configuration.version) - ] - # make sure pip is installed if not os.path.exists(os.path.join(installation_path, 'Scripts', 'pip.exe')): shell(['python', get_pip_script] + dependency_constraint_flags, env=env, cwd="C:\\cibw") @@ -144,7 +138,7 @@ def setup_python(python_configuration, dependency_constraints, environment): shell(['pip', '--version'], env=env) shell(['pip', 'install', '--upgrade', 'setuptools', 'wheel'] + dependency_constraint_flags, env=env) - return env, dependency_constraint_flags + return env def build(project_dir, output_dir, test_command, before_test, test_requires, test_extras, before_build, build_verbosity, build_selector, repair_command, environment, dependency_constraints): @@ -159,8 +153,14 @@ def build(project_dir, output_dir, test_command, before_test, test_requires, tes python_configurations = get_python_configurations(build_selector) for config in python_configurations: + dependency_constraint_flags = [] + if dependency_constraints: + dependency_constraint_flags = [ + '-c', dependency_constraints.get_for_python_version(config.version) + ] + # install Python - env, dependency_constraint_flags = setup_python(config, dependency_constraints, environment) + env = setup_python(config, dependency_constraint_flags, environment) # run the before_build command if before_build: