From f3a136be789aeb0ccb8ea2381a890d41b4febc33 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sun, 31 May 2020 17:36:30 +0100 Subject: [PATCH 01/18] improv: support pyproject.toml existence Signed-off-by: heitorlessa --- cibuildwheel/__main__.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index bc21fbe6..d4ce5025 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -161,7 +161,7 @@ def main() -> None: # This needs to be passed on to the docker container in linux.py os.environ['CIBUILDWHEEL'] = '1' - if not os.path.exists(os.path.join(package_dir, 'setup.py')): + if not detect_setup_pyproject_existence(package_dir): print('cibuildwheel: Could not find setup.py at root of package', file=sys.stderr) exit(2) @@ -309,5 +309,27 @@ def detect_warnings(platform: str, build_options: BuildOptions) -> List[str]: return warnings +def detect_setup_pyproject_existence(package_dir: str) -> bool: + """Detects whether setup.py, or pyproject.toml is at package dir + + Parameters + ---------- + package_dir : str + Package directory path + + Returns + ------- + bool + Whether setup.py, or pyproject.toml exists + """ + exists = False + if os.path.exists(os.path.join(package_dir, 'setup.py')): + exists = True + + if os.path.exists(os.path.join(package_dir, 'pyproject.toml')): + exists = True + + return exists + if __name__ == '__main__': main() From e8d857db21bb7ac29ea84533e44adbc08527811f Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sun, 31 May 2020 17:56:43 +0100 Subject: [PATCH 02/18] chore: flake8 mypy linting Signed-off-by: heitorlessa --- cibuildwheel/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index d4ce5025..77b5aa99 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -325,11 +325,12 @@ def detect_setup_pyproject_existence(package_dir: str) -> bool: exists = False if os.path.exists(os.path.join(package_dir, 'setup.py')): exists = True - + if os.path.exists(os.path.join(package_dir, 'pyproject.toml')): exists = True return exists + if __name__ == '__main__': main() From bb1b050ab5f8355c6a147a05a1d906d9d054043b Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sun, 31 May 2020 19:55:27 +0100 Subject: [PATCH 03/18] improv: add integ test dummy poetry package --- test/test_poetry_project.py | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/test_poetry_project.py diff --git a/test/test_poetry_project.py b/test/test_poetry_project.py new file mode 100644 index 00000000..01c3f83c --- /dev/null +++ b/test/test_poetry_project.py @@ -0,0 +1,42 @@ +from . import test_projects +from . import utils + +pyproject_package_file = """ +[tool.poetry] +name = "dummy_package" +version = "0.1.0" +description = "dummy" +authors = ["cibuildwheel poetry test"] +classifiers=[ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", +] +license = "MIT" +[tool.poetry.dependencies] +python = "^3.6" +[tool.poetry.dev-dependencies] +[build-system] +requires = ["poetry>=0.12"] +build-backend = "poetry.masonry.api" +""" + +poetry_dummy_project = test_projects.TestProject() +poetry_dummy_project.files["dummy_package/__init__.py"] = "" +poetry_dummy_project.files["pyproject.toml"] = pyproject_package_file + + +def test_poetry_package(tmp_path): + + project_dir = tmp_path / "project" + poetry_dummy_project.generate(project_dir) + # build the wheels + actual_wheels = utils.cibuildwheel_run(project_dir) + + # check that the expected wheels are produced + expected_wheels = utils.expected_wheels("dummy_package", "0.1.0") + assert set(actual_wheels) == set(expected_wheels) From 4fb7874ca3c7c5982dba1bb5cbe6df4eb23e2136 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sun, 31 May 2020 20:13:52 +0100 Subject: [PATCH 04/18] chore: address PR feedback Signed-off-by: heitorlessa --- cibuildwheel/__main__.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 77b5aa99..9e4e57ae 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -310,18 +310,6 @@ def detect_warnings(platform: str, build_options: BuildOptions) -> List[str]: def detect_setup_pyproject_existence(package_dir: str) -> bool: - """Detects whether setup.py, or pyproject.toml is at package dir - - Parameters - ---------- - package_dir : str - Package directory path - - Returns - ------- - bool - Whether setup.py, or pyproject.toml exists - """ exists = False if os.path.exists(os.path.join(package_dir, 'setup.py')): exists = True From f9401d94c2821dcbc00e858ce6d8a7e9454f6378 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sun, 31 May 2020 20:14:24 +0100 Subject: [PATCH 05/18] fix: support py2.7 to accommodate current setup Signed-off-by: heitorlessa --- test/test_poetry_project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_poetry_project.py b/test/test_poetry_project.py index 01c3f83c..bf7c6bd4 100644 --- a/test/test_poetry_project.py +++ b/test/test_poetry_project.py @@ -12,13 +12,14 @@ classifiers=[ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", + "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", ] license = "MIT" [tool.poetry.dependencies] -python = "^3.6" +python = "^2.7" [tool.poetry.dev-dependencies] [build-system] requires = ["poetry>=0.12"] From a8bdac07e6ed8e1ed6725b8f523558d5690385bf Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sun, 31 May 2020 22:02:27 +0100 Subject: [PATCH 06/18] fix: python version requirement range Signed-off-by: heitorlessa --- test/test_poetry_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_poetry_project.py b/test/test_poetry_project.py index bf7c6bd4..e9e278c4 100644 --- a/test/test_poetry_project.py +++ b/test/test_poetry_project.py @@ -19,7 +19,7 @@ classifiers=[ ] license = "MIT" [tool.poetry.dependencies] -python = "^2.7" +python = ">=2.7" [tool.poetry.dev-dependencies] [build-system] requires = ["poetry>=0.12"] From 8a25718c71c55b7011756b90f2d5717ca3c505e4 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sun, 31 May 2020 22:37:52 +0100 Subject: [PATCH 07/18] fix: ignores images with outdated pip version Signed-off-by: heitorlessa --- test/test_poetry_project.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test_poetry_project.py b/test/test_poetry_project.py index e9e278c4..9d5c3813 100644 --- a/test/test_poetry_project.py +++ b/test/test_poetry_project.py @@ -35,8 +35,14 @@ def test_poetry_package(tmp_path): project_dir = tmp_path / "project" poetry_dummy_project.generate(project_dir) - # build the wheels - actual_wheels = utils.cibuildwheel_run(project_dir) + + # Poetry is installed during wheels built by pip + # however, one of poetry deps require cryptography + # which fails to build in outdated pip versions + # more info: https://github.com/pyca/cryptography/issues/5101 + skip_outdated_pip_images_env = {'CIBW_SKIP': 'cp27-* *-win32 *-manylinux_i686'} + + actual_wheels = utils.cibuildwheel_run(project_dir, add_env=skip_outdated_pip_images_env) # check that the expected wheels are produced expected_wheels = utils.expected_wheels("dummy_package", "0.1.0") From ab4f5209b50951f793f3ec03c92a521be3a6e20f Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sun, 31 May 2020 22:39:19 +0100 Subject: [PATCH 08/18] improv: document test given when then Signed-off-by: heitorlessa --- test/test_poetry_project.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/test_poetry_project.py b/test/test_poetry_project.py index 9d5c3813..80dbda21 100644 --- a/test/test_poetry_project.py +++ b/test/test_poetry_project.py @@ -33,6 +33,8 @@ poetry_dummy_project.files["pyproject.toml"] = pyproject_package_file def test_poetry_package(tmp_path): + # GIVEN a project that only has pyproject.toml + # managed by poetry project_dir = tmp_path / "project" poetry_dummy_project.generate(project_dir) @@ -42,8 +44,11 @@ def test_poetry_package(tmp_path): # more info: https://github.com/pyca/cryptography/issues/5101 skip_outdated_pip_images_env = {'CIBW_SKIP': 'cp27-* *-win32 *-manylinux_i686'} + # WHEN we attempt to build wheels for multiple platforms + # for dummy_package package actual_wheels = utils.cibuildwheel_run(project_dir, add_env=skip_outdated_pip_images_env) - # check that the expected wheels are produced + + # THEN we should have a dummy_package wheel with version 0.1.0 expected_wheels = utils.expected_wheels("dummy_package", "0.1.0") assert set(actual_wheels) == set(expected_wheels) From 4e6246d2a7a7b14c8717b3281fa439b4798fa783 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sun, 31 May 2020 22:43:30 +0100 Subject: [PATCH 09/18] chore: flake8 Signed-off-by: heitorlessa --- test/test_poetry_project.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_poetry_project.py b/test/test_poetry_project.py index 80dbda21..e5f46220 100644 --- a/test/test_poetry_project.py +++ b/test/test_poetry_project.py @@ -48,7 +48,6 @@ def test_poetry_package(tmp_path): # for dummy_package package actual_wheels = utils.cibuildwheel_run(project_dir, add_env=skip_outdated_pip_images_env) - # THEN we should have a dummy_package wheel with version 0.1.0 expected_wheels = utils.expected_wheels("dummy_package", "0.1.0") assert set(actual_wheels) == set(expected_wheels) From d41cf65173cd0897124f92f85c5e0801ab43740b Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Mon, 1 Jun 2020 08:32:35 +0100 Subject: [PATCH 10/18] improv: address Henrii's feedback Signed-off-by: heitorlessa --- cibuildwheel/__main__.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 9e4e57ae..87d74b30 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -310,14 +310,10 @@ def detect_warnings(platform: str, build_options: BuildOptions) -> List[str]: def detect_setup_pyproject_existence(package_dir: str) -> bool: - exists = False - if os.path.exists(os.path.join(package_dir, 'setup.py')): - exists = True - - if os.path.exists(os.path.join(package_dir, 'pyproject.toml')): - exists = True - - return exists + return any( + os.path.exists(os.path.join(package_dir, name)) + for name in ["setup.py", "setup.cfg", "pyproject.toml"] + ) if __name__ == '__main__': From a15a5f1c0f368888e8526f4367fec882fd14b449 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Mon, 1 Jun 2020 08:58:24 +0100 Subject: [PATCH 11/18] fix: exclude pypy build that's failing Signed-off-by: heitorlessa --- test/test_poetry_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_poetry_project.py b/test/test_poetry_project.py index e5f46220..da28a94b 100644 --- a/test/test_poetry_project.py +++ b/test/test_poetry_project.py @@ -42,7 +42,7 @@ def test_poetry_package(tmp_path): # however, one of poetry deps require cryptography # which fails to build in outdated pip versions # more info: https://github.com/pyca/cryptography/issues/5101 - skip_outdated_pip_images_env = {'CIBW_SKIP': 'cp27-* *-win32 *-manylinux_i686'} + skip_outdated_pip_images_env = {'CIBW_SKIP': 'cp27-* *-win32 *-manylinux_i686 pp*'} # WHEN we attempt to build wheels for multiple platforms # for dummy_package package From 63eda18cf9581524d463bf71aeeb15fa5f67708c Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Mon, 1 Jun 2020 09:31:54 +0100 Subject: [PATCH 12/18] chore: increase test verbosity to capture errors Signed-off-by: heitorlessa --- bin/run_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/run_tests.py b/bin/run_tests.py index 93c23e88..2b28ec0c 100755 --- a/bin/run_tests.py +++ b/bin/run_tests.py @@ -12,4 +12,4 @@ if __name__ == '__main__': subprocess.check_call([sys.executable, '-m', 'pytest', 'unit_test']) # run the integration tests - subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', 'test']) + subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', 'test', '-vv']) From 3de38fc679b9927e8920a328bf7443c44a45e266 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Mon, 1 Jun 2020 09:56:03 +0100 Subject: [PATCH 13/18] fix: assert single wheel workaround Signed-off-by: heitorlessa --- test/test_poetry_project.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/test_poetry_project.py b/test/test_poetry_project.py index da28a94b..f4a3658b 100644 --- a/test/test_poetry_project.py +++ b/test/test_poetry_project.py @@ -49,5 +49,8 @@ def test_poetry_package(tmp_path): actual_wheels = utils.cibuildwheel_run(project_dir, add_env=skip_outdated_pip_images_env) # THEN we should have a dummy_package wheel with version 0.1.0 - expected_wheels = utils.expected_wheels("dummy_package", "0.1.0") + # expected_wheels = utils.expected_wheels("dummy_package", "0.1.0") + + # Workaround while I await maintainers on correct assertion + expected_wheels = {"dummy_package-0.1.0-py2.py3-none-any.whl"} assert set(actual_wheels) == set(expected_wheels) From 15f167843925e9762abfdc9cea3398f3b6232d28 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Mon, 1 Jun 2020 10:44:58 +0100 Subject: [PATCH 14/18] fix: install poetry before build for windows Signed-off-by: heitorlessa --- test/test_poetry_project.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/test_poetry_project.py b/test/test_poetry_project.py index f4a3658b..dac1f13f 100644 --- a/test/test_poetry_project.py +++ b/test/test_poetry_project.py @@ -38,15 +38,24 @@ def test_poetry_package(tmp_path): project_dir = tmp_path / "project" poetry_dummy_project.generate(project_dir) + # These are temporary as I understand cibuildwheels + # behaviour across different CIs + # Poetry is installed during wheels built by pip # however, one of poetry deps require cryptography # which fails to build in outdated pip versions # more info: https://github.com/pyca/cryptography/issues/5101 - skip_outdated_pip_images_env = {'CIBW_SKIP': 'cp27-* *-win32 *-manylinux_i686 pp*'} + poetry_project_env = {"CIBW_SKIP": "cp27-* *-win32 *-manylinux_i686 pp*"} + + # Pip on Windows don't seem to honour installing build system deps + # as it happens on Mac/Linux according to CI tests + # so we need to install `poetry` before we build the wheels + # https://dev.azure.com/joerick0429/cibuildwheel/_build/results?buildId=1315&view=logs&j=fff2fde4-faa2-579c-a2fc-f5ab27662b77&t=ba46a93f-85b8-5ca5-6207-999df763f341&l=396 + poetry_project_env["CIBW_BEFORE_BUILD"] = "pip install poetry" # WHEN we attempt to build wheels for multiple platforms # for dummy_package package - actual_wheels = utils.cibuildwheel_run(project_dir, add_env=skip_outdated_pip_images_env) + actual_wheels = utils.cibuildwheel_run(project_dir, add_env=poetry_project_env) # THEN we should have a dummy_package wheel with version 0.1.0 # expected_wheels = utils.expected_wheels("dummy_package", "0.1.0") From 004fc03899b6dddc93a1685745ccb8546cf031e3 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Mon, 1 Jun 2020 13:21:52 +0100 Subject: [PATCH 15/18] fix: remove integ test --- test/test_poetry_project.py | 65 ------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 test/test_poetry_project.py diff --git a/test/test_poetry_project.py b/test/test_poetry_project.py deleted file mode 100644 index dac1f13f..00000000 --- a/test/test_poetry_project.py +++ /dev/null @@ -1,65 +0,0 @@ -from . import test_projects -from . import utils - -pyproject_package_file = """ -[tool.poetry] -name = "dummy_package" -version = "0.1.0" -description = "dummy" -authors = ["cibuildwheel poetry test"] -classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", -] -license = "MIT" -[tool.poetry.dependencies] -python = ">=2.7" -[tool.poetry.dev-dependencies] -[build-system] -requires = ["poetry>=0.12"] -build-backend = "poetry.masonry.api" -""" - -poetry_dummy_project = test_projects.TestProject() -poetry_dummy_project.files["dummy_package/__init__.py"] = "" -poetry_dummy_project.files["pyproject.toml"] = pyproject_package_file - - -def test_poetry_package(tmp_path): - - # GIVEN a project that only has pyproject.toml - # managed by poetry - project_dir = tmp_path / "project" - poetry_dummy_project.generate(project_dir) - - # These are temporary as I understand cibuildwheels - # behaviour across different CIs - - # Poetry is installed during wheels built by pip - # however, one of poetry deps require cryptography - # which fails to build in outdated pip versions - # more info: https://github.com/pyca/cryptography/issues/5101 - poetry_project_env = {"CIBW_SKIP": "cp27-* *-win32 *-manylinux_i686 pp*"} - - # Pip on Windows don't seem to honour installing build system deps - # as it happens on Mac/Linux according to CI tests - # so we need to install `poetry` before we build the wheels - # https://dev.azure.com/joerick0429/cibuildwheel/_build/results?buildId=1315&view=logs&j=fff2fde4-faa2-579c-a2fc-f5ab27662b77&t=ba46a93f-85b8-5ca5-6207-999df763f341&l=396 - poetry_project_env["CIBW_BEFORE_BUILD"] = "pip install poetry" - - # WHEN we attempt to build wheels for multiple platforms - # for dummy_package package - actual_wheels = utils.cibuildwheel_run(project_dir, add_env=poetry_project_env) - - # THEN we should have a dummy_package wheel with version 0.1.0 - # expected_wheels = utils.expected_wheels("dummy_package", "0.1.0") - - # Workaround while I await maintainers on correct assertion - expected_wheels = {"dummy_package-0.1.0-py2.py3-none-any.whl"} - assert set(actual_wheels) == set(expected_wheels) From d9a317c370f9bbc83d5680f15baf5abbd5258936 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Mon, 1 Jun 2020 14:30:14 +0100 Subject: [PATCH 16/18] fix: address Yannick's PR feedback --- cibuildwheel/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 87d74b30..4706a2a3 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -161,7 +161,7 @@ def main() -> None: # This needs to be passed on to the docker container in linux.py os.environ['CIBUILDWHEEL'] = '1' - if not detect_setup_pyproject_existence(package_dir): + if not is_python_project(package_dir): print('cibuildwheel: Could not find setup.py at root of package', file=sys.stderr) exit(2) @@ -309,7 +309,7 @@ def detect_warnings(platform: str, build_options: BuildOptions) -> List[str]: return warnings -def detect_setup_pyproject_existence(package_dir: str) -> bool: +def is_python_project(package_dir: str) -> bool: return any( os.path.exists(os.path.join(package_dir, name)) for name in ["setup.py", "setup.cfg", "pyproject.toml"] From 35ea7b63078d5bedafd4663f6ab9349d6b590efd Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Tue, 2 Jun 2020 20:02:54 +0100 Subject: [PATCH 17/18] Remove debugging flags --- bin/run_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/run_tests.py b/bin/run_tests.py index 2b28ec0c..93c23e88 100755 --- a/bin/run_tests.py +++ b/bin/run_tests.py @@ -12,4 +12,4 @@ if __name__ == '__main__': subprocess.check_call([sys.executable, '-m', 'pytest', 'unit_test']) # run the integration tests - subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', 'test', '-vv']) + subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', 'test']) From 4e15e202c8a12812a5691725757ff9d0258c0ee3 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Tue, 2 Jun 2020 20:03:04 +0100 Subject: [PATCH 18/18] style- inline function --- cibuildwheel/__main__.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 4706a2a3..95bc96b9 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -161,8 +161,9 @@ def main() -> None: # This needs to be passed on to the docker container in linux.py os.environ['CIBUILDWHEEL'] = '1' - if not is_python_project(package_dir): - print('cibuildwheel: Could not find setup.py at root of package', file=sys.stderr) + if not any(os.path.exists(os.path.join(package_dir, name)) + for name in ["setup.py", "setup.cfg", "pyproject.toml"]): + print('cibuildwheel: Could not find setup.py, setup.cfg or pyproject.toml at root of package', file=sys.stderr) exit(2) if args.print_build_identifiers: @@ -309,12 +310,5 @@ def detect_warnings(platform: str, build_options: BuildOptions) -> List[str]: return warnings -def is_python_project(package_dir: str) -> bool: - return any( - os.path.exists(os.path.join(package_dir, name)) - for name in ["setup.py", "setup.cfg", "pyproject.toml"] - ) - - if __name__ == '__main__': main()