mirror of
https://github.com/facebook/proxygen.git
synced 2025-08-10 05:22:59 +03:00
use python 3 type annotations
Summary: We don't support Python 2 anymore. Reviewed By: xavierd Differential Revision: D33715602 fbshipit-source-id: 6cf3dba83f8207f956cab8eb8dbb3a748e1d9f89
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4fb4756ec9
commit
5c779d26ba
@@ -10,6 +10,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from typing import Optional, Mapping
|
||||||
|
|
||||||
from .copytree import containing_repo_type
|
from .copytree import containing_repo_type
|
||||||
from .envfuncs import Env, add_path_entry
|
from .envfuncs import Env, add_path_entry
|
||||||
@@ -18,12 +19,6 @@ from .manifest import ContextGenerator
|
|||||||
from .platform import HostType, is_windows
|
from .platform import HostType, is_windows
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
import typing # noqa: F401
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def detect_project(path):
|
def detect_project(path):
|
||||||
repo_type, repo_root = containing_repo_type(path)
|
repo_type, repo_root = containing_repo_type(path)
|
||||||
if repo_type is None:
|
if repo_type is None:
|
||||||
@@ -312,10 +307,9 @@ def list_win32_subst_letters():
|
|||||||
|
|
||||||
|
|
||||||
def find_existing_win32_subst_for_path(
|
def find_existing_win32_subst_for_path(
|
||||||
path, # type: str
|
path: str,
|
||||||
subst_mapping, # type: typing.Mapping[str, str]
|
subst_mapping: Mapping[str, str],
|
||||||
):
|
) -> Optional[str]:
|
||||||
# type: (...) -> typing.Optional[str]
|
|
||||||
path = ntpath.normcase(ntpath.normpath(path))
|
path = ntpath.normcase(ntpath.normpath(path))
|
||||||
for letter, target in subst_mapping.items():
|
for letter, target in subst_mapping.items():
|
||||||
if ntpath.normcase(target) == path:
|
if ntpath.normcase(target) == path:
|
||||||
|
@@ -98,9 +98,7 @@ class PythonWheelBuilder(BuilderBase):
|
|||||||
that can be used by add_fb_python_library()/add_fb_python_executable() CMake rules.
|
that can be used by add_fb_python_library()/add_fb_python_executable() CMake rules.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _build(self, install_dirs, reconfigure):
|
def _build(self, install_dirs: List[str], reconfigure: bool) -> None:
|
||||||
# type: (List[str], bool) -> None
|
|
||||||
|
|
||||||
# When we are invoked, self.src_dir contains the unpacked wheel contents.
|
# When we are invoked, self.src_dir contains the unpacked wheel contents.
|
||||||
#
|
#
|
||||||
# Since a wheel file is just a zip file, the Fetcher code recognizes it as such
|
# Since a wheel file is just a zip file, the Fetcher code recognizes it as such
|
||||||
@@ -169,9 +167,7 @@ class PythonWheelBuilder(BuilderBase):
|
|||||||
# Run the build
|
# Run the build
|
||||||
self._run_cmake_build(install_dirs, reconfigure)
|
self._run_cmake_build(install_dirs, reconfigure)
|
||||||
|
|
||||||
def _run_cmake_build(self, install_dirs, reconfigure):
|
def _run_cmake_build(self, install_dirs: List[str], reconfigure: bool) -> None:
|
||||||
# type: (List[str], bool) -> None
|
|
||||||
|
|
||||||
cmake_builder = CMakeBuilder(
|
cmake_builder = CMakeBuilder(
|
||||||
build_opts=self.build_opts,
|
build_opts=self.build_opts,
|
||||||
ctx=self.ctx,
|
ctx=self.ctx,
|
||||||
@@ -187,9 +183,7 @@ class PythonWheelBuilder(BuilderBase):
|
|||||||
)
|
)
|
||||||
cmake_builder.build(install_dirs=install_dirs, reconfigure=reconfigure)
|
cmake_builder.build(install_dirs=install_dirs, reconfigure=reconfigure)
|
||||||
|
|
||||||
def _write_cmakelists(self, path_mapping, dependencies):
|
def _write_cmakelists(self, path_mapping: List[str], dependencies) -> None:
|
||||||
# type: (List[str]) -> None
|
|
||||||
|
|
||||||
cmake_path = os.path.join(self.build_dir, "CMakeLists.txt")
|
cmake_path = os.path.join(self.build_dir, "CMakeLists.txt")
|
||||||
with open(cmake_path, "w") as f:
|
with open(cmake_path, "w") as f:
|
||||||
f.write(CMAKE_HEADER.format(**self.template_format_dict))
|
f.write(CMAKE_HEADER.format(**self.template_format_dict))
|
||||||
@@ -221,9 +215,7 @@ class PythonWheelBuilder(BuilderBase):
|
|||||||
with open(output_path, "w") as f:
|
with open(output_path, "w") as f:
|
||||||
f.write(CMAKE_CONFIG_FILE.format(**self.template_format_dict))
|
f.write(CMAKE_CONFIG_FILE.format(**self.template_format_dict))
|
||||||
|
|
||||||
def _add_sources(self, path_mapping, src_path, install_path):
|
def _add_sources(self, path_mapping: List[str], src_path: str, install_path: str):
|
||||||
# type: (List[str], str, str) -> None
|
|
||||||
|
|
||||||
s = os.lstat(src_path)
|
s = os.lstat(src_path)
|
||||||
if not stat.S_ISDIR(s.st_mode):
|
if not stat.S_ISDIR(s.st_mode):
|
||||||
path_mapping[src_path] = install_path
|
path_mapping[src_path] = install_path
|
||||||
@@ -236,9 +228,7 @@ class PythonWheelBuilder(BuilderBase):
|
|||||||
os.path.join(install_path, entry),
|
os.path.join(install_path, entry),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _parse_wheel_name(self):
|
def _parse_wheel_name(self) -> WheelNameInfo:
|
||||||
# type: () -> WheelNameInfo
|
|
||||||
|
|
||||||
# The ArchiveFetcher prepends "manifest_name-", so strip that off first.
|
# The ArchiveFetcher prepends "manifest_name-", so strip that off first.
|
||||||
wheel_name = os.path.basename(self.src_dir)
|
wheel_name = os.path.basename(self.src_dir)
|
||||||
prefix = self.manifest.name + "-"
|
prefix = self.manifest.name + "-"
|
||||||
|
Reference in New Issue
Block a user