22import inspect
33import os
44import platform
5+ import subprocess
6+ import shlex
7+ import glob
58
69from hatchling .builders .hooks .plugin .interface import BuildHookInterface
710
@@ -14,8 +17,11 @@ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
1417 build_data ["infer_tag" ] = True
1518 build_data ["pure_python" ] = False
1619
17- os .system ("conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force" )
18- os .system ("conan profile detect --force" )
20+ subprocess .run (
21+ ["conan" , "remote" , "add" , "osp" , "https://osp.jfrog.io/artifactory/api/conan/conan-local" , "--force" ],
22+ check = True ,
23+ )
24+ subprocess .run (["conan" , "profile" , "detect" , "--force" ], check = True )
1925
2026 for frame_info in inspect .stack ():
2127 frame = frame_info .frame
@@ -29,14 +35,22 @@ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
2935 else :
3036 build_packages = "-b missing"
3137
32- assert (
33- os .system (f"conan install . -u { build_packages } -of build --format json -b b2/* --out-file graph.json" ) == 0
34- ), "Conan install failed"
38+ install_cmd_str = (
39+ f"conan install . -u { build_packages } -of build --format json -b b2/* -b m4/* --out-file graph.json"
40+ )
41+
42+ install_args = shlex .split (install_cmd_str )
43+ result = subprocess .run (install_args )
44+ assert result .returncode == 0 , "Conan install failed"
3545
3646 if "CONAN_UPLOAD_OSP" in os .environ :
3747 print ("Uploading packages.." )
38- os .system ("conan list --graph=graph.json --format=json > pkglist.json" )
39- os .system ("conan upload --confirm --list=pkglist.json --remote osp" )
48+ with open ("pkglist.json" , "w" ) as pkglist_file :
49+ subprocess .run (
50+ ["conan" , "list" , "--graph=graph.json" , "--format=json" ], check = True , stdout = pkglist_file
51+ )
52+ subprocess .run (["conan" , "upload" , "--confirm" , "--list=pkglist.json" , "--remote" , "osp" ], check = True )
4053
4154 if system_os == "Linux" :
42- os .system ("patchelf --set-rpath '$ORIGIN' build/libcosimc/*" )
55+ for libfile in glob .glob ("build/libcosimc/*" ):
56+ subprocess .run (["patchelf" , "--set-rpath" , "$ORIGIN" , libfile ], check = True )
0 commit comments