Skip to content

Commit 2e560d3

Browse files
tharvikmatthiaskramm
authored andcommitted
Improve distutils (#418)
* remove old distutils * core done * ccompiler done * compilers done * archive_util done * dep_util done * dir_util done * file_util done * util done * dist done * debug, error, extension done * fancy_getopt done * filelist, log, spawn done * sysconfig done * text_file done * version done * cmd done * add command * add emxccompiler which is py2 only * command.build_py have spec only in py3 * make pytype happy by resolving relative import
1 parent 2c21f27 commit 2e560d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+407
-40
lines changed

stdlib/2.7/distutils/__init__.pyi

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +0,0 @@
1-
# Stubs for distutils (Python 2)
2-
#
3-
# NOTE: This dynamically typed stub was automatically generated by stubgen.
4-
5-
from typing import Any
6-
7-
__revision__ = ... # type: Any

stdlib/2.7/distutils/emxccompiler.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Stubs for emxccompiler
2+
3+
from distutils.unixccompiler import UnixCCompiler
4+
5+
class EMXCCompiler(UnixCCompiler): ...

stdlib/2.7/distutils/version.pyi

Lines changed: 0 additions & 23 deletions
This file was deleted.
File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Stubs for distutils.archive_util
2+
3+
from typing import Optional
4+
5+
6+
def make_archive(base_name: str, format: str, root_dir: Optional[str] = ...,
7+
base_dir: Optional[str] = ..., verbose: int = ...,
8+
dry_run: int = ...) -> str: ...
9+
def make_tarball(base_name: str, base_dir: str, compress: Optional[str] = ...,
10+
verbose: int = ..., dry_run: int = ...) -> str: ...
11+
def make_zipfile(base_name: str, base_dir: str, verbose: int = ...,
12+
dry_run: int = ...) -> str: ...
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Stubs for distutils.bcppcompiler
2+
3+
from distutils.ccompiler import CCompiler
4+
5+
6+
class BCPPCompiler(CCompiler): ...

stdlib/2and3/distutils/ccompiler.pyi

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Stubs for distutils.ccompiler
2+
3+
from typing import Any, Callable, List, Optional, Tuple, Union
4+
5+
6+
_Macro = Union[Tuple[str], Tuple[str, str]]
7+
8+
9+
def gen_lib_options(compiler: CCompiler, library_dirs: List[str],
10+
runtime_library_dirs: List[str],
11+
libraries: List[str]) -> List[str]: ...
12+
def gen_preprocess_options(macros: List[_Macro],
13+
include_dirs: List[str]) -> List[str]: ...
14+
def get_default_compiler(osname: Optional[str] = ...,
15+
platform: Optional[str] = ...) -> str: ...
16+
def new_compiler(plat: Optional[str] = ..., compiler: Optional[str] = ...,
17+
verbose: int = ..., dry_run: int = ...,
18+
force: int = ...) -> CCompiler: ...
19+
def show_compilers() -> None: ...
20+
21+
class CCompiler:
22+
def __init__(self, verbose: int = ..., dry_run: int = ...,
23+
force: int = ...) -> None: ...
24+
def add_include_dir(self, dir: str) -> None: ...
25+
def set_include_dirs(self, dirs: List[str]) -> None: ...
26+
def add_library(self, libname: str) -> None: ...
27+
def set_libraries(self, libnames: List[str]) -> None: ...
28+
def add_library_dir(self, dir: str) -> None: ...
29+
def set_library_dirs(self, dirs: List[str]) -> None: ...
30+
def add_runtime_library_dir(self, dir: str) -> None: ...
31+
def set_runtime_library_dirs(self, dirs: List[str]) -> None: ...
32+
def define_macro(self, name: str, value: Optional[str] = ...) -> None: ...
33+
def undefine_macro(self, name: str) -> None: ...
34+
def add_link_object(self, object: str) -> None: ...
35+
def set_link_objects(self, objects: List[str]) -> None: ...
36+
def detect_language(self, sources: Union[str, List[str]]) -> Optional[str]: ...
37+
def find_library_file(self, dirs: List[str], lib: str,
38+
debug: bool = ...) -> Optional[str]: ...
39+
def has_function(self, funcname: str, includes: Optional[List[str]] = ...,
40+
include_dirs: Optional[List[str]] = ...,
41+
libraries: Optional[List[str]] = ...,
42+
library_dirs: Optional[List[str]] = ...) -> bool: ...
43+
def library_dir_option(self, dir: str) -> str: ...
44+
def library_option(self, lib: str) -> str: ...
45+
def runtime_library_dir_option(self, dir: str) -> str: ...
46+
def set_executables(self, **args: str) -> None: ...
47+
def compile(self, sources: List[str], output_dir: Optional[str] = ...,
48+
macros: Optional[_Macro] = ...,
49+
include_dirs: Optional[List[str]] = ..., debug: bool = ...,
50+
extra_preargs: Optional[List[str]] = ...,
51+
extra_postargs: Optional[List[str]] = ...,
52+
depends: Optional[List[str]] = ...) -> List[str]: ...
53+
def create_static_lib(self, objects: List[str], output_libname: str,
54+
output_dir: Optional[str] = ..., debug: bool = ...,
55+
target_lang: Optional[str] = ...) -> None: ...
56+
def link(self, target_desc: str, objects: List[str], output_filename: str,
57+
output_dir: Optional[str] = ...,
58+
libraries: Optional[List[str]] = ...,
59+
library_dirs: Optional[List[str]] = ...,
60+
runtime_library_dirs: Optional[List[str]] = ...,
61+
export_symbols: Optional[List[str]] = ..., debug: bool = ...,
62+
extra_preargs: Optional[List[str]] = ...,
63+
extra_postargs: Optional[List[str]] = ...,
64+
build_temp: Optional[str] = ...,
65+
target_lang: Optional[str] = ...) -> None: ...
66+
def link_executable(self, objects: List[str], output_progname: str,
67+
output_dir: Optional[str] = ...,
68+
libraries: Optional[List[str]] = ...,
69+
library_dirs: Optional[List[str]] = ...,
70+
runtime_library_dirs: Optional[List[str]] = ...,
71+
debug: bool = ...,
72+
extra_preargs: Optional[List[str]] = ...,
73+
extra_postargs: Optional[List[str]] = ...,
74+
target_lang: Optional[str] = ...) -> None: ...
75+
def link_shared_lib(self, objects: List[str], output_libname: str,
76+
output_dir: Optional[str] = ...,
77+
libraries: Optional[List[str]] = ...,
78+
library_dirs: Optional[List[str]] = ...,
79+
runtime_library_dirs: Optional[List[str]] = ...,
80+
export_symbols: Optional[List[str]] = ...,
81+
debug: bool = ...,
82+
extra_preargs: Optional[List[str]] = ...,
83+
extra_postargs: Optional[List[str]] = ...,
84+
build_temp: Optional[str] = ...,
85+
target_lang: Optional[str] = ...) -> None: ...
86+
def link_shared_object(self, objects: List[str], output_filename: str,
87+
output_dir: Optional[str] = ...,
88+
libraries: Optional[List[str]] = ...,
89+
library_dirs: Optional[List[str]] = ...,
90+
runtime_library_dirs: Optional[List[str]] = ...,
91+
export_symbols: Optional[List[str]] = ...,
92+
debug: bool = ...,
93+
extra_preargs: Optional[List[str]] = ...,
94+
extra_postargs: Optional[List[str]] = ...,
95+
build_temp: Optional[str] = ...,
96+
target_lang: Optional[str] = ...) -> None: ...
97+
def preprocess(self, source: str, output_file: Optional[str] = ...,
98+
macros: Optional[List[_Macro]] = ...,
99+
include_dirs: Optional[List[str]] = ...,
100+
extra_preargs: Optional[List[str]] = ...,
101+
extra_postargs: Optional[List[str]] = ...) -> None: ...
102+
def executable_filename(self, basename: str, strip_dir: int = ...,
103+
output_dir: str = ...) -> str: ...
104+
def library_filename(self, libname: str, lib_type: str = ...,
105+
strip_dir: int = ...,
106+
output_dir: str = ...) -> str: ...
107+
def object_filenames(self, source_filenames: List[str],
108+
strip_dir: int = ...,
109+
output_dir: str = ...) -> List[str]: ...
110+
def shared_object_filename(self, basename: str, strip_dir: int = ...,
111+
output_dir: str = ...) -> str: ...
112+
def execute(self, func: Callable[..., None], args: Tuple[Any, ...],
113+
msg: Optional[str] = ..., level: int = ...) -> None: ...
114+
def spawn(self, cmd: List[str]) -> None: ...
115+
def mkpath(self, name: str, mode: int = ...) -> None: ...
116+
def move_file(self, src: str, dst: str) -> str: ...
117+
def announce(self, msg: str, level: int = ...) -> None: ...
118+
def warn(self, msg: str) -> None: ...
119+
def debug_print(self, msg: str) -> None: ...

stdlib/2and3/distutils/cmd.pyi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Stubs for distutils.cmd
2+
3+
from typing import Callable, List, Tuple, Union
4+
from abc import abstractmethod
5+
from distutils.dist import Distribution
6+
7+
class Command:
8+
sub_commands = ... # type: List[Tuple[str, Union[Callable[[], bool], str, None]]]
9+
def __init__(self, dist: Distribution) -> None: ...
10+
@abstractmethod
11+
def initialize_options(self) -> None: ...
12+
@abstractmethod
13+
def finalize_options(self) -> None: ...
14+
@abstractmethod
15+
def run(self) -> None: ...

stdlib/2and3/distutils/command/__init__.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/bdist.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/bdist_dumb.pyi

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Stubs for distutils.command.bdist_msi
2+
3+
from distutils.cmd import Command
4+
5+
class bdist_msi(Command): ...

stdlib/2and3/distutils/command/bdist_packager.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/bdist_rpm.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/bdist_wininst.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/build.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/build_clib.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/build_ext.pyi

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Stubs for distutils.command.bdist_msi
2+
3+
from distutils.cmd import Command
4+
import sys
5+
6+
if sys.version_info >= (3,):
7+
class build_py(Command): ...
8+
class build_py_2to3(Command): ...

stdlib/2and3/distutils/command/build_scripts.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/check.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/clean.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/config.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/install.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/install_data.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/install_headers.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/install_lib.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/install_scripts.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/register.pyi

Whitespace-only changes.

stdlib/2and3/distutils/command/sdist.pyi

Whitespace-only changes.

stdlib/2and3/distutils/core.pyi

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Stubs for distutils.core
2+
3+
from typing import Any, List, Mapping, Optional, Tuple, Type, Union
4+
from distutils.cmd import Command as Command
5+
from distutils.dist import Distribution as Distribution
6+
from distutils.extension import Extension as Extension
7+
8+
def setup(name: str = ...,
9+
version: str = ...,
10+
description: str = ...,
11+
long_description: str = ...,
12+
author: str = ...,
13+
author_email: str = ...,
14+
maintainer: str = ...,
15+
maintainer_email: str = ...,
16+
url: str = ...,
17+
download_url: str = ...,
18+
packages: List[str] = ...,
19+
py_modules: List[str] = ...,
20+
scripts: List[str] = ...,
21+
ext_modules: List[Extension] = ...,
22+
classifiers: List[str] = ...,
23+
distclass: Type[Distribution] = ...,
24+
script_name: str = ...,
25+
script_args: List[str] = ...,
26+
options: Mapping[str, Any] = ...,
27+
license: str = ...,
28+
keywords: Union[List[str], str] = ...,
29+
platforms: Union[List[str], str] = ...,
30+
cmdclass: Mapping[str, Command] = ...,
31+
data_files: List[Tuple[str, List[str]]] = ...,
32+
package_dir: Mapping[str, str] = ...) -> None: ...
33+
def run_setup(script_name: str,
34+
script_args: Optional[List[str]] = ...,
35+
stop_after: str = ...) -> Distribution: ...
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Stubs for distutils.cygwinccompiler
2+
3+
from distutils.unixccompiler import UnixCCompiler
4+
5+
6+
class CygwinCCompiler(UnixCCompiler): ...
7+
class Mingw32CCompiler(CygwinCCompiler): ...

stdlib/2and3/distutils/debug.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Stubs for distutils.debug
2+
3+
DEBUG = ... # type: bool

stdlib/2and3/distutils/dep_util.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Stubs for distutils.dep_util
2+
3+
from typing import List, Tuple
4+
5+
def newer(source: str, target: str) -> bool: ...
6+
def newer_pairwise(sources: List[str],
7+
targets: List[str]) -> List[Tuple[str, str]]: ...
8+
def newer_group(sources: List[str], target: str, missing: str = ...) -> bool: ...

stdlib/2and3/distutils/dir_util.pyi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Stubs for distutils.dir_util
2+
3+
from typing import List
4+
5+
6+
def mkpath(name: str, mode: int = ..., verbose: int = ...,
7+
dry_run: int = ...) -> List[str]: ...
8+
def create_tree(base_dir: str, files: List[str], mode: int = ...,
9+
verbose: int = ..., dry_run: int = ...) -> None: ...
10+
def copy_tree(src: str, dst: str, preserve_mode: int = ...,
11+
preserve_times: int = ..., preserve_symlinks: int = ...,
12+
update: int = ..., verbose: int = ...,
13+
dry_run: int = ...) -> List[str]: ...
14+
def remove_tree(directory: str, verbose: int = ...,
15+
dry_run: int = ...) -> None: ...

stdlib/2and3/distutils/dist.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Stubs for distutils.dist
2+
3+
from typing import Any, Mapping, Optional
4+
5+
6+
class Distribution:
7+
def __init__(self, attrs: Optional[Mapping[str, Any]] = ...) -> None: ...

stdlib/2and3/distutils/errors.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Stubs for distutils.errors
2+
3+
class DistutilsExecError(Exception): ...
4+
class DistutilsFileError(Exception): ...

stdlib/2and3/distutils/extension.pyi

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Stubs for distutils.extension
2+
3+
from typing import List, Optional, Tuple
4+
import sys
5+
6+
class Extension:
7+
if sys.version_info >= (3,):
8+
def __init__(self,
9+
*, name: str = ...,
10+
sources: List[str] = ...,
11+
include_dirs: List[str] = ...,
12+
define_macros: List[Tuple[str, Optional[str]]] = ...,
13+
undef_macros: List[str] = ...,
14+
library_dirs: List[str] = ...,
15+
libraries: List[str] = ...,
16+
runtime_library_dirs: List[str] = ...,
17+
extra_objects: List[str] = ...,
18+
extra_compile_args: List[str] = ...,
19+
extra_link_args: List[str] = ...,
20+
export_symbols: List[str] = ...,
21+
depends: List[str] = ...,
22+
language: str = ...,
23+
optional: bool = ...) -> None: ...
24+
else:
25+
def __init__(self,
26+
*, name: str = ...,
27+
sources: List[str] = ...,
28+
include_dirs: List[str] = ...,
29+
define_macros: List[Tuple[str, Optional[str]]] = ...,
30+
undef_macros: List[str] = ...,
31+
library_dirs: List[str] = ...,
32+
libraries: List[str] = ...,
33+
runtime_library_dirs: List[str] = ...,
34+
extra_objects: List[str] = ...,
35+
extra_compile_args: List[str] = ...,
36+
extra_link_args: List[str] = ...,
37+
export_symbols: List[str] = ...,
38+
depends: List[str] = ...,
39+
language: str = ...) -> None: ...
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Stubs for distutils.fancy_getopt
2+
3+
from typing import (
4+
Any, List, Mapping, Optional, Tuple, Union,
5+
TypeVar, overload,
6+
)
7+
8+
_Option = Tuple[str, str, str]
9+
_GR = Tuple[List[str], OptionDummy]
10+
11+
def fancy_getopt(options: List[_Option],
12+
negative_opt: Mapping[_Option, _Option],
13+
object: Any,
14+
args: Optional[List[str]]) -> Union[List[str], _GR]: ...
15+
def wrap_text(text: str, width: int) -> List[str]: ...
16+
17+
class FancyGetopt:
18+
def __init__(self, option_table: Optional[List[_Option]] = ...) -> None: ...
19+
# TODO kinda wrong, `getopt(object=object())` is invalid
20+
@overload
21+
def getopt(self, args: Optional[List[str]] = ...) -> _GR: ...
22+
@overload
23+
def getopt(self, args: Optional[List[str]], object: Any) -> List[str]: ...
24+
def get_option_order(self) -> List[Tuple[str, str]]: ...
25+
def generate_help(self, header: Optional[str] = ...) -> List[str]: ...
26+
27+
class OptionDummy: ...

stdlib/2and3/distutils/file_util.pyi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Stubs for distutils.file_util
2+
3+
from typing import Optional, Sequence, Tuple
4+
5+
6+
def copy_file(src: str, dst: str, preserve_mode: bool = ...,
7+
preserve_times: bool = ..., update: bool = ...,
8+
link: Optional[str] = ..., verbose: bool = ...,
9+
dry_run: bool = ...) -> Tuple[str, str]: ...
10+
def move_file(src: str, dst: str, verbose: bool = ...,
11+
dry_run: bool = ...) -> str: ...
12+
def write_file(filename: str, contents: Sequence[str]) -> None: ...

stdlib/2and3/distutils/filelist.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Stubs for distutils.filelist
2+
3+
class FileList: ...

stdlib/2and3/distutils/log.pyi

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Stubs for distutils.msvccompiler
2+
3+
from distutils.ccompiler import CCompiler
4+
5+
6+
class MSVCCompiler(CCompiler): ...

stdlib/2and3/distutils/spawn.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Stubs for distutils.spawn
2+
3+
from typing import Optional
4+
5+
def spawn(cmd: List[str], search_path: bool = ...,
6+
verbose: bool = ..., dry_run: bool = ...) -> None: ...
7+
def find_executable(executable: str,
8+
path: Optional[str] = ...) -> Optional[str]: ...

0 commit comments

Comments
 (0)