Skip to content

Commit f795820

Browse files
codewizdaveclaude
andcommitted
fix(build): replace __file__ with os.getcwd() in spec file
__file__ is not available in PyInstaller spec file namespace because PyInstaller uses exec() to run the spec. Use os.getcwd() to get the repository root directory instead. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent f1cc5d6 commit f795820

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

build/gui.spec

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ all dependencies and can run without Python installation.
88

99
import sys
1010
import os
11-
from pathlib import Path
1211
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
1312

1413
block_cipher = None
1514

16-
# Get the directory containing this spec file
17-
SPEC_DIR = Path(__file__).parent
18-
REPO_ROOT = SPEC_DIR.parent
15+
# PyInstaller executes this from the repository root
16+
# Use os.getcwd() to get the current working directory
17+
REPO_ROOT = os.getcwd()
18+
SPEC_DIR = os.path.join(REPO_ROOT, 'build')
1919

2020
# Collect all data files from excel_to_sql
2121
excel_to_sql_datas = collect_data_files('excel_to_sql')
2222

2323
a = Analysis(
24-
[str(REPO_ROOT / 'src' / 'wareflow_analysis' / 'gui' / '__main__.py')],
25-
pathex=[str(REPO_ROOT)],
24+
[os.path.join(REPO_ROOT, 'src', 'wareflow_analysis', 'gui', '__main__.py')],
25+
pathex=[REPO_ROOT],
2626
binaries=[],
2727
datas=[
2828
# Source code
29-
(str(REPO_ROOT / 'src' / 'wareflow_analysis'), 'wareflow_analysis'),
29+
(os.path.join(REPO_ROOT, 'src', 'wareflow_analysis'), 'wareflow_analysis'),
3030

3131
# Templates
32-
(str(REPO_ROOT / 'src' / 'wareflow_analysis' / 'templates'), 'wareflow_analysis/templates'),
32+
(os.path.join(REPO_ROOT, 'src', 'wareflow_analysis', 'templates'), 'wareflow_analysis/templates'),
3333

3434
# Excel-to-SQL data files
35-
*[(str(REPO_ROOT / src), dst) for src, dst in excel_to_sql_datas],
35+
*[(os.path.join(REPO_ROOT, src), dst) for src, dst in excel_to_sql_datas],
3636
],
3737
hiddenimports=[
3838
# GUI framework
@@ -157,5 +157,5 @@ exe = EXE(
157157
target_arch=None,
158158
codesign_identity=None,
159159
entitlements_file=None,
160-
icon=str(SPEC_DIR / 'icon.ico'),
160+
icon=os.path.join(SPEC_DIR, 'icon.ico'),
161161
)

0 commit comments

Comments
 (0)