199 lines
6.2 KiB
Python
199 lines
6.2 KiB
Python
# -*- mode: python ; coding: utf-8 -*-
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Get the base directory (current working directory)
|
|
base_dir = Path.cwd()
|
|
|
|
# Collect Django apps data
|
|
datas = []
|
|
|
|
# Add templates directory
|
|
templates_dir = base_dir / 'templates'
|
|
if templates_dir.exists():
|
|
for root, dirs, files in os.walk(templates_dir):
|
|
for file in files:
|
|
file_path = Path(root) / file
|
|
relative_path = file_path.relative_to(base_dir)
|
|
datas.append((str(file_path), str(relative_path.parent)))
|
|
|
|
# Add static files directory
|
|
static_dir = base_dir / 'static'
|
|
if static_dir.exists():
|
|
for root, dirs, files in os.walk(static_dir):
|
|
for file in files:
|
|
file_path = Path(root) / file
|
|
relative_path = file_path.relative_to(base_dir)
|
|
datas.append((str(file_path), str(relative_path.parent)))
|
|
|
|
# Add media files directory
|
|
media_dir = base_dir / 'media'
|
|
if media_dir.exists():
|
|
for root, dirs, files in os.walk(media_dir):
|
|
for file in files:
|
|
file_path = Path(root) / file
|
|
relative_path = file_path.relative_to(base_dir)
|
|
datas.append((str(file_path), str(relative_path.parent)))
|
|
|
|
# Add all Django apps with their migrations
|
|
django_apps = ['core', 'users', 'inventory', 'purchase', 'manufacture', 'sales']
|
|
for app in django_apps:
|
|
app_dir = base_dir / app
|
|
if app_dir.exists():
|
|
# Add the app directory
|
|
for root, dirs, files in os.walk(app_dir):
|
|
for file in files:
|
|
file_path = Path(root) / file
|
|
relative_path = file_path.relative_to(base_dir)
|
|
datas.append((str(file_path), str(relative_path.parent)))
|
|
|
|
# Add templates for this app if they exist
|
|
app_templates_dir = base_dir / 'templates' / app
|
|
if app_templates_dir.exists():
|
|
for root, dirs, files in os.walk(app_templates_dir):
|
|
for file in files:
|
|
file_path = Path(root) / file
|
|
relative_path = file_path.relative_to(base_dir)
|
|
datas.append((str(file_path), str(relative_path.parent)))
|
|
|
|
# Add the database
|
|
# Database is now kept external to the executable
|
|
# db_file = base_dir / 'db.sqlite3'
|
|
# if db_file.exists():
|
|
# datas.append((str(db_file), '.'))
|
|
|
|
# Add crispy forms templates
|
|
try:
|
|
import crispy_forms
|
|
crispy_forms_path = Path(crispy_forms.__file__).parent
|
|
crispy_templates_dir = crispy_forms_path / 'templates'
|
|
if crispy_templates_dir.exists():
|
|
for root, dirs, files in os.walk(crispy_templates_dir):
|
|
for file in files:
|
|
file_path = Path(root) / file
|
|
relative_path = file_path.relative_to(crispy_forms_path)
|
|
datas.append((str(file_path), str(relative_path.parent)))
|
|
except ImportError:
|
|
pass
|
|
|
|
# Add crispy bootstrap5 templates
|
|
try:
|
|
import crispy_bootstrap5
|
|
crispy_bootstrap5_path = Path(crispy_bootstrap5.__file__).parent
|
|
crispy_bootstrap5_templates_dir = crispy_bootstrap5_path / 'templates'
|
|
if crispy_bootstrap5_templates_dir.exists():
|
|
for root, dirs, files in os.walk(crispy_bootstrap5_templates_dir):
|
|
for file in files:
|
|
file_path = Path(root) / file
|
|
relative_path = file_path.relative_to(crispy_bootstrap5_path)
|
|
datas.append((str(file_path), str(relative_path.parent)))
|
|
except ImportError:
|
|
pass
|
|
|
|
# Add Django templates
|
|
try:
|
|
import django
|
|
django_path = Path(django.__file__).parent
|
|
django_templates_dir = django_path / 'forms' / 'templates'
|
|
if django_templates_dir.exists():
|
|
for root, dirs, files in os.walk(django_templates_dir):
|
|
for file in files:
|
|
file_path = Path(root) / file
|
|
relative_path = file_path.relative_to(django_path)
|
|
datas.append((str(file_path), str(relative_path.parent)))
|
|
except ImportError:
|
|
pass
|
|
|
|
# Add more Django templates
|
|
try:
|
|
import django
|
|
django_path = Path(django.__file__).parent
|
|
django_contrib_dir = django_path / 'contrib'
|
|
if django_contrib_dir.exists():
|
|
for root, dirs, files in os.walk(django_contrib_dir):
|
|
# Look for templates directories
|
|
if 'templates' in dirs:
|
|
templates_dir = Path(root) / 'templates'
|
|
for t_root, t_dirs, t_files in os.walk(templates_dir):
|
|
for file in t_files:
|
|
file_path = Path(t_root) / file
|
|
relative_path = file_path.relative_to(django_path)
|
|
datas.append((str(file_path), str(relative_path.parent)))
|
|
except ImportError:
|
|
pass
|
|
|
|
# Hidden imports for Django
|
|
hiddenimports = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'django_extensions',
|
|
'crispy_forms',
|
|
'crispy_bootstrap5',
|
|
'core',
|
|
'users',
|
|
'inventory',
|
|
'purchase',
|
|
'manufacture',
|
|
'sales',
|
|
'manufacture_app',
|
|
'django.contrib.admin.apps',
|
|
'django.contrib.auth.apps',
|
|
'django.contrib.contenttypes.apps',
|
|
'django.contrib.sessions.apps',
|
|
'django.contrib.messages.apps',
|
|
'django.contrib.staticfiles.apps',
|
|
# Additional imports for form rendering
|
|
'django.forms',
|
|
'django.forms.widgets',
|
|
'django.forms.models',
|
|
'django.forms.fields',
|
|
'django.forms.boundfield',
|
|
# Additional imports for model relationships
|
|
'django.db.models',
|
|
'django.db.models.fields',
|
|
'django.db.models.fields.related',
|
|
'django.db.models.fields.reverse_related',
|
|
]
|
|
|
|
a = Analysis(
|
|
['start_server.py'],
|
|
pathex=[],
|
|
binaries=[],
|
|
datas=datas,
|
|
hiddenimports=hiddenimports,
|
|
hookspath=[],
|
|
hooksconfig={},
|
|
runtime_hooks=[],
|
|
excludes=[],
|
|
noarchive=False,
|
|
optimize=0,
|
|
)
|
|
pyz = PYZ(a.pure)
|
|
|
|
exe = EXE(
|
|
pyz,
|
|
a.scripts,
|
|
a.binaries,
|
|
a.datas,
|
|
[],
|
|
name='start_server',
|
|
debug=False,
|
|
bootloader_ignore_signals=False,
|
|
strip=False,
|
|
upx=True,
|
|
upx_exclude=[],
|
|
runtime_tmpdir=None,
|
|
console=True,
|
|
disable_windowed_traceback=False,
|
|
argv_emulation=False,
|
|
target_arch=None,
|
|
codesign_identity=None,
|
|
entitlements_file=None,
|
|
)
|