Spaces:
Build error
Build error
Create setup.py
Browse files
setup.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# setup.py
|
| 2 |
+
import os
|
| 3 |
+
import subprocess
|
| 4 |
+
import sys
|
| 5 |
+
|
| 6 |
+
def setup_directories():
|
| 7 |
+
"""Set up necessary directories and permissions."""
|
| 8 |
+
try:
|
| 9 |
+
# Create base directory
|
| 10 |
+
os.makedirs('/data', exist_ok=True)
|
| 11 |
+
|
| 12 |
+
# Create subdirectories
|
| 13 |
+
subdirs = ['database', 'files', 'vectorstore', 'metadata']
|
| 14 |
+
for subdir in subdirs:
|
| 15 |
+
os.makedirs(f'/data/{subdir}', exist_ok=True)
|
| 16 |
+
|
| 17 |
+
# Set permissions
|
| 18 |
+
subprocess.run(['chmod', '-R', '777', '/data'])
|
| 19 |
+
|
| 20 |
+
# Create empty database file
|
| 21 |
+
db_path = '/data/database/rfp_analysis.db'
|
| 22 |
+
if not os.path.exists(db_path):
|
| 23 |
+
open(db_path, 'a').close()
|
| 24 |
+
|
| 25 |
+
print("Setup completed successfully!")
|
| 26 |
+
return True
|
| 27 |
+
|
| 28 |
+
except Exception as e:
|
| 29 |
+
print(f"Error during setup: {e}", file=sys.stderr)
|
| 30 |
+
return False
|
| 31 |
+
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
setup_directories()
|