More type annotations after rebasing
This commit is contained in:
@@ -134,7 +134,7 @@ def main() -> None:
|
|||||||
|
|
||||||
dependency_versions = get_option_from_environment('CIBW_DEPENDENCY_VERSIONS', platform=platform, default='pinned')
|
dependency_versions = get_option_from_environment('CIBW_DEPENDENCY_VERSIONS', platform=platform, default='pinned')
|
||||||
if dependency_versions == 'pinned':
|
if dependency_versions == 'pinned':
|
||||||
dependency_constraints = DependencyConstraints.with_defaults()
|
dependency_constraints = DependencyConstraints.with_defaults() # type: Optional[DependencyConstraints]
|
||||||
elif dependency_versions == 'latest':
|
elif dependency_versions == 'latest':
|
||||||
dependency_constraints = None
|
dependency_constraints = None
|
||||||
else:
|
else:
|
||||||
@@ -169,6 +169,7 @@ def main() -> None:
|
|||||||
print_build_identifiers(platform, build_selector)
|
print_build_identifiers(platform, build_selector)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
manylinux_images = None # type: Optional[Dict[str, str]]
|
||||||
if platform == 'linux':
|
if platform == 'linux':
|
||||||
pinned_docker_images_file = os.path.join(
|
pinned_docker_images_file = os.path.join(
|
||||||
os.path.dirname(__file__), 'resources', 'pinned_docker_images.cfg'
|
os.path.dirname(__file__), 'resources', 'pinned_docker_images.cfg'
|
||||||
@@ -181,8 +182,7 @@ def main() -> None:
|
|||||||
# 'pypy_x86_64': {'manylinux2010': '...' }
|
# 'pypy_x86_64': {'manylinux2010': '...' }
|
||||||
# ... }
|
# ... }
|
||||||
|
|
||||||
manylinux_images = {} # type: Optional[Dict[str, str]]
|
manylinux_images = {}
|
||||||
assert manylinux_images is not None # Weird problem with mypy
|
|
||||||
|
|
||||||
for build_platform in ['x86_64', 'i686', 'pypy_x86_64', 'aarch64', 'ppc64le', 's390x']:
|
for build_platform in ['x86_64', 'i686', 'pypy_x86_64', 'aarch64', 'ppc64le', 's390x']:
|
||||||
pinned_images = all_pinned_docker_images[build_platform]
|
pinned_images = all_pinned_docker_images[build_platform]
|
||||||
@@ -200,9 +200,6 @@ def main() -> None:
|
|||||||
|
|
||||||
manylinux_images[build_platform] = image
|
manylinux_images[build_platform] = image
|
||||||
|
|
||||||
else:
|
|
||||||
manylinux_images = None
|
|
||||||
|
|
||||||
build_options = BuildOptions(
|
build_options = BuildOptions(
|
||||||
package_dir=package_dir,
|
package_dir=package_dir,
|
||||||
output_dir=output_dir,
|
output_dir=output_dir,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import sys
|
|||||||
import textwrap
|
import textwrap
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from typing import Callable, List, NamedTuple
|
from typing import Callable, List, NamedTuple, Optional, Union
|
||||||
|
|
||||||
from .util import (
|
from .util import (
|
||||||
BuildOptions,
|
BuildOptions,
|
||||||
@@ -15,14 +15,14 @@ from .util import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def call(args, input=None, universal_newlines=False):
|
def call(args: List[str], input: Optional[Union[str, bytes]] = None, universal_newlines: bool = False) -> None:
|
||||||
print('+ ' + ' '.join(shlex.quote(a) for a in args))
|
print('+ ' + ' '.join(shlex.quote(a) for a in args))
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
args, input=input, universal_newlines=universal_newlines, check=True
|
args, input=input, universal_newlines=universal_newlines, check=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def matches_platform(identifier):
|
def matches_platform(identifier: str) -> bool:
|
||||||
pm = platform.machine()
|
pm = platform.machine()
|
||||||
if pm == "x86_64":
|
if pm == "x86_64":
|
||||||
# x86_64 machines can run i686 docker containers
|
# x86_64 machines can run i686 docker containers
|
||||||
@@ -79,7 +79,7 @@ def get_python_configurations(build_selector: Callable[[str], bool]) -> List[Pyt
|
|||||||
return [c for c in python_configurations if matches_platform(c.identifier) and build_selector(c.identifier)]
|
return [c for c in python_configurations if matches_platform(c.identifier) and build_selector(c.identifier)]
|
||||||
|
|
||||||
|
|
||||||
def build(options: BuildOptions):
|
def build(options: BuildOptions) -> None:
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['docker', '--version'])
|
subprocess.check_call(['docker', '--version'])
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from glob import glob
|
|||||||
|
|
||||||
from typing import Callable, Dict, List, Optional, NamedTuple, Union
|
from typing import Callable, Dict, List, Optional, NamedTuple, Union
|
||||||
|
|
||||||
|
from .environment import ParsedEnvironment
|
||||||
from .util import (
|
from .util import (
|
||||||
BuildOptions,
|
BuildOptions,
|
||||||
download,
|
download,
|
||||||
@@ -106,7 +107,7 @@ def install_pypy(version: str, url: str) -> str:
|
|||||||
return installation_bin_path
|
return installation_bin_path
|
||||||
|
|
||||||
|
|
||||||
def setup_python(python_configuration, dependency_constraint_flags, environment):
|
def setup_python(python_configuration: PythonConfiguration, dependency_constraint_flags: List[str], environment: ParsedEnvironment) -> Dict[str, str]:
|
||||||
if python_configuration.identifier.startswith('cp'):
|
if python_configuration.identifier.startswith('cp'):
|
||||||
installation_bin_path = install_cpython(python_configuration.version, python_configuration.url)
|
installation_bin_path = install_cpython(python_configuration.version, python_configuration.url)
|
||||||
elif python_configuration.identifier.startswith('pp'):
|
elif python_configuration.identifier.startswith('pp'):
|
||||||
@@ -164,7 +165,7 @@ def setup_python(python_configuration, dependency_constraint_flags, environment)
|
|||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
def build(options: BuildOptions):
|
def build(options: BuildOptions) -> None:
|
||||||
temp_dir = tempfile.mkdtemp(prefix='cibuildwheel')
|
temp_dir = tempfile.mkdtemp(prefix='cibuildwheel')
|
||||||
built_wheel_dir = os.path.join(temp_dir, 'built_wheel')
|
built_wheel_dir = os.path.join(temp_dir, 'built_wheel')
|
||||||
repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel')
|
repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel')
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import urllib.request
|
|||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
from typing import Dict, List, NamedTuple, Optional
|
from typing import Dict, List, NamedTuple, Optional, Type, TypeVar
|
||||||
|
|
||||||
from .environment import ParsedEnvironment
|
from .environment import ParsedEnvironment
|
||||||
|
|
||||||
@@ -82,18 +82,21 @@ def download(url: str, dest: str) -> None:
|
|||||||
response.close()
|
response.close()
|
||||||
|
|
||||||
|
|
||||||
|
DependencyConstraints_T = TypeVar('DependencyConstraints_T', bound='DependencyConstraints')
|
||||||
|
|
||||||
|
|
||||||
class DependencyConstraints:
|
class DependencyConstraints:
|
||||||
def __init__(self, base_file_path):
|
def __init__(self, base_file_path: str):
|
||||||
assert os.path.exists(base_file_path)
|
assert os.path.exists(base_file_path)
|
||||||
self.base_file_path = os.path.abspath(base_file_path)
|
self.base_file_path = os.path.abspath(base_file_path)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def with_defaults(cls):
|
def with_defaults(cls: Type[DependencyConstraints_T]) -> DependencyConstraints_T:
|
||||||
return cls(
|
return cls(
|
||||||
base_file_path=os.path.join(os.path.dirname(__file__), 'resources', 'constraints.txt')
|
base_file_path=os.path.join(os.path.dirname(__file__), 'resources', 'constraints.txt')
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_for_python_version(self, version):
|
def get_for_python_version(self, version: str) -> str:
|
||||||
version_parts = version.split('.')
|
version_parts = version.split('.')
|
||||||
|
|
||||||
# try to find a version-specific dependency file e.g. if
|
# try to find a version-specific dependency file e.g. if
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from zipfile import ZipFile
|
|||||||
|
|
||||||
from typing import Callable, Dict, List, Optional, NamedTuple
|
from typing import Callable, Dict, List, Optional, NamedTuple
|
||||||
|
|
||||||
|
from .environment import ParsedEnvironment
|
||||||
from .util import (
|
from .util import (
|
||||||
BuildOptions,
|
BuildOptions,
|
||||||
download,
|
download,
|
||||||
@@ -93,7 +94,7 @@ def install_pypy(version: str, arch: str, url: Optional[str]) -> str:
|
|||||||
return installation_path
|
return installation_path
|
||||||
|
|
||||||
|
|
||||||
def setup_python(python_configuration, dependency_constraint_flags, environment):
|
def setup_python(python_configuration: PythonConfiguration, dependency_constraint_flags: List[str], environment: ParsedEnvironment) -> Dict[str, str]:
|
||||||
nuget = 'C:\\cibw\\nuget.exe'
|
nuget = 'C:\\cibw\\nuget.exe'
|
||||||
if not os.path.exists(nuget):
|
if not os.path.exists(nuget):
|
||||||
download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget)
|
download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget)
|
||||||
@@ -145,7 +146,7 @@ def setup_python(python_configuration, dependency_constraint_flags, environment)
|
|||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
def build(options: BuildOptions):
|
def build(options: BuildOptions) -> None:
|
||||||
temp_dir = tempfile.mkdtemp(prefix='cibuildwheel')
|
temp_dir = tempfile.mkdtemp(prefix='cibuildwheel')
|
||||||
built_wheel_dir = os.path.join(temp_dir, 'built_wheel')
|
built_wheel_dir = os.path.join(temp_dir, 'built_wheel')
|
||||||
repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel')
|
repaired_wheel_dir = os.path.join(temp_dir, 'repaired_wheel')
|
||||||
|
|||||||
Reference in New Issue
Block a user