Skip to content

Commit 770395e

Browse files
committed
Statically alias distutils-stubs to setuptools._distutils
1 parent a9a79e7 commit 770395e

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

+81
-0
lines changed

tools/update_distutils_stubs.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
9+
def main():
10+
if _distutils_stubs_path.exists():
11+
shutil.rmtree(_distutils_stubs_path)
12+
_distutils_stubs_path.mkdir(parents=True)
13+
(_distutils_stubs_path / "ruff.toml").write_text('[lint]\nignore = ["F403"]')
14+
for path in _vendored_distutils_path.rglob("*.py"):
15+
relative_path = path.relative_to(_vendored_distutils_path)
16+
if relative_path.parts[0] == "tests":
17+
continue
18+
stub_path = (_distutils_stubs_path / relative_path).with_suffix(".pyi")
19+
stub_path.parent.mkdir(exist_ok=True)
20+
module = (
21+
"setuptools._distutils."
22+
+ str(relative_path.with_suffix("")).replace(os.sep, ".")
23+
).removesuffix(".__init__")
24+
stub_path.write_text(f"from {module} import *\n")
25+
26+
27+
if __name__ == "__main__":
28+
main()

typings/distutils-stubs/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from setuptools._distutils import *

typings/distutils-stubs/_log.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from setuptools._distutils._log import *
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from setuptools._distutils._macos_compat import *

typings/distutils-stubs/_modified.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from setuptools._distutils._modified import *
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from setuptools._distutils._msvccompiler import *
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from setuptools._distutils.archive_util import *

typings/distutils-stubs/ccompiler.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from setuptools._distutils.ccompiler import *

typings/distutils-stubs/cmd.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from setuptools._distutils.cmd import *
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from setuptools._distutils.command import *

0 commit comments

Comments
 (0)