-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
84 lines (64 loc) · 2.19 KB
/
setup.py
File metadata and controls
84 lines (64 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python
"""Setup script to handle version file copying and dotenv instantiation."""
import shutil
from pathlib import Path
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.egg_info import egg_info
from setuptools.command.install import install
def copy_version_files():
"""Copy src/_version.py to other package locations."""
source_file = Path("src/_version.py")
if not source_file.exists():
print(f"Warning: {source_file} does not exist, nothing to copy")
return
target_files = [
Path("src/smartem_backend/_version.py"),
Path("src/smartem_agent/_version.py"),
Path("src/smartem_common/_version.py"),
Path("src/smartem_api/_version.py"),
]
# Make sure target directories exist
for target in target_files:
target.parent.mkdir(parents=True, exist_ok=True)
# Copy the file to each target location
for target in target_files:
shutil.copy2(source_file, target)
print(f"Copied version file to {target}")
def copy_dotenv():
"""Copy .env.example to .env if .env doesn't exist."""
source_file = Path(".env.example")
target_file = Path(".env")
if not source_file.exists():
print(f"Warning: {source_file} does not exist, nothing to copy")
return
if target_file.exists():
print(f"{target_file} already exists, skipping copy")
return
shutil.copy2(source_file, target_file)
print(f"Copied {source_file} to {target_file}")
class CustomDevelop(develop):
def run(self):
develop.run(self)
copy_version_files()
copy_dotenv()
class CustomInstall(install):
def run(self):
install.run(self)
copy_version_files()
copy_dotenv()
class CustomEggInfo(egg_info):
def run(self):
egg_info.run(self)
copy_version_files()
copy_dotenv()
# Keep this minimal - config is in pyproject.toml
setup(
name="smartem-decisions", # Required for some setuptools versions
cmdclass={
"develop": CustomDevelop,
"install": CustomInstall,
"egg_info": CustomEggInfo,
},
# We're using pyproject.toml for the rest
)