d120cd7f8a
mypy's move to external types-* packages is a PITA, as it requires them to be installed in site-packages, and provides no way to specify a custom site-packages folder, necessitating extra scripts to mock the site-packages path, and copy+rename the stub packages into a separate folder.
31 lines
867 B
Python
31 lines
867 B
Python
# Copyright: Ankitects Pty Ltd and contributors
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import re
|
|
import shutil
|
|
|
|
stubs_remap = {"protobuf": "google", "futures": "concurrent"}
|
|
|
|
|
|
def copy_folder(pkgname, path, outbase):
|
|
stubname = stubs_remap.get(pkgname, pkgname)
|
|
os.listdir(path)
|
|
path = f"{path}/{stubname}-stubs"
|
|
shutil.copytree(path, os.path.join(outbase, f"{stubname}-stubs"))
|
|
|
|
|
|
name_re = re.compile("__types_(.+?)_\d")
|
|
|
|
if __name__ == "__main__":
|
|
outbase = os.path.abspath(sys.argv[1])
|
|
|
|
# copy stubs into top level folder, renaming
|
|
folder = os.path.join(os.path.dirname(__file__), "../../external")
|
|
os.chdir(folder)
|
|
for folder in os.listdir("."):
|
|
if match := name_re.search(folder):
|
|
copy_folder(match.group(1), folder, outbase)
|