Skip to content

Commit

Permalink
Statically alias distutils-stubs to setuptools._distutils
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Oct 25, 2024
1 parent a9a79e7 commit 770395e
Show file tree
Hide file tree
Showing 53 changed files with 81 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tools/update_distutils_stubs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import shutil
from pathlib import Path

_vendored_distutils_path = Path(__file__).parent.parent / "setuptools" / "_distutils"
_distutils_stubs_path = Path(__file__).parent.parent / "typings" / "distutils-stubs"


def main():
if _distutils_stubs_path.exists():
shutil.rmtree(_distutils_stubs_path)
_distutils_stubs_path.mkdir(parents=True)
(_distutils_stubs_path / "ruff.toml").write_text('[lint]\nignore = ["F403"]')
for path in _vendored_distutils_path.rglob("*.py"):
relative_path = path.relative_to(_vendored_distutils_path)
if relative_path.parts[0] == "tests":
continue
stub_path = (_distutils_stubs_path / relative_path).with_suffix(".pyi")
stub_path.parent.mkdir(exist_ok=True)
module = (
"setuptools._distutils."
+ str(relative_path.with_suffix("")).replace(os.sep, ".")
).removesuffix(".__init__")
stub_path.write_text(f"from {module} import *\n")


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions typings/distutils-stubs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/_log.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils._log import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/_macos_compat.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils._macos_compat import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/_modified.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils._modified import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/_msvccompiler.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils._msvccompiler import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/archive_util.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.archive_util import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/ccompiler.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.ccompiler import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/cmd.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.cmd import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/_framework_compat.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command._framework_compat import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/bdist.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.bdist import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/bdist_dumb.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.bdist_dumb import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/bdist_rpm.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.bdist_rpm import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/build.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.build import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/build_clib.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.build_clib import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/build_ext.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.build_ext import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/build_py.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.build_py import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/build_scripts.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.build_scripts import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/check.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.check import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/clean.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.clean import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/config.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.config import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/install.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.install import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/install_data.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.install_data import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/install_egg_info.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.install_egg_info import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/install_headers.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.install_headers import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/install_lib.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.install_lib import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/install_scripts.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.install_scripts import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/command/sdist.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.command.sdist import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/compat/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.compat import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/compat/py38.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.compat.py38 import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/compat/py39.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.compat.py39 import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/core.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.core import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/cygwinccompiler.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.cygwinccompiler import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/debug.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.debug import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/dep_util.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.dep_util import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/dir_util.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.dir_util import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/dist.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.dist import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/errors.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.errors import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/extension.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.extension import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/fancy_getopt.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.fancy_getopt import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/file_util.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.file_util import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/filelist.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.filelist import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/log.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.log import *
2 changes: 2 additions & 0 deletions typings/distutils-stubs/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[lint]
ignore = ["F403"]
1 change: 1 addition & 0 deletions typings/distutils-stubs/spawn.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.spawn import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/sysconfig.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.sysconfig import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/text_file.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.text_file import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/unixccompiler.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.unixccompiler import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/util.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.util import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.version import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/versionpredicate.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.versionpredicate import *
1 change: 1 addition & 0 deletions typings/distutils-stubs/zosccompiler.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from setuptools._distutils.zosccompiler import *

0 comments on commit 770395e

Please sign in to comment.