Skip to content

Commit b359a17

Browse files
committed
Add automatic git submodule initialization and stub files update.
1 parent 3432d95 commit b359a17

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

setup.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import platform
33
from pathlib import Path
44
from setuptools import setup, Extension
5+
from warnings import warn
56

67
FORCE_BINARIES = "NOVA_FORCE" in os.environ and os.environ["NOVA_FORCE"].lower() == "binaries"
78
FORCE_BUILD_SOURCE = "NOVA_FORCE" in os.environ and os.environ["NOVA_FORCE"].lower() == "source"
@@ -32,6 +33,14 @@
3233
elif not LOCAL_BINARIES.exists():
3334
raise RuntimeError(f"Not supported {platform.machine()} architecture for binaries.")
3435

36+
if len(list(NOVA_PHYSICS.iterdir())) == 0 or len(list(NOVA_PYTHON.iterdir())) == 0:
37+
warn("Submodules not initialized, performing additional cloning.")
38+
if platform.system() == "Windows":
39+
os.system("git.exe submodule init")
40+
os.system("git.exe submodule update")
41+
else:
42+
os.system("git submodule init && git submodule update")
43+
3544

3645
def use_binaries():
3746
if FORCE_BINARIES:
@@ -103,7 +112,10 @@ def get_nova_sources():
103112

104113
def main():
105114
nova_to_link = str(get_nova_to_link().relative_to(PACKAGE_DIR))
106-
local_stubs = []
115+
stubs_to_override = {REAL_PACKAGE / "__init__.pyi": NOVA_PYTHON_STUB, REAL_PACKAGE / "_nova.pyi": NOVA_PYTHON_STUB}
116+
117+
for write_to, read_from in stubs_to_override.items():
118+
write_to.write_text(read_from.read_text())
107119

108120
extension = Extension(
109121
name="nova._nova",

0 commit comments

Comments
 (0)