diff --git a/fix_requirements.py b/fix_requirements.py new file mode 100644 index 0000000..349167d --- /dev/null +++ b/fix_requirements.py @@ -0,0 +1,28 @@ +import re + + +def simplify_editable_git_path(line: str) -> str: + if not line.strip().startswith("-e"): + return line + + # 匹配 subdirectory 参数 + match = re.search(r"subdirectory=([^\s&#]+)", line) + if match: + sub_path = match.group(1) + if sub_path.startswith("third_party/"): + return f"-e {sub_path}\n" + return line + +def fix_requirements(): + with open('requirements.txt', "r") as infile: + lines = infile.readlines() + + fixed_lines = [simplify_editable_git_path(line) for line in lines] + + with open('requirements.txt', "w") as outfile: + outfile.writelines(fixed_lines) + + print(f"✅ 已更新 requirements.txt:简化了包含 third_party 的 git 路径。") + +if __name__ == "__main__": + fix_requirements()