refactor: standard arch checking in one place
This commit is contained in:
@@ -8,7 +8,7 @@ from .docker_container import DockerContainer
|
||||
from .logger import log
|
||||
from .util import (
|
||||
Architecture, BuildOptions, BuildSelector, NonPlatformWheelError,
|
||||
get_build_verbosity_extra_flags, prepare_command,
|
||||
allowed_architectures_check, get_build_verbosity_extra_flags, prepare_command,
|
||||
)
|
||||
from .typing import PathOrStr
|
||||
|
||||
@@ -71,6 +71,8 @@ def get_python_configurations(
|
||||
|
||||
|
||||
def build(options: BuildOptions) -> None:
|
||||
allowed_architectures_check("linux", options)
|
||||
|
||||
try:
|
||||
subprocess.check_output(['docker', '--version'])
|
||||
except Exception:
|
||||
|
||||
@@ -4,15 +4,14 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, NamedTuple, Optional, Sequence
|
||||
|
||||
from .environment import ParsedEnvironment
|
||||
from .logger import log
|
||||
from .util import (Architecture, BuildOptions, BuildSelector, NonPlatformWheelError,
|
||||
from .util import (BuildOptions, BuildSelector, NonPlatformWheelError,
|
||||
download, get_build_verbosity_extra_flags, get_pip_script,
|
||||
install_certifi_script, prepare_command)
|
||||
install_certifi_script, prepare_command, allowed_architectures_check)
|
||||
from .typing import PathOrStr
|
||||
|
||||
|
||||
@@ -187,11 +186,7 @@ def setup_python(python_configuration: PythonConfiguration,
|
||||
|
||||
|
||||
def build(options: BuildOptions) -> None:
|
||||
if not options.architectures <= {Architecture.x86_64}:
|
||||
raise ValueError(textwrap.dedent(f'''
|
||||
Invalid archs option {options.architectures}. macOS only supports x86_64 for the moment.
|
||||
If you want to set emulation architectures on Linux, use CIBW_ARCHS_LINUX instead.
|
||||
'''))
|
||||
allowed_architectures_check("macos", options)
|
||||
|
||||
temp_dir = Path(tempfile.mkdtemp(prefix='cibuildwheel'))
|
||||
built_wheel_dir = temp_dir / 'built_wheel'
|
||||
|
||||
@@ -2,6 +2,7 @@ import os
|
||||
import platform as platform_module
|
||||
import re
|
||||
import ssl
|
||||
import sys
|
||||
import functools
|
||||
import textwrap
|
||||
import urllib.request
|
||||
@@ -16,6 +17,11 @@ import certifi
|
||||
from .environment import ParsedEnvironment
|
||||
from .typing import PathOrStr
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
from typing_extensions import Literal
|
||||
else:
|
||||
from typing import Literal
|
||||
|
||||
|
||||
def prepare_command(command: str, **kwargs: PathOrStr) -> str:
|
||||
'''
|
||||
@@ -237,3 +243,33 @@ def detect_ci_provider() -> Optional[CIProvider]:
|
||||
return CIProvider.other
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
PRETTY_NAMES = {'linux': 'Linux', 'macos': 'macOS', 'windows': 'Windows'}
|
||||
|
||||
ALLOWED_ARCHITECTURES = {
|
||||
'linux': {Architecture.x86_64, Architecture.i686, Architecture.aarch64, Architecture.ppc64le, Architecture.s390x},
|
||||
'macos': {Architecture.x86_64},
|
||||
'windows': {Architecture.AMD64, Architecture.x86},
|
||||
}
|
||||
|
||||
|
||||
def allowed_architectures_check(
|
||||
name: Literal['linux', 'macos', 'windows'],
|
||||
options: BuildOptions,
|
||||
) -> None:
|
||||
|
||||
allowed_architectures = ALLOWED_ARCHITECTURES[name]
|
||||
|
||||
msg = f'{PRETTY_NAMES[name]} only supports {sorted(allowed_architectures)} at the moment.'
|
||||
|
||||
if name != 'linux':
|
||||
msg += ' If you want to set emulation architectures on Linux, use CIBW_ARCHS_LINUX instead.'
|
||||
|
||||
if not options.architectures <= allowed_architectures:
|
||||
msg = f'Invalid archs option {options.architectures}. ' + msg
|
||||
raise ValueError(msg)
|
||||
|
||||
if not options.architectures:
|
||||
msg = 'Empty archs option set. ' + msg
|
||||
raise ValueError(msg)
|
||||
|
||||
@@ -3,7 +3,6 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, NamedTuple, Optional, Sequence, Set
|
||||
from zipfile import ZipFile
|
||||
@@ -14,7 +13,7 @@ from .environment import ParsedEnvironment
|
||||
from .logger import log
|
||||
from .util import (Architecture, BuildOptions, BuildSelector, NonPlatformWheelError,
|
||||
download, get_build_verbosity_extra_flags, get_pip_script,
|
||||
prepare_command)
|
||||
prepare_command, allowed_architectures_check)
|
||||
from .typing import PathOrStr
|
||||
|
||||
IS_RUNNING_ON_AZURE = Path('C:\\hostedtoolcache').exists()
|
||||
@@ -210,13 +209,7 @@ def pep_518_cp35_workaround(package_dir: Path, env: Dict[str, str]) -> None:
|
||||
|
||||
|
||||
def build(options: BuildOptions) -> None:
|
||||
allowed_architectures = {Architecture.AMD64, Architecture.x86}
|
||||
if not options.architectures <= allowed_architectures:
|
||||
raise ValueError(textwrap.dedent(f'''
|
||||
Invalid archs option {options.architectures}. Windows only supports
|
||||
{sorted(allowed_architectures)}. If you want to set emulation
|
||||
architectures on Linux, use CIBW_ARCHS_LINUX instead.
|
||||
'''))
|
||||
allowed_architectures_check("windows", options)
|
||||
|
||||
temp_dir = Path(tempfile.mkdtemp(prefix='cibuildwheel'))
|
||||
built_wheel_dir = temp_dir / 'built_wheel'
|
||||
|
||||
Reference in New Issue
Block a user