Skip to content

Commit

Permalink
fix: minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Apr 27, 2022
1 parent 958a7c3 commit 68dd0d0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
29 changes: 10 additions & 19 deletions cibuildwheel/__main__.py
Expand Up @@ -24,7 +24,6 @@
Unbuffered,
chdir,
detect_ci_provider,
format_safe,
)


Expand Down Expand Up @@ -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.
""",
)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion cibuildwheel/options.py
Expand Up @@ -22,6 +22,7 @@
import tomllib
else:
import tomli as tomllib

from packaging.specifiers import SpecifierSet

from .architecture import Architecture
Expand All @@ -36,6 +37,7 @@
DependencyConstraints,
TestSelector,
cached_property,
format_safe,
resources_dir,
selector_matches,
strtobool,
Expand Down Expand Up @@ -344,7 +346,7 @@ def config_file_path(self) -> Optional[Path]:
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"
Expand Down
2 changes: 1 addition & 1 deletion docs/cpp_standards.md
Expand Up @@ -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.

Expand Down
10 changes: 5 additions & 5 deletions test/test_from_sdist.py
Expand Up @@ -18,7 +18,7 @@ def make_sdist(project: TestProject, working_dir: Path) -> Path:

sdist_dir = working_dir / "sdist"
subprocess.run(
[sys.executable, "-m", "build", "--sdist", "--outdir", str(sdist_dir), str(project_dir)],
[sys.executable, "-m", "build", "--sdist", "--outdir", sdist_dir, project_dir],
check=True,
)

Expand All @@ -39,8 +39,8 @@ def cibuildwheel_from_sdist_run(sdist_path, add_env=None, config_file=None):
"cibuildwheel",
*(["--config-file", config_file] if config_file else []),
"--output-dir",
str(tmp_output_dir),
str(sdist_path),
tmp_output_dir,
sdist_path,
],
env=env,
check=True,
Expand Down Expand Up @@ -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
Expand All @@ -188,7 +188,7 @@ def test_argument_passthrough(tmp_path, capfd):
sys.executable,
"-m",
"cibuildwheel",
str(sdist_path),
sdist_path,
"--platform",
"linux",
"--archs",
Expand Down

0 comments on commit 68dd0d0

Please sign in to comment.