Skip to content

Commit 62443b4

Browse files
committed
refactor: move prompt file copying from build command to setup
Removes custom BuildPyCommand class and moves prompt file copying logic directly into the setup script. This simplifies the build process while maintaining the same functionality.
1 parent db1f3a9 commit 62443b4

File tree

1 file changed

+20
-34
lines changed

1 file changed

+20
-34
lines changed

python/setup.py

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,32 @@
66
from pathlib import Path
77

88
from setuptools import find_packages, setup
9-
from setuptools.command.build_py import build_py
10-
11-
12-
class BuildPyCommand(build_py):
13-
"""Custom build command to copy prompt files."""
14-
15-
def run(self):
16-
# Copy prompt files from project root to package
17-
root_dir = Path(__file__).parent.parent
18-
package_dir = Path(__file__).parent / "heart_centered_prompts"
19-
prompts_dir = root_dir / "prompts"
20-
package_prompts_dir = package_dir / "prompts"
21-
22-
# Ensure the base prompts directory exists
23-
package_prompts_dir.mkdir(parents=True, exist_ok=True)
24-
25-
if prompts_dir.exists():
26-
for collection in prompts_dir.iterdir():
27-
if collection.is_dir():
28-
# Create collection directory if it doesn't exist
29-
collection_path = package_prompts_dir / collection.name
30-
collection_path.mkdir(parents=True, exist_ok=True)
31-
32-
# Copy prompt files
33-
for prompt_file in collection.glob("*.txt"):
34-
dest_file = collection_path / prompt_file.name
35-
shutil.copy2(prompt_file, dest_file)
36-
37-
# Run the regular build_py command
38-
super().run()
39-
409

4110
# Read the contents of README.md
4211
readme_path = Path(__file__).parent / "README.md"
4312
with readme_path.open("r", encoding="utf-8") as f:
4413
long_description = f.read()
4514

15+
# Copy prompt files from project root to package
16+
root_dir = Path(__file__).parent.parent
17+
package_dir = Path(__file__).parent / "heart_centered_prompts"
18+
prompts_dir = root_dir / "prompts"
19+
package_prompts_dir = package_dir / "prompts"
20+
21+
# Ensure the base prompts directory exists
22+
package_prompts_dir.mkdir(parents=True, exist_ok=True)
23+
24+
if prompts_dir.exists():
25+
for collection in prompts_dir.iterdir():
26+
if collection.is_dir():
27+
# Create collection directory if it doesn't exist
28+
collection_path = package_prompts_dir / collection.name
29+
collection_path.mkdir(parents=True, exist_ok=True)
30+
31+
# Copy prompt files
32+
for prompt_file in collection.glob("*.txt"):
33+
dest_file = collection_path / prompt_file.name
34+
shutil.copy2(prompt_file, dest_file)
4635

4736
setup(
4837
name="heart_centered_prompts",
@@ -75,8 +64,5 @@ def run(self):
7564
package_data={
7665
"heart_centered_prompts": ["prompts/*/*.txt"],
7766
},
78-
cmdclass={
79-
"build_py": BuildPyCommand,
80-
},
8167
zip_safe=False,
8268
)

0 commit comments

Comments
 (0)