You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
783 B
Python

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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()