Update setup.py
Browse files
setup.py
CHANGED
|
@@ -1,32 +1,65 @@
|
|
| 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 |
-
#
|
| 10 |
-
os.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
# Create
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# Create empty database file
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
print("Setup completed successfully!")
|
| 26 |
return True
|
| 27 |
|
| 28 |
except Exception as e:
|
| 29 |
-
print(f"Error during setup: {e}"
|
| 30 |
return False
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
|
|
|
| 1 |
# setup.py
|
| 2 |
import os
|
|
|
|
| 3 |
import sys
|
| 4 |
+
import shutil
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
import streamlit as st
|
| 7 |
|
| 8 |
def setup_directories():
|
| 9 |
"""Set up necessary directories and permissions."""
|
| 10 |
try:
|
| 11 |
+
# Define base directories
|
| 12 |
+
if os.path.exists('/data'):
|
| 13 |
+
# Hugging Face Space environment
|
| 14 |
+
base_path = Path('/data')
|
| 15 |
+
else:
|
| 16 |
+
# Local development environment
|
| 17 |
+
base_path = Path(os.getcwd()) / 'data'
|
| 18 |
|
| 19 |
+
# Create required directories
|
| 20 |
+
directories = [
|
| 21 |
+
base_path / 'database',
|
| 22 |
+
base_path / 'files',
|
| 23 |
+
base_path / 'vectorstore',
|
| 24 |
+
base_path / 'metadata',
|
| 25 |
+
Path('img'), # for logo
|
| 26 |
+
Path('components'),
|
| 27 |
+
Path('utils'),
|
| 28 |
+
Path('static/thumbnails')
|
| 29 |
+
]
|
| 30 |
|
| 31 |
+
# Create each directory
|
| 32 |
+
for directory in directories:
|
| 33 |
+
directory.mkdir(parents=True, exist_ok=True)
|
| 34 |
+
print(f"Created directory: {directory}")
|
| 35 |
+
|
| 36 |
+
# Create empty __init__.py files for Python packages
|
| 37 |
+
init_dirs = ['components', 'utils']
|
| 38 |
+
for dir_name in init_dirs:
|
| 39 |
+
init_file = Path(dir_name) / '__init__.py'
|
| 40 |
+
init_file.touch(exist_ok=True)
|
| 41 |
+
print(f"Created {init_file}")
|
| 42 |
|
| 43 |
# Create empty database file
|
| 44 |
+
db_file = base_path / 'database' / 'rfp_analysis.db'
|
| 45 |
+
db_file.touch(exist_ok=True)
|
| 46 |
+
print(f"Created database file: {db_file}")
|
| 47 |
+
|
| 48 |
+
# Set permissions if in Linux environment
|
| 49 |
+
if sys.platform.startswith('linux'):
|
| 50 |
+
try:
|
| 51 |
+
for directory in directories:
|
| 52 |
+
os.chmod(directory, 0o777)
|
| 53 |
+
os.chmod(db_file, 0o666)
|
| 54 |
+
print("Set permissions successfully")
|
| 55 |
+
except Exception as e:
|
| 56 |
+
print(f"Warning: Could not set permissions: {e}")
|
| 57 |
|
| 58 |
print("Setup completed successfully!")
|
| 59 |
return True
|
| 60 |
|
| 61 |
except Exception as e:
|
| 62 |
+
print(f"Error during setup: {e}")
|
| 63 |
return False
|
| 64 |
|
| 65 |
if __name__ == "__main__":
|