Skip to content

Commit 79c5db9

Browse files
committed
Statically alias distutils-stubs to setuptools._distutils
1 parent 9692cde commit 79c5db9

Some content is hidden

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

53 files changed

+137
-0
lines changed

tools/update_distutils_stubs.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
import shutil
3+
from pathlib import Path
4+
5+
_vendored_distutils_path = Path(__file__).parent.parent / "setuptools" / "_distutils"
6+
_distutils_stubs_path = Path(__file__).parent.parent / "typings" / "distutils-stubs"
7+
8+
DONT_TOUCH_COMMENT = "# DO NOT MODIFY ! This file was automatically generated by tools/update_distutils_stubs.py\n"
9+
10+
11+
def main():
12+
if _distutils_stubs_path.exists():
13+
shutil.rmtree(_distutils_stubs_path)
14+
_distutils_stubs_path.mkdir(parents=True)
15+
(_distutils_stubs_path / "ruff.toml").write_text(
16+
f'{DONT_TOUCH_COMMENT}[lint]\nignore = ["F403"]'
17+
)
18+
for path in _vendored_distutils_path.rglob("*.py"):
19+
relative_path = path.relative_to(_vendored_distutils_path)
20+
if relative_path.parts[0] == "tests":
21+
continue
22+
stub_path = (_distutils_stubs_path / relative_path).with_suffix(".pyi")
23+
stub_path.parent.mkdir(exist_ok=True)
24+
module = (
25+
"setuptools._distutils."
26+
+ str(relative_path.with_suffix("")).replace(os.sep, ".")
27+
).removesuffix(".__init__")
28+
stub_path.write_text(f"{DONT_TOUCH_COMMENT}from {module} import *\n")
29+
30+
31+
if __name__ == "__main__":
32+
main()

typings/distutils-stubs/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT MODIFY ! This file was automatically generated by tools/update_distutils_stubs.py
2+
from setuptools._distutils import *

typings/distutils-stubs/_log.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT MODIFY ! This file was automatically generated by tools/update_distutils_stubs.py
2+
from setuptools._distutils._log import *
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT MODIFY ! This file was automatically generated by tools/update_distutils_stubs.py
2+
from setuptools._distutils._macos_compat import *

typings/distutils-stubs/_modified.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT MODIFY ! This file was automatically generated by tools/update_distutils_stubs.py
2+
from setuptools._distutils._modified import *
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT MODIFY ! This file was automatically generated by tools/update_distutils_stubs.py
2+
from setuptools._distutils._msvccompiler import *
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT MODIFY ! This file was automatically generated by tools/update_distutils_stubs.py
2+
from setuptools._distutils.archive_util import *

typings/distutils-stubs/ccompiler.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT MODIFY ! This file was automatically generated by tools/update_distutils_stubs.py
2+
from setuptools._distutils.ccompiler import *

typings/distutils-stubs/cmd.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT MODIFY ! This file was automatically generated by tools/update_distutils_stubs.py
2+
from setuptools._distutils.cmd import *
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# DO NOT MODIFY ! This file was automatically generated by tools/update_distutils_stubs.py
2+
from setuptools._distutils.command import *

0 commit comments

Comments
 (0)