forked from MadcowD/ell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
45 lines (33 loc) · 1.13 KB
/
build.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
43
44
45
import os
import subprocess
import shutil
import toml
def run_command(command, cwd=None):
result = subprocess.run(command, shell=True, cwd=cwd)
if result.returncode != 0:
raise RuntimeError(
f"Command {command} failed with return code {result.returncode}"
)
def npm_install():
print("Running npm install")
run_command("npm install", cwd="ell-studio")
def npm_build():
print("Running npm build")
run_command("npm run build", cwd="ell-studio")
print("Copying static files")
source_dir = os.path.join("ell-studio", "build")
target_dir = os.path.join("src", "ell", "studio", "static")
shutil.rmtree(target_dir, ignore_errors=True)
shutil.copytree(source_dir, target_dir)
print(f"Copied static files from {source_dir} to {target_dir}")
def get_ell_version():
pyproject_path = "pyproject.toml"
pyproject_data = toml.load(pyproject_path)
return pyproject_data["tool"]["poetry"]["version"]
def main():
ell_version = get_ell_version()
os.environ['REACT_APP_ELL_VERSION'] = ell_version
npm_install()
npm_build()
if __name__ == "__main__":
main()