From 26a3b29a8328f5e2104497f1d302fe4f8e517c5a Mon Sep 17 00:00:00 2001 From: breezedeus Date: Sun, 8 Dec 2024 16:52:16 +0800 Subject: [PATCH] Fix compatibility issue of setting environment variables on Windows systems --- RELEASE.md | 12 ++++++++++++ cnstd/__version__.py | 2 +- cnstd/utils/utils.py | 7 +++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index f268940..4a86fad 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,17 @@ # Release Notes +## Update 2024.12.08:发布 V1.2.5.2 + +Bug Fixes: + +* Fix compatibility issue of setting environment variables on Windows systems +* Use subprocess.run instead of os.system for better cross-platform support + +Bug Fixes: + +* 修复在 Windows 系统下设置环境变量的兼容性问题 +* 使用 subprocess.run 替代 os.system 以提供更好的跨平台支持 + ## Update 2024.11.30:发布 V1.2.5.1 Major Changes: diff --git a/cnstd/__version__.py b/cnstd/__version__.py index 972a07f..9d1ef14 100644 --- a/cnstd/__version__.py +++ b/cnstd/__version__.py @@ -17,4 +17,4 @@ # specific language governing permissions and limitations # under the License. -__version__ = '1.2.5.1' +__version__ = '1.2.5.2' diff --git a/cnstd/utils/utils.py b/cnstd/utils/utils.py index 78ca416..f1177e9 100644 --- a/cnstd/utils/utils.py +++ b/cnstd/utils/utils.py @@ -28,6 +28,7 @@ from functools import cmp_to_key import shutil import tempfile +import subprocess from tqdm import tqdm import cv2 @@ -117,11 +118,13 @@ def prepare_model_files(model_fp, remote_repo, mirror_url='https://hf-mirror.com shutil.rmtree(str(model_dir)) model_dir.mkdir(parents=True) download_cmd = f'huggingface-cli download --repo-type model --resume-download --local-dir-use-symlinks False {remote_repo} --local-dir {model_dir}' - os.system(download_cmd) + subprocess.run(download_cmd, shell=True) if not model_fp.exists(): # download failed above if model_dir.exists(): shutil.rmtree(str(model_dir)) - os.system(f'HF_ENDPOINT={mirror_url} ' + download_cmd) + env = os.environ.copy() + env['HF_ENDPOINT'] = mirror_url + subprocess.run(download_cmd, env=env, shell=True) return model_fp