-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstubs.py
42 lines (28 loc) · 890 Bytes
/
stubs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from importlib.resources import path
import sys
import os
import pathlib
import shutil
import multiprocessing
import mypy.stubgen
stub_index = """
from . import vector
from . import spline
from . import plane
from . import mesh
"""
if __name__ == '__main__':
multiprocessing.freeze_support()
if len(sys.argv) > 1:
stubgen_path = sys.argv[1]
else:
stubgen_path = str(pathlib.Path(__file__).absolute().parent)
print(f"running in {stubgen_path}")
sys.path.append(stubgen_path)
opts = mypy.stubgen.parse_options([])
opts.packages.append("euklid")
opts.output_dir = stubgen_path
mypy.stubgen.generate_stubs(opts)
with open(os.path.join(stubgen_path, "euklid", "__init__.pyi"), "w") as outfile:
outfile.write(stub_index)
shutil.move(os.path.join(stubgen_path, "euklid"), os.path.join(stubgen_path, "euklid-stubs"))