Commit 47027899 authored by PanZezhong's avatar PanZezhong
Browse files

issue/134/refactor 修改set env

parent 40b32e95
...@@ -2,34 +2,11 @@ import os ...@@ -2,34 +2,11 @@ import os
import subprocess import subprocess
import platform import platform
import sys import sys
from set_env import set_env
PROJECT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) PROJECT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
os.chdir(PROJECT_DIR) os.chdir(PROJECT_DIR)
def set_env():
if os.environ.get("INFINI_ROOT", "") == "":
os.environ["INFINI_ROOT"] = os.path.expanduser("~/.infini")
if platform.system() == "Windows":
new_path = os.path.expanduser(os.environ.get("INFINI_ROOT") + "/bin")
if new_path not in os.environ.get("PATH", ""):
os.environ["PATH"] = f"{new_path};{os.environ.get('PATH', '')}"
elif platform.system() == "Linux":
new_path = os.path.expanduser(os.environ.get("INFINI_ROOT") + "/bin")
if new_path not in os.environ.get("PATH", ""):
os.environ["PATH"] = f"{new_path}:{os.environ.get('PATH', '')}"
new_lib_path = os.path.expanduser(os.environ.get("INFINI_ROOT") + "/lib")
if new_lib_path not in os.environ.get("LD_LIBRARY_PATH", ""):
os.environ["LD_LIBRARY_PATH"] = (
f"{new_lib_path}:{os.environ.get('LD_LIBRARY_PATH', '')}"
)
else:
raise RuntimeError("Unsupported platform.")
def run_cmd(cmd): def run_cmd(cmd):
subprocess.run(cmd, text=True, encoding="utf-8", check=True, shell=True) subprocess.run(cmd, text=True, encoding="utf-8", check=True, shell=True)
......
import os import os
import subprocess import subprocess
import platform from set_env import set_env
import sys import sys
PROJECT_DIR = os.path.abspath( PROJECT_DIR = os.path.abspath(
...@@ -9,29 +9,6 @@ PROJECT_DIR = os.path.abspath( ...@@ -9,29 +9,6 @@ PROJECT_DIR = os.path.abspath(
os.chdir(PROJECT_DIR) os.chdir(PROJECT_DIR)
def set_env():
if os.environ.get("INFINI_ROOT", "") == "":
os.environ["INFINI_ROOT"] = os.path.expanduser("~/.infini")
if platform.system() == "Windows":
new_path = os.path.expanduser(os.environ.get("INFINI_ROOT") + "/bin")
if new_path not in os.environ.get("PATH", ""):
os.environ["PATH"] = f"{new_path};{os.environ.get('PATH', '')}"
elif platform.system() == "Linux":
new_path = os.path.expanduser(os.environ.get("INFINI_ROOT") + "/bin")
if new_path not in os.environ.get("PATH", ""):
os.environ["PATH"] = f"{new_path}:{os.environ.get('PATH', '')}"
new_lib_path = os.path.expanduser(os.environ.get("INFINI_ROOT") + "/lib")
if new_lib_path not in os.environ.get("LD_LIBRARY_PATH", ""):
os.environ["LD_LIBRARY_PATH"] = (
f"{new_lib_path}:{os.environ.get('LD_LIBRARY_PATH', '')}"
)
else:
raise RuntimeError("Unsupported platform.")
def run_tests(args): def run_tests(args):
failed = [] failed = []
for test in [ for test in [
......
import os
import platform
def set_env():
if os.environ.get("INFINI_ROOT") == None:
os.environ["INFINI_ROOT"] = os.path.expanduser("~/.infini")
if platform.system() == "Windows":
new_path = os.path.expanduser(os.environ.get("INFINI_ROOT") + "/bin")
if new_path not in os.environ.get("PATH", ""):
os.environ["PATH"] = f"{new_path};{os.environ.get('PATH', '')}"
elif platform.system() == "Linux":
new_path = os.path.expanduser(os.environ.get("INFINI_ROOT") + "/bin")
if new_path not in os.environ.get("PATH", ""):
os.environ["PATH"] = f"{new_path}:{os.environ.get('PATH', '')}"
new_lib_path = os.path.expanduser(os.environ.get("INFINI_ROOT") + "/lib")
if new_lib_path not in os.environ.get("LD_LIBRARY_PATH", ""):
os.environ["LD_LIBRARY_PATH"] = (
f"{new_lib_path}:{os.environ.get('LD_LIBRARY_PATH', '')}"
)
else:
raise RuntimeError("Unsupported platform.")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment