From 8b465bc94a9c006e1d800588bdac118c8a3ba7d3 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Sun, 5 Apr 2020 16:03:35 +0200 Subject: [PATCH 1/9] move python setup to separated function --- cibuildwheel/macos.py | 121 +++++++++++++++++++++------------------- cibuildwheel/windows.py | 108 +++++++++++++++++++---------------- 2 files changed, 123 insertions(+), 106 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 04fa0d84..d6511c2e 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -108,6 +108,69 @@ def install_pypy(version, url): return installation_bin_path +def setup_python(python_configuration, dependency_constraints, environment): + if python_configuration.identifier.startswith('cp'): + installation_bin_path = install_cpython(python_configuration.version, python_configuration.url) + elif python_configuration.identifier.startswith('pp'): + installation_bin_path = install_pypy(python_configuration.version, python_configuration.url) + else: + raise ValueError("Unknown Python implementation") + + env = os.environ.copy() + env['PATH'] = os.pathsep.join([ + SYMLINKS_DIR, + installation_bin_path, + env['PATH'], + ]) + + # Fix issue with site.py setting the wrong `sys.prefix`, `sys.exec_prefix`, + # `sys.path`, ... for PyPy: https://foss.heptapod.net/pypy/pypy/issues/3175 + # Also fix an issue with the shebang of installed scripts inside the + # testing virtualenv- see https://github.com/theacodes/nox/issues/44 and + # https://github.com/pypa/virtualenv/issues/620 + # Also see https://github.com/python/cpython/pull/9516 + env.pop('__PYVENV_LAUNCHER__', None) + env = environment.as_dictionary(prev_environment=env) + + # check what version we're on + call(['which', 'python'], env=env) + call(['python', '--version'], env=env) + which_python = subprocess.check_output(['which', 'python'], env=env, universal_newlines=True).strip() + if which_python != '/tmp/cibw_bin/python': + 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')) + call(['which', 'pip'], env=env) + call(['pip', '--version'], env=env) + which_pip = subprocess.check_output(['which', 'pip'], env=env, universal_newlines=True).strip() + if which_pip != '/tmp/cibw_bin/pip': + print("cibuildwheel: pip 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 pip above it.", file=sys.stderr) + exit(1) + call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', 'delocate'] + dependency_constraint_flags, env=env) + + # setup target platform, only required for python 3.5 + if python_configuration.version == '3.5': + if '_PYTHON_HOST_PLATFORM' not in env: + # cross-compilation platform override + env['_PYTHON_HOST_PLATFORM'] = 'macosx-10.9-x86_64' + if 'ARCHFLAGS' not in env: + # https://github.com/python/cpython/blob/a5ed2fe0eedefa1649aa93ee74a0bafc8e628a10/Lib/_osx_support.py#L260 + env['ARCHFLAGS'] = '-arch x86_64' + if 'MACOSX_DEPLOYMENT_TARGET' not in env: + env['MACOSX_DEPLOYMENT_TARGET'] = '10.9' + + return env, dependency_constraint_flags + + 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): abs_project_dir = os.path.abspath(project_dir) temp_dir = tempfile.mkdtemp(prefix='cibuildwheel') @@ -117,64 +180,8 @@ 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: - if config.identifier.startswith('cp'): - installation_bin_path = install_cpython(config.version, config.url) - elif config.identifier.startswith('pp'): - installation_bin_path = install_pypy(config.version, config.url) - else: - raise ValueError("Unknown Python implementation") + env, dependency_constraint_flags = setup_python(config, dependency_constraints, environment) - env = os.environ.copy() - env['PATH'] = os.pathsep.join([ - SYMLINKS_DIR, - installation_bin_path, - env['PATH'], - ]) - - # Fix issue with site.py setting the wrong `sys.prefix`, `sys.exec_prefix`, - # `sys.path`, ... for PyPy: https://foss.heptapod.net/pypy/pypy/issues/3175 - # Also fix an issue with the shebang of installed scripts inside the - # testing virtualenv- see https://github.com/theacodes/nox/issues/44 and - # https://github.com/pypa/virtualenv/issues/620 - # Also see https://github.com/python/cpython/pull/9516 - env.pop('__PYVENV_LAUNCHER__', None) - env = environment.as_dictionary(prev_environment=env) - - # check what version we're on - call(['which', 'python'], env=env) - call(['python', '--version'], env=env) - which_python = subprocess.check_output(['which', 'python'], env=env, universal_newlines=True).strip() - if which_python != '/tmp/cibw_bin/python': - 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(config.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')) - call(['which', 'pip'], env=env) - call(['pip', '--version'], env=env) - which_pip = subprocess.check_output(['which', 'pip'], env=env, universal_newlines=True).strip() - if which_pip != '/tmp/cibw_bin/pip': - print("cibuildwheel: pip 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 pip above it.", file=sys.stderr) - exit(1) - call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', 'delocate'] + dependency_constraint_flags, env=env) - - # setup target platform, only required for python 3.5 - if config.version == '3.5': - if '_PYTHON_HOST_PLATFORM' not in env: - # cross-compilation platform override - env['_PYTHON_HOST_PLATFORM'] = 'macosx-10.9-x86_64' - if 'ARCHFLAGS' not in env: - # https://github.com/python/cpython/blob/a5ed2fe0eedefa1649aa93ee74a0bafc8e628a10/Lib/_osx_support.py#L260 - env['ARCHFLAGS'] = '-arch x86_64' - if 'MACOSX_DEPLOYMENT_TARGET' not in env: - env['MACOSX_DEPLOYMENT_TARGET'] = '10.9' # run the before_build command if before_build: diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 4aadd6d2..5d340207 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -89,6 +89,64 @@ def install_pypy(version, arch, url): return installation_path +def setup_python(python_configuration, dependency_constraints, environment): + nuget = 'C:\\cibw\\nuget.exe' + if not os.path.exists(nuget): + download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget) + + if python_configuration.identifier.startswith('cp'): + installation_path = install_cpython(python_configuration.version, python_configuration.arch, nuget) + elif python_configuration.identifier.startswith('pp'): + installation_path = install_pypy(python_configuration.version, python_configuration.arch, python_configuration.url) + else: + raise ValueError("Unknown Python implementation") + + assert os.path.exists(os.path.join(installation_path, 'python.exe')) + + # set up PATH and environment variables for run_with_env + env = os.environ.copy() + env['PYTHON_VERSION'] = python_configuration.version + env['PYTHON_ARCH'] = python_configuration.arch + env['PATH'] = os.pathsep.join([ + installation_path, + os.path.join(installation_path, 'Scripts'), + env['PATH'] + ]) + # update env with results from CIBW_ENVIRONMENT + env = environment.as_dictionary(prev_environment=env) + + # for the logs - check we're running the right version of python + shell(['where', 'python'], env=env) + shell(['python', '--version'], env=env) + shell(['python', '-c', '"import struct; print(struct.calcsize(\'P\') * 8)"'], env=env) + where_python = subprocess.check_output(['where', 'python'], env=env, universal_newlines=True).splitlines()[0].strip() + if where_python != os.path.join(installation_path, 'python.exe'): + 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") + assert os.path.exists(os.path.join(installation_path, 'Scripts', 'pip.exe')) + where_pip = subprocess.check_output(['where', 'pip'], env=env, universal_newlines=True).splitlines()[0].strip() + if where_pip.strip() != os.path.join(installation_path, 'Scripts', 'pip.exe'): + print("cibuildwheel: pip 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 pip above it.", file=sys.stderr) + exit(1) + + # prepare the Python environment + shell(['python', '-m', 'pip', 'install', '--upgrade', 'pip'] + dependency_constraint_flags, env=env) + shell(['pip', '--version'], env=env) + shell(['pip', 'install', '--upgrade', 'setuptools', 'wheel'] + dependency_constraint_flags, env=env) + + return env, dependency_constraint_flags + + 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): abs_project_dir = os.path.abspath(project_dir) temp_dir = tempfile.mkdtemp(prefix='cibuildwheel') @@ -102,55 +160,7 @@ 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: # install Python - if config.identifier.startswith('cp'): - installation_path = install_cpython(config.version, config.arch, nuget) - elif config.identifier.startswith('pp'): - installation_path = install_pypy(config.version, config.arch, config.url) - else: - raise ValueError("Unknown Python implementation") - - assert os.path.exists(os.path.join(installation_path, 'python.exe')) - - # set up PATH and environment variables for run_with_env - env = os.environ.copy() - env['PYTHON_VERSION'] = config.version - env['PYTHON_ARCH'] = config.arch - env['PATH'] = os.pathsep.join([ - installation_path, - os.path.join(installation_path, 'Scripts'), - env['PATH'] - ]) - # update env with results from CIBW_ENVIRONMENT - env = environment.as_dictionary(prev_environment=env) - - # for the logs - check we're running the right version of python - shell(['where', 'python'], env=env) - shell(['python', '--version'], env=env) - shell(['python', '-c', '"import struct; print(struct.calcsize(\'P\') * 8)"'], env=env) - where_python = subprocess.check_output(['where', 'python'], env=env, universal_newlines=True).splitlines()[0].strip() - if where_python != os.path.join(installation_path, 'python.exe'): - 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(config.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") - assert os.path.exists(os.path.join(installation_path, 'Scripts', 'pip.exe')) - where_pip = subprocess.check_output(['where', 'pip'], env=env, universal_newlines=True).splitlines()[0].strip() - if where_pip.strip() != os.path.join(installation_path, 'Scripts', 'pip.exe'): - print("cibuildwheel: pip 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 pip above it.", file=sys.stderr) - exit(1) - - # prepare the Python environment - shell(['python', '-m', 'pip', 'install', '--upgrade', 'pip'] + dependency_constraint_flags, env=env) - shell(['pip', '--version'], env=env) - shell(['pip', 'install', '--upgrade', 'setuptools', 'wheel'] + dependency_constraint_flags, env=env) + env, dependency_constraint_flags = setup_python(config, dependency_constraints, environment) # run the before_build command if before_build: From 8986b2d468f6266d6109e8c8b3374d13740e212d Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 6 Apr 2020 11:13:27 +0100 Subject: [PATCH 2/9] Add dependency update script --- bin/make_dependency_update_pr.py | 75 +++++++++++++++++++ ..._constraints.py => update_dependencies.py} | 0 requirements-dev.txt | 1 + 3 files changed, 76 insertions(+) create mode 100755 bin/make_dependency_update_pr.py rename bin/{update_constraints.py => update_dependencies.py} (100%) diff --git a/bin/make_dependency_update_pr.py b/bin/make_dependency_update_pr.py new file mode 100755 index 00000000..d24295a5 --- /dev/null +++ b/bin/make_dependency_update_pr.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 + +import os +import time +from pathlib import Path +from subprocess import run + +import click +import textwrap + + +def shell(cmd, **kwargs): + return run([cmd], shell=True, **kwargs) + + +def git_repo_has_changes(): + unstaged_changes = shell('git diff-index --quiet HEAD --').returncode != 0 + staged_changes = shell('git diff-index --quiet --cached HEAD --').returncode != 0 + return unstaged_changes or staged_changes + + +@click.command() +def main(force): + project_root = Path(__file__).parent / '..' + os.chdir(project_root) + + if git_repo_has_changes() and not force: + print('Your git repo has uncommitted changes. Commit or stash before continuing.') + exit(1) + + previous_branch = shell('git rev-parse --abbrev-ref HEAD', + check=True, + capture_output=True, + encoding='utf8').stdout.strip() + + shell('git fetch origin', check=True) + + timestamp = time.strftime('%Y-%m-%dT%H-%M-%S', time.gmtime()) + branch_name = f'update-constraints-{timestamp}' + + shell(f'git checkout -b {branch_name} origin/master', check=True) + + try: + shell('bin/update_constraints.py', check=True) + + if not git_repo_has_changes(): + print('Done: no constraint updates required.') + return + + shell('git commit -a -m "Update dependencies"', check=True) + run( + [ + 'gh', 'pr', 'create', + '--repo', 'joerick/cibuildwheel', + '--base', 'master', + '--title', 'Update dependencies', + '--body', textwrap.dedent(f''' + Update the versions of our dependencies. + + PR generated by `{os.path.basename(__file__)}`. + ''') + ], + check=True + ) + + print('Done.') + finally: + # remove any local changes + shell('git checkout -- .') + shell(f'git checkout {previous_branch}', check=True) + shell(f'git branch -D --force {branch_name}', check=True) + + +if __name__ == '__main__': + main.main(standalone_mode=True) diff --git a/bin/update_constraints.py b/bin/update_dependencies.py similarity index 100% rename from bin/update_constraints.py rename to bin/update_dependencies.py diff --git a/requirements-dev.txt b/requirements-dev.txt index df361eba..f838e3f2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,3 +4,4 @@ pytest mkdocs==1.0.4 pip-tools requests +click From e78a731e2d7a7fcbcadbdf886ecf40b4853bb761 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 6 Apr 2020 11:47:23 +0100 Subject: [PATCH 3/9] Fix bug in Docker pin script causing the latest tag to be pinned --- bin/update_dependencies.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/update_dependencies.py b/bin/update_dependencies.py index 50aaf515..ff7d511c 100755 --- a/bin/update_dependencies.py +++ b/bin/update_dependencies.py @@ -84,7 +84,9 @@ for image in images: digest = latest_tag['images'][0]['digest'] pinned_tag = next( - tag for tag in tags if tag['images'][0]['digest'] == digest + tag + for tag in tags + if tag != latest_tag and tag['images'][0]['digest'] == digest ) tag_name = pinned_tag['name'] From 90634ed8725cd6be7c8d95ee23d70357cea0f690 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 6 Apr 2020 11:50:30 +0100 Subject: [PATCH 4/9] Fix flake8 exclude list --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index b2c53158..c5d51ac7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,5 +8,6 @@ exclude = .git/, env/, env2/, + env??/, .venv/, site/ From ea6ada07286dcc8a0e7dff04495632235297aa06 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 6 Apr 2020 11:52:21 +0100 Subject: [PATCH 5/9] Fix update deps script bugs --- bin/make_dependency_update_pr.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/make_dependency_update_pr.py b/bin/make_dependency_update_pr.py index d24295a5..adfb21e0 100755 --- a/bin/make_dependency_update_pr.py +++ b/bin/make_dependency_update_pr.py @@ -20,11 +20,11 @@ def git_repo_has_changes(): @click.command() -def main(force): +def main(): project_root = Path(__file__).parent / '..' os.chdir(project_root) - if git_repo_has_changes() and not force: + if git_repo_has_changes(): print('Your git repo has uncommitted changes. Commit or stash before continuing.') exit(1) @@ -41,7 +41,7 @@ def main(force): shell(f'git checkout -b {branch_name} origin/master', check=True) try: - shell('bin/update_constraints.py', check=True) + shell('bin/update_dependencies.py', check=True) if not git_repo_has_changes(): print('Done: no constraint updates required.') From 3018e7a1f86e5dfb2646cbe792f103b9da88fb8f Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 6 Apr 2020 23:10:19 +0100 Subject: [PATCH 6/9] Refactor expected_wheels function --- test/shared/utils.py | 79 ++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/test/shared/utils.py b/test/shared/utils.py index 862d4466..9c5ecfcb 100644 --- a/test/shared/utils.py +++ b/test/shared/utils.py @@ -81,60 +81,61 @@ def expected_wheels(package_name, package_version, manylinux_versions=None, # {python tag} and {abi tag} are closely related to the python interpreter used to build the wheel # so we'll merge them below as python_abi_tag - python_abi_tags = ['cp35-cp35m', 'cp36-cp36m', 'cp37-cp37m', 'cp38-cp38'] - extra_x86_python_abi_tags = ['cp27-cp27m', 'pp27-pypy_73', 'pp36-pypy36_pp73'] - - if platform == 'linux': - if pm.machine() not in ['x86_64', 'i686']: - if manylinux_versions is None: - manylinux_versions = ['manylinux2014'] - architectures = {'cp': [pm.machine()]} + if manylinux_versions is None: + if pm.machine() == 'x86_64': + manylinux_versions = ['manylinux1', 'manylinux2010'] else: - if manylinux_versions is None: - manylinux_versions = ['manylinux1', 'manylinux2010'] - python_abi_tags += extra_x86_python_abi_tags + manylinux_versions = ['manylinux2014'] + + python_abi_tags = ['cp35-cp35m', 'cp36-cp36m', 'cp37-cp37m', 'cp38-cp38'] + + if pm.machine() == 'x86_64': + python_abi_tags += ['cp27-cp27m', 'pp27-pypy_73', 'pp36-pypy36_pp73'] + + if platform == 'linux': python_abi_tags.append('cp27-cp27mu') # python 2.7 has 2 different ABI on manylinux - architectures = {'cp': ['x86_64', 'i686'], 'pp': ['x86_64']} - platform_tags = {} - for python_implemention in architectures: - platform_tags[python_implemention] = [ - '{manylinux_version}_{architecture}'.format( - manylinux_version=manylinux_version, architecture=architecture) - for architecture in architectures[python_implemention] + + wheels = [] + + for python_abi_tag in python_abi_tags: + platform_tags = [] + + if platform == 'linux': + architectures = [pm.machine()] + + if pm.machine() == 'x86_64' and python_abi_tag.startswith('cp'): + architectures.append('i686') + + platform_tags = [ + '{}_{}'.format(manylinux_version, architecture) + for architecture in architectures for manylinux_version in manylinux_versions ] - def get_platform_tags(python_abi_tag): - return platform_tags[python_abi_tag[:2]] - elif platform == 'windows': - python_abi_tags += extra_x86_python_abi_tags - platform_tags = {'cp': ['win32', 'win_amd64'], 'pp': ['win32']} + elif platform == 'windows': + if python_abi_tag.startswith('cp'): + platform_tags = ['win32', 'win_amd64'] + else: + platform_tags = ['win32'] - def get_platform_tags(python_abi_tag): - return platform_tags[python_abi_tag[:2]] - - elif platform == 'macos': - python_abi_tags += extra_x86_python_abi_tags - - def get_platform_tags(python_abi_tag): + elif platform == 'macos': default_version = '10.7' if python_abi_tag.startswith('pp') else '10.9' - return ['macosx_{}_x86_64'.format((macosx_deployment_target or default_version).replace('.', '_'))] - else: - raise Exception('unsupported platform') + platform_tags = ['macosx_{}_x86_64'.format((macosx_deployment_target or default_version).replace('.', '_'))] - templates = [] - for python_abi_tag in python_abi_tags: - for platform_tag in get_platform_tags(python_abi_tag): - templates.append('{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl'.format( + else: + raise Exception('unsupported platform') + + for platform_tag in platform_tags: + wheels.append('{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl'.format( package_name=package_name, package_version=package_version, python_abi_tag=python_abi_tag, platform_tag=platform_tag )) if IS_WINDOWS_RUNNING_ON_TRAVIS: # Python 2.7 isn't supported on Travis. - templates = [t for t in templates if '-cp27-' not in t and '-pp2' not in t] + wheels = [w for w in wheels if '-cp27-' not in w and '-pp2' not in w] - return templates + return wheels platform = None From a4602c32dd72874152f528781f6db2de4850d53c Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 6 Apr 2020 16:55:15 +0200 Subject: [PATCH 7/9] 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: From 5a7dc042b6b584d8f806a624f3233ea55b2abc3d Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Tue, 7 Apr 2020 10:01:05 +0100 Subject: [PATCH 8/9] Add Windows x86 machine values --- test/shared/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/shared/utils.py b/test/shared/utils.py index 9c5ecfcb..4fcf816a 100644 --- a/test/shared/utils.py +++ b/test/shared/utils.py @@ -89,7 +89,7 @@ def expected_wheels(package_name, package_version, manylinux_versions=None, python_abi_tags = ['cp35-cp35m', 'cp36-cp36m', 'cp37-cp37m', 'cp38-cp38'] - if pm.machine() == 'x86_64': + if pm.machine() in ['x86_64', 'AMD64', 'x86']: python_abi_tags += ['cp27-cp27m', 'pp27-pypy_73', 'pp36-pypy36_pp73'] if platform == 'linux': From 3aa97f09e2783497e3d7965f24e84167c539926b Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Tue, 7 Apr 2020 12:30:53 +0200 Subject: [PATCH 9/9] appveyor retries --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index f7f7e3b9..b3eaebc5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,7 +14,7 @@ build: off init: - cmd: set PATH=C:\Python37;C:\Python37\Scripts;%PATH% -install: python -m pip install -r requirements-dev.txt +install: python -m pip install --retries 3 -r requirements-dev.txt # the '-u' flag is required so the output is in the correct order. # See https://github.com/joerick/cibuildwheel/pull/24 for more info.