refactor: review comments
This commit is contained in:
+10
-12
@@ -67,6 +67,7 @@ def main() -> None:
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--output-dir",
|
"--output-dir",
|
||||||
type=Path,
|
type=Path,
|
||||||
|
default=Path(os.environ.get("CIBW_OUTPUT_DIR", "wheelhouse")),
|
||||||
help="Destination folder for the wheels. Default: wheelhouse.",
|
help="Destination folder for the wheels. Default: wheelhouse.",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -82,17 +83,18 @@ def main() -> None:
|
|||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"package_dir",
|
"package_dir",
|
||||||
|
metavar="PACKAGE",
|
||||||
default=Path("."),
|
default=Path("."),
|
||||||
type=Path,
|
type=Path,
|
||||||
nargs="?",
|
nargs="?",
|
||||||
help="""
|
help="""
|
||||||
Path to the package that you want wheels for. Must be a subdirectory
|
Path to the package that you want wheels for. Default: the working
|
||||||
of the working directory. When set to a directory, the working
|
directory. Can be a directory inside the working directory, or an
|
||||||
directory is still considered the 'project' and is copied into the
|
sdist. When set to a directory, the working directory is still
|
||||||
Docker container on Linux. Default: the working directory. This can
|
considered the 'project' and is copied into the Docker container
|
||||||
also be a tar.gz file - if it is, then --config-file and
|
on Linux. When set to a tar.gz sdist file, --config-file
|
||||||
--output-dir are relative to the current directory, and other paths
|
and --output-dir are relative to the current directory, and other
|
||||||
are relative to the expanded SDist directory.
|
paths are relative to the expanded SDist directory.
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -119,11 +121,7 @@ def main() -> None:
|
|||||||
args.package_dir = args.package_dir.resolve()
|
args.package_dir = args.package_dir.resolve()
|
||||||
|
|
||||||
# This are always relative to the base directory, even in SDist builds
|
# This are always relative to the base directory, even in SDist builds
|
||||||
args.output_dir = Path(
|
args.output_dir = args.output_dir.resolve()
|
||||||
args.output_dir
|
|
||||||
if args.output_dir is not None
|
|
||||||
else os.environ.get("CIBW_OUTPUT_DIR", "wheelhouse")
|
|
||||||
).resolve()
|
|
||||||
|
|
||||||
# Standard builds if a directory or non-existent path is given
|
# Standard builds if a directory or non-existent path is given
|
||||||
if not args.package_dir.is_file() and not args.package_dir.name.endswith("tar.gz"):
|
if not args.package_dir.is_file() and not args.package_dir.name.endswith("tar.gz"):
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from pathlib import Path
|
|||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
Dict,
|
Dict,
|
||||||
Iterator,
|
Generator,
|
||||||
List,
|
List,
|
||||||
Mapping,
|
Mapping,
|
||||||
NamedTuple,
|
NamedTuple,
|
||||||
@@ -48,7 +48,7 @@ from .util import (
|
|||||||
class CommandLineArguments:
|
class CommandLineArguments:
|
||||||
platform: Literal["auto", "linux", "macos", "windows"]
|
platform: Literal["auto", "linux", "macos", "windows"]
|
||||||
archs: Optional[str]
|
archs: Optional[str]
|
||||||
output_dir: Optional[Path]
|
output_dir: Path
|
||||||
config_file: str
|
config_file: str
|
||||||
package_dir: Path
|
package_dir: Path
|
||||||
print_build_identifiers: bool
|
print_build_identifiers: bool
|
||||||
@@ -265,7 +265,7 @@ class OptionsReader:
|
|||||||
]
|
]
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def identifier(self, identifier: Optional[str]) -> Iterator[None]:
|
def identifier(self, identifier: Optional[str]) -> Generator[None, None, None]:
|
||||||
self.current_identifier = identifier
|
self.current_identifier = identifier
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
@@ -363,7 +363,6 @@ class Options:
|
|||||||
@property
|
@property
|
||||||
def globals(self) -> GlobalOptions:
|
def globals(self) -> GlobalOptions:
|
||||||
args = self.command_line_arguments
|
args = self.command_line_arguments
|
||||||
assert args.output_dir is not None, "Must be resolved"
|
|
||||||
package_dir = args.package_dir
|
package_dir = args.package_dir
|
||||||
output_dir = args.output_dir
|
output_dir = args.output_dir
|
||||||
|
|
||||||
|
|||||||
@@ -171,44 +171,3 @@ def test_internal_config_file_argument(tmp_path, capfd):
|
|||||||
# check that before-all was run
|
# check that before-all was run
|
||||||
captured = capfd.readouterr()
|
captured = capfd.readouterr()
|
||||||
assert "test log statement from before-all 1829" in captured.out
|
assert "test log statement from before-all 1829" in captured.out
|
||||||
|
|
||||||
|
|
||||||
def test_argument_passthrough(tmp_path, capfd):
|
|
||||||
basic_project = test_projects.new_c_project()
|
|
||||||
|
|
||||||
# make an sdist of a project
|
|
||||||
sdist_dir = tmp_path / "sdist"
|
|
||||||
sdist_dir.mkdir()
|
|
||||||
sdist_path = make_sdist(basic_project, sdist_dir)
|
|
||||||
|
|
||||||
# make a call that should pass some args through to cibuildwheel
|
|
||||||
# this asks cibuildwheel to print the ppc64le build identifiers
|
|
||||||
process = subprocess.run(
|
|
||||||
[
|
|
||||||
sys.executable,
|
|
||||||
"-m",
|
|
||||||
"cibuildwheel",
|
|
||||||
str(sdist_path),
|
|
||||||
"--platform",
|
|
||||||
"linux",
|
|
||||||
"--archs",
|
|
||||||
"ppc64le",
|
|
||||||
"--print-build-identifiers",
|
|
||||||
],
|
|
||||||
env={
|
|
||||||
**os.environ,
|
|
||||||
"CIBW_BUILD": "cp38-*",
|
|
||||||
},
|
|
||||||
check=True,
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
universal_newlines=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
# fmt: off
|
|
||||||
assert process.stdout == textwrap.dedent(
|
|
||||||
"""
|
|
||||||
cp38-manylinux_ppc64le
|
|
||||||
cp38-musllinux_ppc64le
|
|
||||||
"""
|
|
||||||
).lstrip()
|
|
||||||
# fmt: on
|
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ def get_default_command_line_arguments() -> CommandLineArguments:
|
|||||||
defaults.allow_empty = False
|
defaults.allow_empty = False
|
||||||
defaults.archs = None
|
defaults.archs = None
|
||||||
defaults.config_file = ""
|
defaults.config_file = ""
|
||||||
defaults.output_dir = Path("wheelhouse") # This must be resolved from "None" before passing
|
defaults.output_dir = Path("wheelhouse")
|
||||||
defaults.package_dir = Path(".")
|
defaults.package_dir = Path(".")
|
||||||
defaults.prerelease_pythons = False
|
defaults.prerelease_pythons = False
|
||||||
defaults.print_build_identifiers = False
|
defaults.print_build_identifiers = False
|
||||||
|
|||||||
Reference in New Issue
Block a user