fix: support empty CIBW_PLATFORM (#1969)
* fix: support empty CIBW_PLATFORM Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: support empty CIBW_PLATFORM * Add test --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: mayeut <mayeut@users.noreply.github.com>
This commit is contained in:
co-authored by
mayeut
parent
c6dd39bd83
commit
3580374b18
@@ -240,7 +240,7 @@ def _compute_platform_auto() -> PlatformName:
|
|||||||
|
|
||||||
|
|
||||||
def _compute_platform(args: CommandLineArguments) -> PlatformName:
|
def _compute_platform(args: CommandLineArguments) -> PlatformName:
|
||||||
platform_option_value = args.platform or os.environ.get("CIBW_PLATFORM", "auto")
|
platform_option_value = args.platform or os.environ.get("CIBW_PLATFORM", "") or "auto"
|
||||||
|
|
||||||
if args.only and args.platform is not None:
|
if args.only and args.platform is not None:
|
||||||
msg = "--platform cannot be specified with --only, it is computed from --only"
|
msg = "--platform cannot be specified with --only, it is computed from --only"
|
||||||
|
|||||||
+4
-5
@@ -23,15 +23,14 @@ EMULATED_ARCHS: Final[list[str]] = sorted(
|
|||||||
)
|
)
|
||||||
SINGLE_PYTHON_VERSION: Final[tuple[int, int]] = (3, 12)
|
SINGLE_PYTHON_VERSION: Final[tuple[int, int]] = (3, 12)
|
||||||
|
|
||||||
platform: str
|
platform = os.environ.get("CIBW_PLATFORM", "")
|
||||||
|
if platform:
|
||||||
if "CIBW_PLATFORM" in os.environ:
|
pass
|
||||||
platform = os.environ["CIBW_PLATFORM"]
|
|
||||||
elif sys.platform.startswith("linux"):
|
elif sys.platform.startswith("linux"):
|
||||||
platform = "linux"
|
platform = "linux"
|
||||||
elif sys.platform.startswith("darwin"):
|
elif sys.platform.startswith("darwin"):
|
||||||
platform = "macos"
|
platform = "macos"
|
||||||
elif sys.platform in ["win32", "cygwin"]:
|
elif sys.platform.startswith(("win32", "cygwin")):
|
||||||
platform = "windows"
|
platform = "windows"
|
||||||
else:
|
else:
|
||||||
msg = f"Unsupported platform {sys.platform!r}"
|
msg = f"Unsupported platform {sys.platform!r}"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from cibuildwheel.architecture import Architecture
|
|||||||
from ..conftest import MOCK_PACKAGE_DIR
|
from ..conftest import MOCK_PACKAGE_DIR
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("option_value", [None, "auto"])
|
@pytest.mark.parametrize("option_value", [None, "auto", ""])
|
||||||
def test_platform_unset_or_auto(monkeypatch, intercepted_build_args, option_value):
|
def test_platform_unset_or_auto(monkeypatch, intercepted_build_args, option_value):
|
||||||
if option_value is None:
|
if option_value is None:
|
||||||
monkeypatch.delenv("CIBW_PLATFORM", raising=False)
|
monkeypatch.delenv("CIBW_PLATFORM", raising=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user