Skip to content

Commit 9446ab5

Browse files
committed
polish code
1 parent 3788f3b commit 9446ab5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

python/setup_tools/setup_helper.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ def git_clone(lib, lib_path):
7272
return False
7373

7474

75+
def dir_rollback(deep, base_path):
76+
while (deep):
77+
base_path = os.path.dirname(base_path)
78+
deep -= 1
79+
return Path(base_path)
80+
81+
7582
def download_flagtree_third_party(name, condition, required=False, hock=None):
7683
if not condition:
7784
return
@@ -82,15 +89,16 @@ def download_flagtree_third_party(name, condition, required=False, hock=None):
8289
break
8390
if backend is None:
8491
return backend
85-
third_party_base_dir = Path(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) / "third_party"
86-
prelib_path = Path(third_party_base_dir) / name
87-
lib_path = Path(third_party_base_dir) / _backend.name
92+
base_dir = dir_rollback(3, __file__) / "third_party"
93+
prelib_path = Path(base_dir) / name
94+
lib_path = Path(base_dir) / _backend.name
95+
8896
if not os.path.exists(prelib_path) and not os.path.exists(lib_path):
8997
succ = git_clone(lib=backend, lib_path=prelib_path)
9098
if not succ and required:
9199
raise RuntimeError("Bad network ! ")
92100
if callable(hock):
93-
hock(third_party_base_dir=third_party_base_dir, backend=backend)
101+
hock(third_party_base_dir=base_dir, backend=backend)
94102
else:
95103
print(f'Found third_party {backend.name} at {lib_path}\n')
96104

0 commit comments

Comments
 (0)