Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support projects without setup.py (pyproject.toml and setup.cfg are also valid) #360

Merged
merged 18 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
heitorlessa marked this conversation as resolved.
Show resolved Hide resolved
print('cibuildwheel: Could not find setup.py at root of package', file=sys.stderr)
exit(2)

Expand Down Expand Up @@ -309,5 +309,16 @@ def detect_warnings(platform: str, build_options: BuildOptions) -> List[str]:
return warnings


def detect_setup_pyproject_existence(package_dir: str) -> bool:
exists = False
if os.path.exists(os.path.join(package_dir, 'setup.py')):
heitorlessa marked this conversation as resolved.
Show resolved Hide resolved
exists = True

if os.path.exists(os.path.join(package_dir, 'pyproject.toml')):
exists = True

return exists


if __name__ == '__main__':
main()
53 changes: 53 additions & 0 deletions test/test_poetry_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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)

# 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'}

# 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)

# 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)