From 8dd71189b2a909376c9f298ad30e5340a04f6ce7 Mon Sep 17 00:00:00 2001 From: "corey.d.mccarty" Date: Mon, 5 Nov 2018 11:16:42 -0500 Subject: [PATCH 1/5] removed 'package-name' as per #102 --- cibuildwheel/__main__.py | 8 -------- cibuildwheel/linux.py | 3 +-- cibuildwheel/macos.py | 2 +- cibuildwheel/windows.py | 2 +- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 99fea065..7f040614 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -109,8 +109,6 @@ def main(): project_setup_py = os.path.join(project_dir, 'setup.py') name_output = subprocess.check_output([sys.executable, project_setup_py, '--name'], universal_newlines=True) - # the last line of output is the name - package_name = name_output.strip().splitlines()[-1] except subprocess.CalledProcessError as err: if not os.path.exists(project_setup_py): print('cibuildwheel: Could not find setup.py at root of project', file=sys.stderr) @@ -121,14 +119,8 @@ def main(): file=sys.stderr) exit(err.returncode) - if package_name == '' or package_name == 'UNKNOWN': - print('cibuildwheel: Invalid package name "%s". Check your setup.py' % package_name, - file=sys.stderr) - exit(2) - build_options = dict( project_dir=project_dir, - package_name=package_name, output_dir=output_dir, test_command=test_command, test_requires=test_requires, diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index ee221443..c907c6b6 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -9,7 +9,7 @@ except ImportError: from pipes import quote as shlex_quote -def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, build_verbosity, build_selector, environment, manylinux1_images): +def build(project_dir, output_dir, test_command, test_requires, before_build, build_verbosity, build_selector, environment, manylinux1_images): try: subprocess.check_call(['docker', '--version']) except: @@ -102,7 +102,6 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be chown {uid}:{gid} "/output/$(basename "$delocated_wheel")" done '''.format( - package_name=package_name, pybin_paths=' '.join(c.path+'/bin' for c in platform_configs), test_requires=' '.join(test_requires), test_command=shlex_quote( diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 906da91a..ccdd3780 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -10,7 +10,7 @@ except ImportError: from .util import prepare_command, get_build_verbosity_extra_flags -def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, build_verbosity, build_selector, environment): +def build(project_dir, output_dir, test_command, test_requires, before_build, build_verbosity, build_selector, environment): PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'identifier', 'url']) python_configurations = [ PythonConfiguration(version='2.7', identifier='cp27-macosx_10_6_intel', url='https://www.python.org/ftp/python/2.7.15/python-2.7.15-macosx10.6.pkg'), diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 51d428ce..f5a4ffb8 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -10,7 +10,7 @@ from glob import glob from .util import prepare_command, get_build_verbosity_extra_flags -def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, build_verbosity, build_selector, environment): +def build(project_dir, output_dir, test_command, test_requires, before_build, build_verbosity, build_selector, environment): # run_with_env is a cmd file that sets the right environment variables to run_with_env = os.path.join(tempfile.gettempdir(), 'appveyor_run_with_env.cmd') if not os.path.exists(run_with_env): From 2ca6500bbac7c8cdbb9076eabfead793c07c98a4 Mon Sep 17 00:00:00 2001 From: "corey.d.mccarty" Date: Mon, 5 Nov 2018 11:47:31 -0500 Subject: [PATCH 2/5] removed '--name' pieces for #102 --- cibuildwheel/__main__.py | 2 +- cibuildwheel/linux.py | 1 - test/03_before_build/setup.py | 19 ------------------- test/04_build_skip/setup.py | 7 ------- test/05_environment/setup.py | 16 ---------------- test/06_docker_images/setup.py | 6 ------ 6 files changed, 1 insertion(+), 50 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 7f040614..23c83c50 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -107,7 +107,7 @@ def main(): try: project_setup_py = os.path.join(project_dir, 'setup.py') - name_output = subprocess.check_output([sys.executable, project_setup_py, '--name'], + name_output = subprocess.check_output([sys.executable, project_setup_py], universal_newlines=True) except subprocess.CalledProcessError as err: if not os.path.exists(project_setup_py): diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index c907c6b6..c127ece7 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -135,7 +135,6 @@ def build(project_dir, output_dir, test_command, test_requires, before_build, bu try: run_docker(['create', '--env', 'CIBUILDWHEEL', - '--name', container_name, '-i', '-v', '/:/host', # ignored on Circle docker_image, '/bin/bash']) diff --git a/test/03_before_build/setup.py b/test/03_before_build/setup.py index 333de6e8..6f12313a 100644 --- a/test/03_before_build/setup.py +++ b/test/03_before_build/setup.py @@ -1,25 +1,6 @@ from setuptools import setup, Extension import sys, os -if sys.argv[-1] != '--name': - # assert that the Python version as written to pythonversion.txt in the CIBW_BEFORE_BUILD step - # is the same one as is currently running. - version_file = 'c:\\pythonversion.txt' if sys.platform == 'win32' else '/tmp/pythonversion.txt' - with open(version_file) as f: - stored_version = f.read() - print('stored_version', stored_version) - print('sys.version', sys.version) - assert stored_version == sys.version - - # check that the executable also was written - executable_file = 'c:\\pythonexecutable.txt' if sys.platform == 'win32' else '/tmp/pythonexecutable.txt' - with open(executable_file) as f: - stored_executable = f.read() - print('stored_executable', stored_executable) - print('sys.executable', sys.executable) - # windows/mac are case insensitive - assert os.path.realpath(stored_executable).lower() == os.path.realpath(sys.executable).lower() - setup( name="spam", ext_modules=[Extension('spam', sources=['spam.c'])], diff --git a/test/04_build_skip/setup.py b/test/04_build_skip/setup.py index e261e17c..0a1ac29b 100644 --- a/test/04_build_skip/setup.py +++ b/test/04_build_skip/setup.py @@ -1,13 +1,6 @@ from setuptools import setup, Extension import sys -if sys.argv[-1] != '--name': - # explode if run on Python 2.7 or Python 3.4 (these should be skipped) - if sys.version_info[0:2] == (2, 7): - raise Exception('Python 2.7 should not be built') - if sys.version_info[0:2] == (3, 4): - raise Exception('Python 3.4 should be skipped') - setup( name="spam", ext_modules=[Extension('spam', sources=['spam.c'])], diff --git a/test/05_environment/setup.py b/test/05_environment/setup.py index 3278c944..6f12313a 100644 --- a/test/05_environment/setup.py +++ b/test/05_environment/setup.py @@ -1,22 +1,6 @@ from setuptools import setup, Extension import sys, os -if sys.argv[-1] != '--name': - # explode if environment isn't correct, as set in CIBW_ENVIRONMENT - CIBW_TEST_VAR = os.environ.get('CIBW_TEST_VAR') - CIBW_TEST_VAR_2 = os.environ.get('CIBW_TEST_VAR_2') - PATH = os.environ.get('PATH') - - if CIBW_TEST_VAR != 'a b c': - raise Exception('CIBW_TEST_VAR should equal "a b c". It was "%s"' % CIBW_TEST_VAR) - if CIBW_TEST_VAR_2 != '1': - raise Exception('CIBW_TEST_VAR_2 should equal "1". It was "%s"' % CIBW_TEST_VAR_2) - if '/opt/cibw_test_path' not in PATH: - raise Exception('PATH should contain "/opt/cibw_test_path". It was "%s"' % PATH) - if '$PATH' in PATH: - raise Exception('$PATH should be expanded in PATH. It was "%s"' % PATH) - - setup( name="spam", ext_modules=[Extension('spam', sources=['spam.c'])], diff --git a/test/06_docker_images/setup.py b/test/06_docker_images/setup.py index d341d5ff..5b3e09ec 100644 --- a/test/06_docker_images/setup.py +++ b/test/06_docker_images/setup.py @@ -2,12 +2,6 @@ import os, sys from setuptools import setup, Extension -if sys.argv[-1] != '--name': - # check that we're running in the correct docker image as specified in the - # environment options CIBW_MANYLINUX1_*_IMAGE - if 'linux' in sys.platform and not os.path.exists('/dockcross'): - raise Exception('/dockcross directory not found. Is this test running in the correct docker image?') - setup( name="spam", ext_modules=[Extension('spam', sources=['spam.c'])], From c4822ebdd69e4227ef94baf394d5e49edc2cde32 Mon Sep 17 00:00:00 2001 From: Corey McCarty Date: Mon, 5 Nov 2018 16:30:34 -0600 Subject: [PATCH 3/5] Remove Try/Except for package_name #102 recommended by @YannickJadoul --- cibuildwheel/__main__.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 23c83c50..34cde558 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -105,20 +105,6 @@ def main(): # This needs to be passed on to the docker container in linux.py os.environ['CIBUILDWHEEL'] = '1' - try: - project_setup_py = os.path.join(project_dir, 'setup.py') - name_output = subprocess.check_output([sys.executable, project_setup_py], - universal_newlines=True) - except subprocess.CalledProcessError as err: - if not os.path.exists(project_setup_py): - print('cibuildwheel: Could not find setup.py at root of project', file=sys.stderr) - exit(2) - else: - print(err.output) - print('cibuildwheel: Failed to get name of the package. Command was %s' % err.cmd, - file=sys.stderr) - exit(err.returncode) - build_options = dict( project_dir=project_dir, output_dir=output_dir, From 3d23cbf2a637bd543e6a5ff7e4ab2d41676ffc9e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Nov 2018 02:44:19 +0000 Subject: [PATCH 4/5] corrected as per notations from @YannickJadoul on #113 --- cibuildwheel/__main__.py | 20 ++++++++++++++++++++ cibuildwheel/linux.py | 1 + test/03_before_build/setup.py | 17 +++++++++++++++++ test/04_build_skip/setup.py | 6 ++++++ test/05_environment/setup.py | 13 +++++++++++++ test/06_docker_images/setup.py | 5 +++++ 6 files changed, 62 insertions(+) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 34cde558..84372395 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -105,6 +105,26 @@ def main(): # This needs to be passed on to the docker container in linux.py os.environ['CIBUILDWHEEL'] = '1' + try: + project_setup_py = os.path.join(project_dir, 'setup.py') + name_output = subprocess.check_output([sys.executable, project_setup_py, '--name'], + universal_newlines=True) + # the last line of output is the name + package_name = name_output.strip().splitlines()[-1] + except subprocess.CalledProcessError as err: + if not os.path.exists(project_setup_py): + print('cibuildwheel: Could not find setup.py at root of project', file=sys.stderr) + exit(2) + else: + print(err.output) + print('cibuildwheel: Failed to get name of the package. Command was %s' % err.cmd, + file=sys.stderr) + exit(err.returncode) + if package_name == '' or package_name == 'UNKNOWN': + print('cibuildwheel: Invalid package name "%s". Check your setup.py' % package_name, + file=sys.stderr) + exit(2) + build_options = dict( project_dir=project_dir, output_dir=output_dir, diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index c127ece7..c907c6b6 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -135,6 +135,7 @@ def build(project_dir, output_dir, test_command, test_requires, before_build, bu try: run_docker(['create', '--env', 'CIBUILDWHEEL', + '--name', container_name, '-i', '-v', '/:/host', # ignored on Circle docker_image, '/bin/bash']) diff --git a/test/03_before_build/setup.py b/test/03_before_build/setup.py index 6f12313a..aea796af 100644 --- a/test/03_before_build/setup.py +++ b/test/03_before_build/setup.py @@ -1,6 +1,23 @@ from setuptools import setup, Extension import sys, os +# assert that the Python version as written to pythonversion.txt in the CIBW_BEFORE_BUILD step +# is the same one as is currently running. +version_file = 'c:\\pythonversion.txt' if sys.platform == 'win32' else '/tmp/pythonversion.txt' +with open(version_file) as f: + stored_version = f.read() +print('stored_version', stored_version) +print('sys.version', sys.version) +assert stored_version == sys.version +# check that the executable also was written +executable_file = 'c:\\pythonexecutable.txt' if sys.platform == 'win32' else '/tmp/pythonexecutable.txt' +with open(executable_file) as f: + stored_executable = f.read() +print('stored_executable', stored_executable) +print('sys.executable', sys.executable) +# windows/mac are case insensitive +assert os.path.realpath(stored_executable).lower() == os.path.realpath(sys.executable).lower() + setup( name="spam", ext_modules=[Extension('spam', sources=['spam.c'])], diff --git a/test/04_build_skip/setup.py b/test/04_build_skip/setup.py index 0a1ac29b..94f3eb13 100644 --- a/test/04_build_skip/setup.py +++ b/test/04_build_skip/setup.py @@ -1,6 +1,12 @@ from setuptools import setup, Extension import sys +# explode if run on Python 2.7 or Python 3.4 (these should be skipped) +if sys.version_info[0:2] == (2, 7): + raise Exception('Python 2.7 should not be built') +if sys.version_info[0:2] == (3, 4): + raise Exception('Python 3.4 should be skipped') + setup( name="spam", ext_modules=[Extension('spam', sources=['spam.c'])], diff --git a/test/05_environment/setup.py b/test/05_environment/setup.py index 6f12313a..40b2c197 100644 --- a/test/05_environment/setup.py +++ b/test/05_environment/setup.py @@ -1,6 +1,19 @@ from setuptools import setup, Extension import sys, os +# explode if environment isn't correct, as set in CIBW_ENVIRONMENT +CIBW_TEST_VAR = os.environ.get('CIBW_TEST_VAR') +CIBW_TEST_VAR_2 = os.environ.get('CIBW_TEST_VAR_2') +PATH = os.environ.get('PATH') +if CIBW_TEST_VAR != 'a b c': + raise Exception('CIBW_TEST_VAR should equal "a b c". It was "%s"' % CIBW_TEST_VAR) +if CIBW_TEST_VAR_2 != '1': + raise Exception('CIBW_TEST_VAR_2 should equal "1". It was "%s"' % CIBW_TEST_VAR_2) +if '/opt/cibw_test_path' not in PATH: + raise Exception('PATH should contain "/opt/cibw_test_path". It was "%s"' % PATH) +if '$PATH' in PATH: + raise Exception('$PATH should be expanded in PATH. It was "%s"' % PATH) + setup( name="spam", ext_modules=[Extension('spam', sources=['spam.c'])], diff --git a/test/06_docker_images/setup.py b/test/06_docker_images/setup.py index 5b3e09ec..8084d9fe 100644 --- a/test/06_docker_images/setup.py +++ b/test/06_docker_images/setup.py @@ -2,6 +2,11 @@ import os, sys from setuptools import setup, Extension +# check that we're running in the correct docker image as specified in the +# environment options CIBW_MANYLINUX1_*_IMAGE +if 'linux' in sys.platform and not os.path.exists('/dockcross'): + raise Exception('/dockcross directory not found. Is this test running in the correct docker image?') + setup( name="spam", ext_modules=[Extension('spam', sources=['spam.c'])], From ccfc3c3aa1eabd85040014252f85de862f820420 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Thu, 29 Nov 2018 23:20:38 +0100 Subject: [PATCH 5/5] Fixing indentation error, and keeping only check for setup.py in project root directory in __main__.py --- cibuildwheel/__main__.py | 20 ++------------------ test/03_before_build/setup.py | 1 + test/05_environment/setup.py | 2 ++ 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 84372395..d680e9b8 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -105,24 +105,8 @@ def main(): # This needs to be passed on to the docker container in linux.py os.environ['CIBUILDWHEEL'] = '1' - try: - project_setup_py = os.path.join(project_dir, 'setup.py') - name_output = subprocess.check_output([sys.executable, project_setup_py, '--name'], - universal_newlines=True) - # the last line of output is the name - package_name = name_output.strip().splitlines()[-1] - except subprocess.CalledProcessError as err: - if not os.path.exists(project_setup_py): - print('cibuildwheel: Could not find setup.py at root of project', file=sys.stderr) - exit(2) - else: - print(err.output) - print('cibuildwheel: Failed to get name of the package. Command was %s' % err.cmd, - file=sys.stderr) - exit(err.returncode) - if package_name == '' or package_name == 'UNKNOWN': - print('cibuildwheel: Invalid package name "%s". Check your setup.py' % package_name, - file=sys.stderr) + if not os.path.exists(os.path.join(project_dir, 'setup.py')): + print('cibuildwheel: Could not find setup.py at root of project', file=sys.stderr) exit(2) build_options = dict( diff --git a/test/03_before_build/setup.py b/test/03_before_build/setup.py index aea796af..b7b802fe 100644 --- a/test/03_before_build/setup.py +++ b/test/03_before_build/setup.py @@ -9,6 +9,7 @@ with open(version_file) as f: print('stored_version', stored_version) print('sys.version', sys.version) assert stored_version == sys.version + # check that the executable also was written executable_file = 'c:\\pythonexecutable.txt' if sys.platform == 'win32' else '/tmp/pythonexecutable.txt' with open(executable_file) as f: diff --git a/test/05_environment/setup.py b/test/05_environment/setup.py index 40b2c197..61abd814 100644 --- a/test/05_environment/setup.py +++ b/test/05_environment/setup.py @@ -5,6 +5,7 @@ import sys, os CIBW_TEST_VAR = os.environ.get('CIBW_TEST_VAR') CIBW_TEST_VAR_2 = os.environ.get('CIBW_TEST_VAR_2') PATH = os.environ.get('PATH') + if CIBW_TEST_VAR != 'a b c': raise Exception('CIBW_TEST_VAR should equal "a b c". It was "%s"' % CIBW_TEST_VAR) if CIBW_TEST_VAR_2 != '1': @@ -14,6 +15,7 @@ if '/opt/cibw_test_path' not in PATH: if '$PATH' in PATH: raise Exception('$PATH should be expanded in PATH. It was "%s"' % PATH) + setup( name="spam", ext_modules=[Extension('spam', sources=['spam.c'])],