Skip to content

Commit

Permalink
fix patch
Browse files Browse the repository at this point in the history
  • Loading branch information
clemente0731 committed Mar 27, 2024
1 parent 9a5643c commit dc58fc4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 78 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ __pycache__
*.profraw
*.md5
*.run
build/
dist/
pthook.egg-info/
80 changes: 2 additions & 78 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,6 @@
import shutil


def move_configs_and_requirements():
"""将配置和依赖项移动到 benchflow 文件夹中。
如果已存在名为 `benchflow` 的目录,则删除该目录及其内容。然后将名为 `configs` 和 `requirements` 以及 `patch`
的子文件夹分别复制到 `benchflow` 中。
Args:
None
Returns:
None
"""
# 删除已经存在的目标目录
if os.path.exists("benchflow/configs"):
shutil.rmtree("benchflow/configs")

if os.path.exists("benchflow/requirements"):
shutil.rmtree("benchflow/requirements")

if os.path.exists("benchflow/patch"):
shutil.rmtree("benchflow/patch")

# 移动configs目录到benchflow目录下
shutil.copytree("configs", "benchflow/configs")
# 移动requirements目录到benchflow目录下
shutil.copytree("requirements", "benchflow/requirements")
# 移动patch目录到benchflow目录下
shutil.copytree("patch", "benchflow/patch")


def clean_pycache():
"""
清理当前目录及其子目录下所有以 .pyc、.pyo 和 __pycache__ 结尾的文件和文件夹。
Args:
None
Returns:
None
"""
for root, dirs, files in os.walk(".", topdown=False):
for name in files:
if (
name.endswith(".pyc")
or name.endswith(".pyo")
or name.endswith("__pycache__")
):
os.remove(os.path.join(root, name))
print(f"Removed pycache file: {os.path.join(root, name)}")
for name in dirs:
if name == "__pycache__":
os.rmdir(os.path.join(root, name))
print(f"Removed pycache directory: {os.path.join(root, name)}")


def read_requirements(file_path):
"""
读取依赖项列表文件
Expand All @@ -72,29 +15,10 @@ def read_requirements(file_path):
"""
with open(file_path) as f:
print("benchflow install_requires:", f.read().splitlines())
print("pthook install_requires:", f.read().splitlines())
return f.read().splitlines()


def pre_setup():
"""
移动配置文件和依赖项,并清理 pycache 文件
Args:
无参
Returns:
None
Raises:
无异常处理
"""
clean_pycache()
move_configs_and_requirements()


pre_setup()

setup(
name="pthook",
version="1.0.0",
Expand All @@ -103,7 +27,7 @@ def pre_setup():
install_requires=read_requirements("./requirements.txt"),
entry_points={
"console_scripts": [
"pthook = pthook:pthook",
"pthook = agent",
],
},
author="clemente0620",
Expand Down

0 comments on commit dc58fc4

Please sign in to comment.