Skip to content

Commit 3505466

Browse files
committed
refactor: review comments
1 parent b1e8549 commit 3505466

File tree

4 files changed

+14
-58
lines changed

4 files changed

+14
-58
lines changed

cibuildwheel/__main__.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def main() -> None:
6767
parser.add_argument(
6868
"--output-dir",
6969
type=Path,
70+
default=Path(os.environ.get("CIBW_OUTPUT_DIR", "wheelhouse")),
7071
help="Destination folder for the wheels. Default: wheelhouse.",
7172
)
7273

@@ -82,17 +83,18 @@ def main() -> None:
8283

8384
parser.add_argument(
8485
"package_dir",
86+
metavar="PACKAGE",
8587
default=Path("."),
8688
type=Path,
8789
nargs="?",
8890
help="""
89-
Path to the package that you want wheels for. Must be a subdirectory
90-
of the working directory. When set to a directory, the working
91-
directory is still considered the 'project' and is copied into the
92-
Docker container on Linux. Default: the working directory. This can
93-
also be a tar.gz file - if it is, then --config-file and
94-
--output-dir are relative to the current directory, and other paths
95-
are relative to the expanded SDist directory.
91+
Path to the package that you want wheels for. Default: the working
92+
directory. Can be a directory inside the working directory, or an
93+
sdist. When set to a directory, the working directory is still
94+
considered the 'project' and is copied into the Docker container
95+
on Linux. When set to a tar.gz sdist file, --config-file
96+
and --output-dir are relative to the current directory, and other
97+
paths are relative to the expanded SDist directory.
9698
""",
9799
)
98100

@@ -119,11 +121,7 @@ def main() -> None:
119121
args.package_dir = args.package_dir.resolve()
120122

121123
# This are always relative to the base directory, even in SDist builds
122-
args.output_dir = Path(
123-
args.output_dir
124-
if args.output_dir is not None
125-
else os.environ.get("CIBW_OUTPUT_DIR", "wheelhouse")
126-
).resolve()
124+
args.output_dir = args.output_dir.resolve()
127125

128126
# Standard builds if a directory or non-existent path is given
129127
if not args.package_dir.is_file() and not args.package_dir.name.endswith("tar.gz"):

cibuildwheel/options.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import (
99
Any,
1010
Dict,
11-
Iterator,
11+
Generator,
1212
List,
1313
Mapping,
1414
NamedTuple,
@@ -48,7 +48,7 @@
4848
class CommandLineArguments:
4949
platform: Literal["auto", "linux", "macos", "windows"]
5050
archs: Optional[str]
51-
output_dir: Optional[Path]
51+
output_dir: Path
5252
config_file: str
5353
package_dir: Path
5454
print_build_identifiers: bool
@@ -265,7 +265,7 @@ def active_config_overrides(self) -> List[Override]:
265265
]
266266

267267
@contextmanager
268-
def identifier(self, identifier: Optional[str]) -> Iterator[None]:
268+
def identifier(self, identifier: Optional[str]) -> Generator[None, None, None]:
269269
self.current_identifier = identifier
270270
try:
271271
yield
@@ -363,7 +363,6 @@ def package_requires_python_str(self) -> Optional[str]:
363363
@property
364364
def globals(self) -> GlobalOptions:
365365
args = self.command_line_arguments
366-
assert args.output_dir is not None, "Must be resolved"
367366
package_dir = args.package_dir
368367
output_dir = args.output_dir
369368

test/test_from_sdist.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -171,44 +171,3 @@ def test_internal_config_file_argument(tmp_path, capfd):
171171
# check that before-all was run
172172
captured = capfd.readouterr()
173173
assert "test log statement from before-all 1829" in captured.out
174-
175-
176-
def test_argument_passthrough(tmp_path, capfd):
177-
basic_project = test_projects.new_c_project()
178-
179-
# make an sdist of a project
180-
sdist_dir = tmp_path / "sdist"
181-
sdist_dir.mkdir()
182-
sdist_path = make_sdist(basic_project, sdist_dir)
183-
184-
# make a call that should pass some args through to cibuildwheel
185-
# this asks cibuildwheel to print the ppc64le build identifiers
186-
process = subprocess.run(
187-
[
188-
sys.executable,
189-
"-m",
190-
"cibuildwheel",
191-
str(sdist_path),
192-
"--platform",
193-
"linux",
194-
"--archs",
195-
"ppc64le",
196-
"--print-build-identifiers",
197-
],
198-
env={
199-
**os.environ,
200-
"CIBW_BUILD": "cp38-*",
201-
},
202-
check=True,
203-
stdout=subprocess.PIPE,
204-
universal_newlines=True,
205-
)
206-
207-
# fmt: off
208-
assert process.stdout == textwrap.dedent(
209-
"""
210-
cp38-manylinux_ppc64le
211-
cp38-musllinux_ppc64le
212-
"""
213-
).lstrip()
214-
# fmt: on

unit_test/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def get_default_command_line_arguments() -> CommandLineArguments:
1010
defaults.allow_empty = False
1111
defaults.archs = None
1212
defaults.config_file = ""
13-
defaults.output_dir = Path("wheelhouse") # This must be resolved from "None" before passing
13+
defaults.output_dir = Path("wheelhouse")
1414
defaults.package_dir = Path(".")
1515
defaults.prerelease_pythons = False
1616
defaults.print_build_identifiers = False

0 commit comments

Comments
 (0)