-
Notifications
You must be signed in to change notification settings - Fork 12
/
install_to_dir.py
executable file
·35 lines (29 loc) · 1.08 KB
/
install_to_dir.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
#!/usr/bin/env python3
import argparse
import json
import os
import shlex
import shutil
import subprocess
from pathlib import Path
parser = argparse.ArgumentParser(description="Nutrimatic installer tool")
parser.add_argument("output_dir", type=Path, help="Root directory to deploy to")
args = parser.parse_args()
output_path = args.output_dir.resolve() # Resolve before changing directory
top_dir = Path(__file__).resolve().parent
os.chdir(top_dir)
print(f"🔨 Building and exporting package to Conan cache")
conan_export = ["conan", "export-pkg", "--format=json", "."]
print(f"🐚 {shlex.join(conan_export)}")
export_run = subprocess.run(conan_export, stdout=subprocess.PIPE, check=True)
export_json = json.loads(export_run.stdout)
node = next(iter(export_json["graph"]["nodes"].values()))
package_path = Path(node["package_folder"])
print(
f"\n📁 Copying files out of Conan cache...\n"
f" from {package_path}\n"
f" to {output_path}"
)
output_path.mkdir(parents=True, exist_ok=True)
shutil.copytree(package_path, output_path, dirs_exist_ok=True)
print("\n📦 Install complete")