Skip to content

Commit aaa5937

Browse files
authored
Merge pull request #178 from SECTL/copilot/fix-packaging-issue
Fix Windows packaging: Switch to onedir mode for stable DLL paths
2 parents 4eac4b5 + 9f38b6b commit aaa5937

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

Secrandom.spec

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,13 @@ if sys.platform == "linux":
7474
exe = EXE(
7575
pyz,
7676
a.scripts,
77-
a.binaries,
78-
a.zipfiles,
79-
a.datas,
8077
[],
78+
exclude_binaries=True,
8179
name=exename,
8280
debug=False,
8381
bootloader_ignore_signals=False,
8482
strip=False,
8583
upx=True,
86-
upx_exclude=[],
87-
runtime_tmpdir=None,
8884
console=False,
8985
disable_windowed_traceback=False,
9086
argv_emulation=False,
@@ -94,7 +90,7 @@ exe = EXE(
9490
icon="resources/secrandom-icon-paper.ico",
9591
)
9692

97-
# 创建目录模式输出
93+
# 创建目录模式输出(onedir模式)
9894
coll = COLLECT(
9995
exe,
10096
a.binaries,
@@ -105,4 +101,3 @@ coll = COLLECT(
105101
upx_exclude=[],
106102
name="SecRandom",
107103
)
108-
#nothing

app/common/windows/uiaccess.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
11
import os
22
import sys
33
import ctypes
4-
from ctypes import wintypes
54
from subprocess import list2cmdline
6-
from app.tools.path_utils import get_data_path
75

86
from loguru import logger
97

8+
# Only import wintypes on Windows to avoid import errors on other platforms
9+
if os.name == "nt":
10+
from ctypes import wintypes
11+
else:
12+
# Create a dummy wintypes module for non-Windows platforms
13+
# NOTE: These dummy types are ONLY for import compatibility and type hints.
14+
# They should NEVER be instantiated at runtime because:
15+
# 1. All functions using wintypes check _is_windows() first and return early
16+
# 2. The dummy types lack ctypes-specific attributes like .value
17+
# This design is safe because non-Windows code paths never reach wintypes usage
18+
class _DummyWinTypes:
19+
DWORD = int
20+
BOOL = bool
21+
HWND = int
22+
LPCWSTR = str
23+
UINT = int
24+
25+
wintypes = _DummyWinTypes()
26+
27+
from app.tools.path_utils import get_data_path
28+
1029
_uiaccess_dll = None
1130
_user32 = None
1231
_kernel32 = None

0 commit comments

Comments
 (0)