From 418cb9c39d8cf4ff0d59d9d318bac2758d7cfad8 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sun, 8 Apr 2018 13:40:30 +0200 Subject: [PATCH 01/14] Removing replacement of {python} and {pip} in CIBW_BEFORE_BUILD --- cibuildwheel/linux.py | 5 +---- cibuildwheel/macos.py | 26 ++++++++++---------------- cibuildwheel/util.py | 12 ------------ cibuildwheel/windows.py | 5 ++--- 4 files changed, 13 insertions(+), 35 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index cd7a7136..9b6ab4d1 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -1,7 +1,6 @@ from __future__ import print_function import os, subprocess, sys from collections import namedtuple -from .util import prepare_command try: from shlex import quote as shlex_quote @@ -105,9 +104,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be test_command=shlex_quote( test_command.format(project='/project') if test_command else '' ), - before_build=shlex_quote( - prepare_command(before_build, python='python', pip='pip') if before_build else '' - ), + before_build=shlex_quote(before_build or ''), environment_exports='\n'.join(environment.as_shell_commands()), ) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 836a7189..71a5716d 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -7,8 +7,6 @@ try: except ImportError: from pipes import quote as shlex_quote -from .util import prepare_command - def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip, environment): PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'identifier', 'url']) @@ -60,18 +58,15 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be ]) env = environment.as_dictionary(prev_environment=env) - python = 'python3' if config.version[0] == '3' else 'python2' - pip = 'pip3' if config.version[0] == '3' else 'pip2' - # check what version we're on - call(['which', python], env=env) - call([python, '--version'], env=env) + call(['which', 'python'], env=env) + call(['python', '--version'], env=env) # install pip & wheel - call([python, get_pip_script, '--no-setuptools', '--no-wheel'], env=env) - call([pip, '--version'], env=env) - call([pip, 'install', 'wheel'], env=env) - call([pip, 'install', 'delocate'], env=env) + call(['python', get_pip_script, '--no-setuptools', '--no-wheel'], env=env) + call(['pip', '--version'], env=env) + call(['pip', 'install', 'wheel'], env=env) + call(['pip', 'install', 'delocate'], env=env) # setup dirs if os.path.exists('/tmp/built_wheel'): @@ -83,11 +78,10 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # run the before_build command if before_build: - before_build_prepared = prepare_command(before_build, python=python, pip=pip) - call(before_build_prepared, env=env, shell=True) + call(before_build, env=env, shell=True) # build the wheel - call([pip, 'wheel', abs_project_dir, '-w', '/tmp/built_wheel', '--no-deps'], env=env) + call(['pip', 'wheel', abs_project_dir, '-w', '/tmp/built_wheel', '--no-deps'], env=env) built_wheel = glob('/tmp/built_wheel/*.whl')[0] if built_wheel.endswith('none-any.whl'): @@ -101,11 +95,11 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be delocated_wheel = glob('/tmp/delocated_wheel/*.whl')[0] # install the wheel - call([pip, 'install', delocated_wheel], env=env) + call(['pip', 'install', delocated_wheel], env=env) # test the wheel if test_requires: - call([pip, 'install'] + test_requires, env=env) + call(['pip', 'install'] + test_requires, env=env) if test_command: # run the tests from $HOME, with an absolute path in the command # (this ensures that Python runs the tests against the installed wheel diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index d860beeb..e15d2ddd 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -1,18 +1,6 @@ from fnmatch import fnmatch -def prepare_command(command, python, pip): - ''' - Preprocesses a command by expanding variables like {python} or {pip}. - - For example, used for the before_build option, where the user would - like to run a command like `python setup.py test`. If the command should run on - Python 3, the user could write `{python} setup.py test`. This command would expand - it out to python2 or python3 as appropriate. - ''' - return command.format(python=python, pip=pip) - - class BuildSkipper(object): def __init__(self, skip_config): self.patterns = skip_config.split() diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 3c962af9..1ea37128 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -7,7 +7,7 @@ except ImportError: from collections import namedtuple from glob import glob -from .util import prepare_command, Unbuffered +from .util import Unbuffered def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip, environment): @@ -78,8 +78,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # run the before_build command if before_build: - before_build_prepared = prepare_command(before_build, python='python', pip='pip') - shell([before_build_prepared], env=env) + shell([before_build], env=env) # build the wheel shell(['pip', 'wheel', abs_project_dir, '-w', built_wheel_dir, '--no-deps'], env=env) From 529e22bfe08cd77cae6cc1676af1a28f8507f1a6 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sun, 8 Apr 2018 14:14:01 +0200 Subject: [PATCH 02/14] Removing {python} from test 03_before_build --- test/03_before_build/environment.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/03_before_build/environment.json b/test/03_before_build/environment.json index 75074513..3e9108ea 100644 --- a/test/03_before_build/environment.json +++ b/test/03_before_build/environment.json @@ -1,4 +1,4 @@ { - "CIBW_BEFORE_BUILD": "{python} -c \"import sys; open('/tmp/pythonversion.txt', 'w').write(sys.version)\" && {python} -c \"import sys; open('/tmp/pythonexecutable.txt', 'w').write(sys.executable)\"", - "CIBW_BEFORE_BUILD_WINDOWS": "{python} -c \"import sys; open('c:\\pythonversion.txt', 'w').write(sys.version)\" && {python} -c \"import sys; open('c:\\pythonexecutable.txt', 'w').write(sys.executable)\"" + "CIBW_BEFORE_BUILD": "python -c \"import sys; open('/tmp/pythonversion.txt', 'w').write(sys.version)\" && python -c \"import sys; open('/tmp/pythonexecutable.txt', 'w').write(sys.executable)\"", + "CIBW_BEFORE_BUILD_WINDOWS": "python -c \"import sys; open('c:\\pythonversion.txt', 'w').write(sys.version)\" && python -c \"import sys; open('c:\\pythonexecutable.txt', 'w').write(sys.executable)\"" } From 783a4deec64067a8786d76e03228d1a64b986e57 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sun, 8 Apr 2018 15:05:21 +0200 Subject: [PATCH 03/14] Symlinking python3 and pip3 to python and pip for OS X runs --- cibuildwheel/macos.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 71a5716d..b5c39961 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -51,9 +51,14 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # install call(['sudo', 'installer', '-pkg', '/tmp/Python.pkg', '-target', '/']) + installation_bin_path = '/Library/Frameworks/Python.framework/Versions/{}/bin'.format(config.version) + if config.version[0] == '3': + os.symlink(os.path.join(installation_bin_path, 'python3'), os.path.join(installation_bin_path, 'python')) + os.symlink(os.path.join(installation_bin_path, 'pip3'), os.path.join(installation_bin_path, 'pip')) + env = os.environ.copy() env['PATH'] = os.pathsep.join([ - '/Library/Frameworks/Python.framework/Versions/%s/bin' % config.version, + installation_bin_path, env['PATH'], ]) env = environment.as_dictionary(prev_environment=env) From 5e009e53c9dc7462e5f55f8f3fcad99073b0f6cb Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sun, 8 Apr 2018 15:12:43 +0200 Subject: [PATCH 04/14] Symlinking only on first-time installation of Python versions on mac OS X --- cibuildwheel/macos.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index b5c39961..6829e835 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -45,16 +45,16 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # if this version of python isn't installed, get it from python.org and install python_package_identifier = 'org.python.Python.PythonFramework-%s' % config.version + installation_bin_path = '/Library/Frameworks/Python.framework/Versions/{}/bin'.format(config.version) if python_package_identifier not in installed_system_packages: # download the pkg call(['curl', '-L', '-o', '/tmp/Python.pkg', config.url]) # install call(['sudo', 'installer', '-pkg', '/tmp/Python.pkg', '-target', '/']) - installation_bin_path = '/Library/Frameworks/Python.framework/Versions/{}/bin'.format(config.version) - if config.version[0] == '3': - os.symlink(os.path.join(installation_bin_path, 'python3'), os.path.join(installation_bin_path, 'python')) - os.symlink(os.path.join(installation_bin_path, 'pip3'), os.path.join(installation_bin_path, 'pip')) + if config.version[0] == '3': + os.symlink(os.path.join(installation_bin_path, 'python3'), os.path.join(installation_bin_path, 'python')) + os.symlink(os.path.join(installation_bin_path, 'pip3'), os.path.join(installation_bin_path, 'pip')) env = os.environ.copy() env['PATH'] = os.pathsep.join([ From 4d61b08fa378403487cdd7dec323847ac91c67d0 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sun, 8 Apr 2018 15:26:09 +0200 Subject: [PATCH 05/14] Updating README, removing documentation on {python} and {pip} --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b4fca73a..02ffa2cc 100644 --- a/README.md +++ b/README.md @@ -194,13 +194,13 @@ Optional. A shell command to run before building the wheel. This option allows you to run a command in **each** Python environment before the `pip wheel` command. This is useful if you need to set up some dependency so it's available during the build. -If dependencies are required to build your wheel (for example if you include a header from a Python module), set this to `{pip} install .`, and the dependencies will be installed automatically by pip. However, this means your package will be built twice - if your package takes a long time to build, you might wish to manually list the dependencies here instead. +If dependencies are required to build your wheel (for example if you include a header from a Python module), set this to `pip install .`, and the dependencies will be installed automatically by pip. However, this means your package will be built twice - if your package takes a long time to build, you might wish to manually list the dependencies here instead. -The active Python binary can be accessed using `{python}`, and pip with `{pip}`. These are useful when you need to write `python3` or `pip3` on a Python 3.x build. +The active Python binary can be accessed using `python`, and pip with `pip`; `cibuildwheel` makes sure the right version of Python and pip will be executed. -Example: `{pip} install .` -Example: `{pip} install pybind11` -Example: `yum install -y libffi-dev && {pip} install .` +Example: `pip install .` +Example: `pip install pybind11` +Example: `yum install -y libffi-dev && pip install .` Platform-specific variants also available: `CIBW_BEFORE_BUILD_MACOS` | `CIBW_BEFORE_BUILD_WINDOWS` | `CIBW_BEFORE_BUILD_LINUX` @@ -222,7 +222,7 @@ Example: `dockcross/manylinux-x86` Optional. -Shell command to run tests after the build. The wheel will be installed automatically and available for import from the tests. The project root should be included in the command as "{project}". +Shell command to run tests after the build. The wheel will be installed automatically and available for import from the tests. `{project}` can be used as a placeholder for the absolute path to the project's root and will be replaced by `cibuildwheel`. Example: `nosetests {project}/tests` From 2ebde4c078db7e82f94c0a9c37982e008357e572 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sun, 8 Apr 2018 17:01:54 +0200 Subject: [PATCH 06/14] Reverting removal of `prepare_command` to maintain backwards compatibility of configurations with {python} and {pip} --- cibuildwheel/linux.py | 5 ++++- cibuildwheel/macos.py | 5 ++++- cibuildwheel/util.py | 12 ++++++++++++ cibuildwheel/windows.py | 5 +++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 9b6ab4d1..cd7a7136 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -1,6 +1,7 @@ from __future__ import print_function import os, subprocess, sys from collections import namedtuple +from .util import prepare_command try: from shlex import quote as shlex_quote @@ -104,7 +105,9 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be test_command=shlex_quote( test_command.format(project='/project') if test_command else '' ), - before_build=shlex_quote(before_build or ''), + before_build=shlex_quote( + prepare_command(before_build, python='python', pip='pip') if before_build else '' + ), environment_exports='\n'.join(environment.as_shell_commands()), ) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 6829e835..d0de6f2e 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -7,6 +7,8 @@ try: except ImportError: from pipes import quote as shlex_quote +from .util import prepare_command + def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip, environment): PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'identifier', 'url']) @@ -83,7 +85,8 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # run the before_build command if before_build: - call(before_build, env=env, shell=True) + before_build_prepared = prepare_command(before_build, python='python', pip='pip') + call(before_build_prepared, env=env, shell=True) # build the wheel call(['pip', 'wheel', abs_project_dir, '-w', '/tmp/built_wheel', '--no-deps'], env=env) diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index e15d2ddd..d860beeb 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -1,6 +1,18 @@ from fnmatch import fnmatch +def prepare_command(command, python, pip): + ''' + Preprocesses a command by expanding variables like {python} or {pip}. + + For example, used for the before_build option, where the user would + like to run a command like `python setup.py test`. If the command should run on + Python 3, the user could write `{python} setup.py test`. This command would expand + it out to python2 or python3 as appropriate. + ''' + return command.format(python=python, pip=pip) + + class BuildSkipper(object): def __init__(self, skip_config): self.patterns = skip_config.split() diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 1ea37128..3c962af9 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -7,7 +7,7 @@ except ImportError: from collections import namedtuple from glob import glob -from .util import Unbuffered +from .util import prepare_command, Unbuffered def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip, environment): @@ -78,7 +78,8 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # run the before_build command if before_build: - shell([before_build], env=env) + before_build_prepared = prepare_command(before_build, python='python', pip='pip') + shell([before_build_prepared], env=env) # build the wheel shell(['pip', 'wheel', abs_project_dir, '-w', built_wheel_dir, '--no-deps'], env=env) From 5099d605840e94ad40d1f849e1501d38ee2455b6 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 8 Apr 2018 16:51:22 +0100 Subject: [PATCH 07/14] Use a separate folder for `bin` overrides --- cibuildwheel/macos.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index d0de6f2e..73194c72 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -54,12 +54,20 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # install call(['sudo', 'installer', '-pkg', '/tmp/Python.pkg', '-target', '/']) - if config.version[0] == '3': - os.symlink(os.path.join(installation_bin_path, 'python3'), os.path.join(installation_bin_path, 'python')) - os.symlink(os.path.join(installation_bin_path, 'pip3'), os.path.join(installation_bin_path, 'pip')) + # 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. + if os.path.exists('/tmp/cibw_bin'): + shutil.rmtree('/tmp/cibw_bin') + os.makedirs('/tmp/cibw_bin') + + if config.version[0] == '3': + os.symlink(os.path.join(installation_bin_path, 'python3'), '/tmp/cibw_bin/python') + os.symlink(os.path.join(installation_bin_path, 'python3-config'), '/tmp/cibw_bin/python-config') + os.symlink(os.path.join(installation_bin_path, 'pip3'), '/tmp/cibw_bin/pip') env = os.environ.copy() env['PATH'] = os.pathsep.join([ + '/tmp/cibw_bin', installation_bin_path, env['PATH'], ]) From b74333a94074d5bed6fa767af61ed02f5efbdf93 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 8 Apr 2018 18:25:18 +0100 Subject: [PATCH 08/14] Simplify prepare_command function and add deprecation warning --- cibuildwheel/__main__.py | 5 ++++- cibuildwheel/linux.py | 4 ++-- cibuildwheel/macos.py | 4 ++-- cibuildwheel/util.py | 11 ++++++++--- cibuildwheel/windows.py | 4 ++-- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index b8f1ac07..81fb2612 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -1,5 +1,5 @@ from __future__ import print_function -import argparse, os, subprocess, sys, textwrap +import argparse, os, subprocess, sys, textwrap, warnings import cibuildwheel import cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos @@ -25,6 +25,9 @@ def get_option_from_environment(option_name, platform=None): def main(): + # enable deprecation warnings + warnings.filterwarnings("once", ".*", DeprecationWarning) + parser = argparse.ArgumentParser( description='Build wheels for all the platforms.', epilog=('Most options are supplied via environment variables. ' diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index e81e231a..b51be81c 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -103,10 +103,10 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be pybin_paths=' '.join(c.path+'/bin' for c in platform_configs), test_requires=' '.join(test_requires), test_command=shlex_quote( - prepare_command(test_command, python='python', pip='pip', project='/project') if test_command else '' + prepare_command(test_command, project='/project') if test_command else '' ), before_build=shlex_quote( - prepare_command(before_build, python='python', pip='pip', project='/project') if before_build else '' + prepare_command(before_build, project='/project') if before_build else '' ), environment_exports='\n'.join(environment.as_shell_commands()), ) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 1a90c410..569f14a9 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -93,7 +93,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # run the before_build command if before_build: - before_build_prepared = prepare_command(before_build, python=python, pip=pip, project=abs_project_dir) + before_build_prepared = prepare_command(before_build, project=abs_project_dir) call(before_build_prepared, env=env, shell=True) # build the wheel @@ -120,7 +120,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # 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(test_command, python=python, pip=pip, project=abs_project_dir) + test_command_prepared = prepare_command(test_command, project=abs_project_dir) call(shlex.split(test_command_prepared), cwd=os.environ['HOME'], env=env) # we're all done here; move it to output diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 9b1e2ccf..763d9cf2 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -1,16 +1,21 @@ from fnmatch import fnmatch +import warnings -def prepare_command(command, python, pip, project): +def prepare_command(command, project): ''' - Preprocesses a command by expanding variables like {python} or {pip}. + Preprocesses a command by expanding variables like {project}. For example, used for the before_build option, where the user would like to run a command like `python setup.py test`. If the command should run on Python 3, the user could write `{python} setup.py test`. This command would expand it out to python2 or python3 as appropriate. ''' - return command.format(python=python, pip=pip, project=project) + if '{python}' in command or '{pip}' in command: + warnings.warn("'{python}' and '{pip}' are no longer needed, and have been deprecated. Simply use 'python' or 'pip' instead.", + DeprecationWarning) + + return command.format(python='python', pip='pip', project=project) class BuildSkipper(object): diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 42a38c80..1c3e5fbd 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -78,7 +78,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # run the before_build command if before_build: - before_build_prepared = prepare_command(before_build, python='python', pip='pip', project=abs_project_dir) + before_build_prepared = prepare_command(before_build, project=abs_project_dir) shell([before_build_prepared], env=env) # build the wheel @@ -95,7 +95,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # 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(test_command, python='python', pip='pip', project=abs_project_dir) + test_command_prepared = prepare_command(test_command, project=abs_project_dir) shell([test_command_prepared], cwd='c:\\', env=env) # we're all done here; move it to output From c9c54602ed740a441d675fca90100b3e2d4e0581 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 8 Apr 2018 18:42:21 +0100 Subject: [PATCH 09/14] Correct comment --- cibuildwheel/util.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 763d9cf2..7cc075a2 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -6,10 +6,8 @@ def prepare_command(command, project): ''' Preprocesses a command by expanding variables like {project}. - For example, used for the before_build option, where the user would - like to run a command like `python setup.py test`. If the command should run on - Python 3, the user could write `{python} setup.py test`. This command would expand - it out to python2 or python3 as appropriate. + For example, used in the test_command option, to specify the path to the + tests directory. ''' if '{python}' in command or '{pip}' in command: warnings.warn("'{python}' and '{pip}' are no longer needed, and have been deprecated. Simply use 'python' or 'pip' instead.", From 94e33cd7e34f961c389b554d73e2edac8a3980ca Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 8 Apr 2018 18:42:47 +0100 Subject: [PATCH 10/14] Switch to a more user-friendly warning style --- cibuildwheel/__main__.py | 20 ++++++++++++++++++++ cibuildwheel/util.py | 4 ---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 81fb2612..52e1b0ac 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -167,7 +167,27 @@ def print_preamble(platform, build_options): for option, value in build_options.items(): print(' %s: %r' % (option, value)) + warnings = detect_warnings(platform, build_options) + if warnings: + print('\nWarnings:') + for warning in warnings: + print(' ' + warning) + print('\nHere we go!\n') +def detect_warnings(platform, build_options): + warnings = [] + + # warn about deprecated {python} and {pip} + for option_name in ['test_command', 'before_build']: + option_value = build_options.get(option_name) + + if option_value: + if '{python}' in option_value or '{pip}' in option_value: + warnings.append(option_name + ": '{python}' and '{pip}' are no longer needed, and will be removed in a future release. Simply use 'python' or 'pip' instead.") + + return warnings + + if __name__ == '__main__': main() diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 7cc075a2..fc74ef65 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -9,10 +9,6 @@ def prepare_command(command, project): For example, used in the test_command option, to specify the path to the tests directory. ''' - if '{python}' in command or '{pip}' in command: - warnings.warn("'{python}' and '{pip}' are no longer needed, and have been deprecated. Simply use 'python' or 'pip' instead.", - DeprecationWarning) - return command.format(python='python', pip='pip', project=project) From b47a5c018f9ad05e5ec187257aa7cd1634f70905 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 8 Apr 2018 19:11:38 +0100 Subject: [PATCH 11/14] Remove unused warnings import --- cibuildwheel/__main__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 52e1b0ac..bdc76287 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -1,5 +1,5 @@ from __future__ import print_function -import argparse, os, subprocess, sys, textwrap, warnings +import argparse, os, subprocess, sys, textwrap import cibuildwheel import cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos @@ -25,9 +25,6 @@ def get_option_from_environment(option_name, platform=None): def main(): - # enable deprecation warnings - warnings.filterwarnings("once", ".*", DeprecationWarning) - parser = argparse.ArgumentParser( description='Build wheels for all the platforms.', epilog=('Most options are supplied via environment variables. ' From 460a4d965645900dc01e7ac2be900f7467209d25 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 8 Apr 2018 23:26:04 +0100 Subject: [PATCH 12/14] Code tidy/reorganise --- cibuildwheel/__main__.py | 7 +++---- cibuildwheel/macos.py | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index bdc76287..6252b4f2 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -177,11 +177,10 @@ def detect_warnings(platform, build_options): # warn about deprecated {python} and {pip} for option_name in ['test_command', 'before_build']: - option_value = build_options.get(option_name) + option_value = build_options.get(option_name, '') - if option_value: - if '{python}' in option_value or '{pip}' in option_value: - warnings.append(option_name + ": '{python}' and '{pip}' are no longer needed, and will be removed in a future release. Simply use 'python' or 'pip' instead.") + if '{python}' in option_value or '{pip}' in option_value: + warnings.append(option_name + ": '{python}' and '{pip}' are no longer needed, and will be removed in a future release. Simply use 'python' or 'pip' instead.") return warnings diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 569f14a9..45cb178a 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -47,13 +47,14 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # if this version of python isn't installed, get it from python.org and install python_package_identifier = 'org.python.Python.PythonFramework-%s' % config.version - installation_bin_path = '/Library/Frameworks/Python.framework/Versions/{}/bin'.format(config.version) if python_package_identifier not in installed_system_packages: # download the pkg call(['curl', '-L', '-o', '/tmp/Python.pkg', config.url]) # install call(['sudo', 'installer', '-pkg', '/tmp/Python.pkg', '-target', '/']) + installation_bin_path = '/Library/Frameworks/Python.framework/Versions/{}/bin'.format(config.version) + # 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. if os.path.exists('/tmp/cibw_bin'): From 0156a9a8706bac14a87e036f0ab452b5018786c4 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 8 Apr 2018 23:38:54 +0100 Subject: [PATCH 13/14] Fix "'NoneType' is not iterable" error The build_options dict contains None objects ! :) --- cibuildwheel/__main__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 6252b4f2..bdc76287 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -177,10 +177,11 @@ def detect_warnings(platform, build_options): # warn about deprecated {python} and {pip} for option_name in ['test_command', 'before_build']: - option_value = build_options.get(option_name, '') + option_value = build_options.get(option_name) - if '{python}' in option_value or '{pip}' in option_value: - warnings.append(option_name + ": '{python}' and '{pip}' are no longer needed, and will be removed in a future release. Simply use 'python' or 'pip' instead.") + if option_value: + if '{python}' in option_value or '{pip}' in option_value: + warnings.append(option_name + ": '{python}' and '{pip}' are no longer needed, and will be removed in a future release. Simply use 'python' or 'pip' instead.") return warnings From 1ec652dff84c7a10c399e1af04b69a6580a97b9d Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 17 Jun 2018 21:06:00 +0100 Subject: [PATCH 14/14] Fix pip variable use --- cibuildwheel/macos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 4072958d..bedfb26b 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -99,7 +99,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be call(before_build_prepared, env=env, shell=True) # build the wheel - call([pip, 'wheel', abs_project_dir, '-w', '/tmp/built_wheel', '--no-deps'] + get_build_verbosity_extra_flags(build_verbosity), env=env) + call(['pip', 'wheel', abs_project_dir, '-w', '/tmp/built_wheel', '--no-deps'] + get_build_verbosity_extra_flags(build_verbosity), env=env) built_wheel = glob('/tmp/built_wheel/*.whl')[0] if built_wheel.endswith('none-any.whl'):