Commit 5f2a0df
authored
Fix PyInstaller packaging: .version file not found error (#4916)
When PaddleX is packaged with PyInstaller, the .version file cannot be
located because __file__ points to the temporary extraction directory
(_MEIxxxxxx) but the file path resolution doesn't account for the
PyInstaller bundle structure.
This fix:
- Adds _get_package_dir() helper that detects PyInstaller environment
using sys.frozen and sys._MEIPASS attributes
- Returns correct path for both normal and frozen (PyInstaller) execution
- Adds fallback to "unknown" version if file is still not found
Users must still include the .version file in their PyInstaller bundle
using --add-data or datas in spec file.1 parent 2771144 commit 5f2a0df
1 file changed
+18
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
21 | 31 | | |
22 | 32 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
27 | 41 | | |
28 | 42 | | |
29 | 43 | | |
| |||
0 commit comments