From b1e8549bb1a7d32a21f98c2ae9167a5d4b72ee83 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 27 Apr 2022 12:31:42 -0400 Subject: [PATCH] fix: minor cleanup --- cibuildwheel/__main__.py | 29 ++++++++++------------------- cibuildwheel/options.py | 4 +++- docs/cpp_standards.md | 2 +- test/test_from_sdist.py | 2 +- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 0e407456..af10eafe 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -24,7 +24,6 @@ from cibuildwheel.util import ( Unbuffered, chdir, detect_ci_provider, - format_safe, ) @@ -75,9 +74,9 @@ def main() -> None: "--config-file", default="", help=""" - TOML config file. Default: "", meaning {package}/pyproject.toml, - if it exists. To refer to a project inside your project, use {package} - or {project}. + TOML config file. Default: "", meaning {package}/pyproject.toml, if + it exists. To refer to a project inside your project, use {package}; + this matters if you build from an SDist. """, ) @@ -87,8 +86,8 @@ def main() -> None: type=Path, nargs="?", help=""" - Path to the package that you want wheels for. Must be a - subdirectory of the working directory. When set, the working + Path to the package that you want wheels for. Must be a subdirectory + of the working directory. When set to a directory, the working directory is still considered the 'project' and is copied into the Docker container on Linux. Default: the working directory. This can also be a tar.gz file - if it is, then --config-file and @@ -117,8 +116,9 @@ def main() -> None: args = parser.parse_args(namespace=CommandLineArguments()) - # These are always relative to the base directory, even in SDist builds args.package_dir = args.package_dir.resolve() + + # This are always relative to the base directory, even in SDist builds args.output_dir = Path( args.output_dir if args.output_dir is not None @@ -130,9 +130,6 @@ def main() -> None: build_in_directory(args) return - if not args.package_dir.name.endswith("tar.gz"): - raise SystemExit("Must be a tar.gz file if a file is given.") - # Tarfile builds require extraction and changing the directory with tempfile.TemporaryDirectory(prefix="cibw-sdist-") as temp_dir_str: temp_dir = Path(temp_dir_str) @@ -145,22 +142,16 @@ def main() -> None: except ValueError: raise SystemExit("invalid sdist: didn't contain a single dir") from None + # This is now the new package dir args.package_dir = project_dir.resolve() - if args.config_file: - # expand the placeholders if they're used - config_file_path = format_safe( - args.config_file, - project=project_dir, - package=project_dir, - ) - args.config_file = str(Path(config_file_path).resolve()) - with chdir(temp_dir): build_in_directory(args) def build_in_directory(args: CommandLineArguments) -> None: + platform: PlatformName + if args.platform != "auto": platform = args.platform else: diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index 6f249d7e..bf707b23 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -22,6 +22,7 @@ if sys.version_info >= (3, 11): import tomllib else: import tomli as tomllib + from packaging.specifiers import SpecifierSet from .architecture import Architecture @@ -36,6 +37,7 @@ from .util import ( DependencyConstraints, TestSelector, cached_property, + format_safe, resources_dir, selector_matches, strtobool, @@ -344,7 +346,7 @@ class Options: args = self.command_line_arguments if args.config_file: - return Path(args.config_file.format(package=args.package_dir)) + return Path(format_safe(args.config_file, package=args.package_dir)) # return pyproject.toml, if it's available pyproject_toml_path = Path(args.package_dir) / "pyproject.toml" diff --git a/docs/cpp_standards.md b/docs/cpp_standards.md index 1f140618..468e4eb1 100644 --- a/docs/cpp_standards.md +++ b/docs/cpp_standards.md @@ -14,7 +14,7 @@ The old `manylinux1` image (based on CentOS 5) contains a version of GCC and lib OS X/macOS allows you to specify a so-called "deployment target" version that will ensure backwards compatibility with older versions of macOS. One way to do this is by setting the `MACOSX_DEPLOYMENT_TARGET` environment variable. -However, to enable modern C++ standards, the deploment target needs to be set high enough (since older OS X/macOS versions did not have the necessary modern C++ standard library). +However, to enable modern C++ standards, the deployment target needs to be set high enough (since older OS X/macOS versions did not have the necessary modern C++ standard library). To get C++11 and C++14 support, `MACOSX_DEPLOYMENT_TARGET` needs to be set to (at least) `"10.9"`. By default, `cibuildwheel` already does this, building 64-bit-only wheels for macOS 10.9 and later. diff --git a/test/test_from_sdist.py b/test/test_from_sdist.py index 31eb718c..4af67015 100644 --- a/test/test_from_sdist.py +++ b/test/test_from_sdist.py @@ -161,7 +161,7 @@ def test_internal_config_file_argument(tmp_path, capfd): actual_wheels = cibuildwheel_from_sdist_run( sdist_path, add_env={"CIBW_BUILD": "cp39-*"}, - config_file="{project}/wheel_build_config.toml", + config_file="{package}/wheel_build_config.toml", ) # check that the expected wheels are produced