From d3fd087166c1bc1f88c1d5f924c9bff295ba83fc Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Tue, 12 Nov 2019 11:40:21 +0100 Subject: [PATCH 1/3] Run python get-pip.py with Scripts directory in PATH to avoid warnings, and reorder steps to match macOS --- cibuildwheel/macos.py | 2 ++ cibuildwheel/windows.py | 26 +++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 25bf78a7e..fa07ca12a 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -63,6 +63,7 @@ def call(args, env=None, cwd=None, shell=False): call(['sudo', 'tar', '-C', '/Library/Frameworks/Python.framework/Versions/%s/' % config.version, '-xmf', '/tmp/python-patch.tar.gz']) installation_bin_path = '/Library/Frameworks/Python.framework/Versions/{}/bin'.format(config.version) + assert os.path.exists(os.path.join(installation_bin_path, 'python3' if config.version[0] == '3' else 'python')) # Python bin folders on Mac don't symlink python3 to python, so we do that # so `python` and `pip` always point to the active configuration. @@ -89,6 +90,7 @@ def call(args, env=None, cwd=None, shell=False): # install pip & wheel call(['python', get_pip_script, '--no-setuptools', '--no-wheel'], env=env) + assert os.path.exists(os.path.join(installation_bin_path, 'pip')) call(['pip', '--version'], env=env) call(['pip', 'install', '--upgrade', 'setuptools'], env=env) call(['pip', 'install', 'wheel'], env=env) diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index a9fc7d92a..6563071d8 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -100,22 +100,13 @@ def shell(args, env=None, cwd=None): python_configurations = get_python_configurations(build_selector) for config in python_configurations: + # install Python config_python_path = get_python_path(config) simple_shell([nuget, "install"] + get_nuget_args(config)) - if not os.path.exists(os.path.join(config_python_path, 'Scripts', 'pip.exe')): - simple_shell([os.path.join(config_python_path, 'python.exe'), get_pip_script ]) - - # check python & pip exist for this configuration assert os.path.exists(os.path.join(config_python_path, 'python.exe')) - assert os.path.exists(os.path.join(config_python_path, 'Scripts', 'pip.exe')) - - # setup dirs - if os.path.exists(built_wheel_dir): - shutil.rmtree(built_wheel_dir) - os.makedirs(built_wheel_dir) + # set up PATH and environment variables for run_with_env env = os.environ.copy() - # set up environment variables for run_with_env env['PYTHON_VERSION'] = config.version env['PYTHON_ARCH'] = config.arch env['PATH'] = os.pathsep.join([ @@ -123,17 +114,30 @@ def shell(args, env=None, cwd=None): os.path.join(config_python_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) + # make sure pip is installed + if not os.path.exists(os.path.join(config_python_path, 'Scripts', 'pip.exe')): + simple_shell([os.path.join(config_python_path, 'python.exe'), get_pip_script], env=env) + assert os.path.exists(os.path.join(config_python_path, 'Scripts', 'pip.exe')) + # prepare the Python environment shell(['python', '-m', 'pip', 'install', '--upgrade', 'pip'], env=env) + shell(['pip', '--version'], env=env) shell(['pip', 'install', '--upgrade', 'setuptools'], env=env) shell(['pip', 'install', 'wheel'], env=env) + # setup dirs + if os.path.exists(built_wheel_dir): + shutil.rmtree(built_wheel_dir) + os.makedirs(built_wheel_dir) + # run the before_build command if before_build: before_build_prepared = prepare_command(before_build, project=abs_project_dir) From dc012313010127105c62723f1c5b82029dcd6be5 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Tue, 12 Nov 2019 22:25:54 +0100 Subject: [PATCH 2/3] Replace a few shell invocations by simple_shell in windows.py --- cibuildwheel/windows.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 6563071d8..6dda391e7 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -118,9 +118,9 @@ def shell(args, env=None, cwd=None): 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) + simple_shell(['where', 'python'], env=env) + simple_shell(['python', '--version'], env=env) + simple_shell(['python', '-c', '"import struct; print(struct.calcsize(\'P\') * 8)\"'], env=env) # make sure pip is installed if not os.path.exists(os.path.join(config_python_path, 'Scripts', 'pip.exe')): @@ -128,10 +128,10 @@ def shell(args, env=None, cwd=None): assert os.path.exists(os.path.join(config_python_path, 'Scripts', 'pip.exe')) # prepare the Python environment - shell(['python', '-m', 'pip', 'install', '--upgrade', 'pip'], env=env) - shell(['pip', '--version'], env=env) - shell(['pip', 'install', '--upgrade', 'setuptools'], env=env) - shell(['pip', 'install', 'wheel'], env=env) + simple_shell(['python', '-m', 'pip', 'install', '--upgrade', 'pip'], env=env) + simple_shell(['pip', '--version'], env=env) + simple_shell(['pip', 'install', '--upgrade', 'setuptools'], env=env) + simple_shell(['pip', 'install', 'wheel'], env=env) # setup dirs if os.path.exists(built_wheel_dir): From 7d99ccfc7bda7ebd4893f4df0e1f430dcb0312c5 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Tue, 12 Nov 2019 23:47:06 +0100 Subject: [PATCH 3/3] Collapse multiple 'pip install's into one in windows.py and macos.py, and replace full path by 'python' in windows.py --- cibuildwheel/macos.py | 4 +--- cibuildwheel/windows.py | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index fa07ca12a..40e59a864 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -92,9 +92,7 @@ def call(args, env=None, cwd=None, shell=False): call(['python', get_pip_script, '--no-setuptools', '--no-wheel'], env=env) assert os.path.exists(os.path.join(installation_bin_path, 'pip')) call(['pip', '--version'], env=env) - call(['pip', 'install', '--upgrade', 'setuptools'], env=env) - call(['pip', 'install', 'wheel'], env=env) - call(['pip', 'install', 'delocate'], env=env) + call(['pip', 'install', '--upgrade', 'setuptools', 'wheel', 'delocate'], env=env) # setup dirs if os.path.exists('/tmp/built_wheel'): diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 6dda391e7..4b1bea8b1 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -124,14 +124,13 @@ def shell(args, env=None, cwd=None): # make sure pip is installed if not os.path.exists(os.path.join(config_python_path, 'Scripts', 'pip.exe')): - simple_shell([os.path.join(config_python_path, 'python.exe'), get_pip_script], env=env) + simple_shell(['python', get_pip_script], env=env) assert os.path.exists(os.path.join(config_python_path, 'Scripts', 'pip.exe')) # prepare the Python environment simple_shell(['python', '-m', 'pip', 'install', '--upgrade', 'pip'], env=env) simple_shell(['pip', '--version'], env=env) - simple_shell(['pip', 'install', '--upgrade', 'setuptools'], env=env) - simple_shell(['pip', 'install', 'wheel'], env=env) + simple_shell(['pip', 'install', '--upgrade', 'setuptools', 'wheel'], env=env) # setup dirs if os.path.exists(built_wheel_dir):