Spaces:
Sleeping
Sleeping
File size: 5,656 Bytes
93917f2 |
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# -*- mode: python ; coding: utf-8 -*-
import os
import sys
from pathlib import Path
from PyInstaller.utils.hooks import collect_data_files, collect_submodules, copy_metadata
# Initialize key variables
block_cipher = None
# Get the directory containing the spec file
import os
SPECPATH = os.getcwd() # Use current directory
excludes = [] # Initialize excludes list
print(f"Using SPECPATH: {SPECPATH}")
# Add patch_pytensor to the entry point
patch_pytensor = os.path.join(SPECPATH, 'patch_pytensor.py')
if not os.path.exists(patch_pytensor):
raise FileNotFoundError(f"patch_pytensor.py not found at {patch_pytensor}")
# Collect all data files with specific includes
arviz_data = collect_data_files('arviz', includes=['**/static/**', '**/*.html', '**/*.css', '**/example_data/**', '**/*.json'])
pymc_data = collect_data_files('pymc', includes=['**/*.dat', '**/*.json', '**/*.txt'])
pytensor_data = collect_data_files('pytensor')
numpy_data = collect_data_files('numpy')
scipy_data = collect_data_files('scipy')
xarray_data = collect_data_files('xarray')
# Add package metadata (needed for some dependencies)
metadata = []
packages_with_data = ['pymc', 'arviz', 'pytensor', 'numpy', 'xarray']
print("\nCollecting metadata and data files:")
for pkg in packages_with_data:
try:
meta = copy_metadata(pkg)
print(f"Found metadata for {pkg}")
metadata.extend(meta)
except Exception as e:
print(f"Warning: Could not collect metadata for {pkg}: {e}")
# Collect all necessary submodules
hidden = []
# Explicitly collect all arviz submodules
arviz_submodules = collect_submodules('arviz')
print(f"\nCollected {len(arviz_submodules)} arviz submodules")
hidden.extend(arviz_submodules)
# Collect other package submodules
for pkg in [
'pymc',
'pytensor',
'numpy',
'scipy',
'pandas',
'xarray',
'netCDF4',
'cftime'
]:
hidden.extend(collect_submodules(pkg))
# Add Codette-specific imports
codette_modules = []
# Check which modules actually exist
potential_modules = [
'cognitive_processor',
'codette_quantum_core',
'agireasoning',
'ai_core_system',
'ai_core_identityscan',
'analyze_cocoons'
]
for module in potential_modules:
if os.path.exists(os.path.join(SPECPATH, f"{module}.py")):
codette_modules.append(module)
hidden.extend(codette_modules)
# Handle PyTensor/Numba warnings by making them optional
try:
import numba
hidden.extend(['numba', 'pytensor.link.numba.dispatch'])
except ImportError:
print("Numba not found - skipping numba-related imports")
# Skip test modules to avoid pytest dependencies
excludes.extend([
'numpy.f2py.tests',
'scipy.tests',
'pandas.tests',
'xarray.tests'
])
# Combine all data files with error handling
datas = []
data_collections = [
('arviz', arviz_data),
('pymc', pymc_data),
('pytensor', pytensor_data),
('numpy', numpy_data),
('scipy', scipy_data),
('xarray', xarray_data)
]
print("\nAdding data files:")
for pkg_name, data_files in data_collections:
try:
print(f"Adding {len(data_files)} files from {pkg_name}")
datas.extend(data_files)
except Exception as e:
print(f"Warning: Error adding data files from {pkg_name}: {e}")
# Add metadata files
try:
print(f"Adding {len(metadata)} metadata files")
datas.extend(metadata)
except Exception as e:
print(f"Warning: Error adding metadata files: {e}")
# Add Codette's own data files and check their existence
codette_core_files = [
('cognitive_processor.py', '.'),
('codette_quantum_core.py', '.'),
('agireasoning.py', '.'),
('ai_core_system.py', '.'),
('ai_core_identityscan.py', '.'),
('analyze_cocoons.py', '.'),
('analyze_cocoons1.py', '.'),
('analyze_cocoons2.py', '.'),
('analyze_cocoons3.py', '.')
]
# Only add files that exist
datas.extend([
(src, dst) for src, dst in codette_core_files
if os.path.exists(os.path.join(SPECPATH, src))
])
# Add models directory if it exists
models_dir = os.path.join(SPECPATH, 'models')
if os.path.exists(models_dir):
for root, dirs, files in os.walk(models_dir):
for file in files:
if file.endswith('.py'):
full_path = os.path.join(root, file)
rel_path = os.path.relpath(root, SPECPATH)
datas.append((full_path, rel_path))
# Print summary of what we're including
print("\nBuild Summary:")
print(f"Total data files: {len(datas)}")
print(f"Hidden imports: {len(hidden)}")
print(f"Excluded modules: {len(excludes)}")
a = Analysis(
['launcher.py'],
pathex=[SPECPATH], # Add the current directory to path
binaries=[],
datas=datas,
hiddenimports=hidden,
hookspath=[],
hooksconfig={},
runtime_hooks=['hook-runtime-arviz.py'] if os.path.exists('hook-runtime-arviz.py') else [],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
exclude_binaries=True,
name='Codette',
debug=True,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=True, # Keep console for debugging
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
# Collect everything into a directory
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name='Codette'
)
|