PyInstaller + Inno Setup fails on github actions

15 views
Skip to first unread message

Gaël de Chalendar

unread,
Aug 23, 2024, 7:13:55 AMAug 23
to PyInstaller
Hi,

I try to automatize the release of an app using pyinstaller, inno setup and github actions.

My app works well under linux when installed with pip. This is my primary work environment and I have very limited Windows knowledge.

I am able to build locally on windows with pyinstaller, then to create an installer with inno setup and finally to use the installed app.

But the same made on github actions fails to run with a module not found error on an internal module. So, it seems that when run on github actions the initial exe does not contain all the sources of my app.

Here are the build traces on github actions:

The built installer is here:

Let me know if I can give more details. I don’t know what would help to identify the problem…

Best,
Gaël

bwoodsend

unread,
Aug 23, 2024, 3:59:28 PMAug 23
to PyInstaller
Your project structure is somewhat defunct. Those `src/__init__.py` and `src/__main__.py` files imply that `src` is a package and `yaas.py` is the submodule `src.yaas`. That's reflected in the wheels on PyPI which are installing `__init__.py` et al directly into `site-packages`.

I'm guessing you really want a package called `yaas` in which case you'd insert a `yaas` directory (e.g. `src/yaas/__init__.py`) (personally I'd ditch the `src` and just use `yaas/__init__.py`) then adjust all the internal imports to use `from yaas import worker` instead of `import worker`.

Once you've made that change and dealt with all the collateral damage that the refactor causes, PyInstaller should stop objecting to your modules not being where they're supposed to be.

Gaël de Chalendar

unread,
Aug 24, 2024, 5:17:10 AMAug 24
to PyInstaller
Thanks for your answer. Despite numerous tries, the intricacies of pythons packages and modules, and the various packaging possibilities are still very blurry for me…
I’ll try to correct my project structure as you suggest (I will keep the src-layout though because I saw it suggested on numerous places, like https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/) and I’ll come back here to give the result.
I don’t understand though, why it works locally installed under Linux and Windows and with pip on Linux and Windows, and also with the pyinstaller+inno-setup installer made locally, but not with the pyinstaller+inno setup installer made on github actions.

Gaël

Chris Barker

unread,
Aug 24, 2024, 11:32:16 AMAug 24
to pyins...@googlegroups.com
I’ll try to correct my project structure as you suggest (I will keep the src-layout though because I saw it suggested on numerous places, like https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/) and I’ll come back here to give the result.

Note that the “src layout” is recommended, but done right, it only ads a layer, and the entire package is still all under the top-level package dir. 

That is, no __init__.py in src, and once installed, src is no where to be seen.

If you carefully follow those recommendations you should be good. 

pyinstaller+inno-setup installer made locally,

I don’t get that either, but sometimes a built app will appear to work where it was built because it references things locally. 

-CHB

Gaël de Chalendar

unread,
Aug 25, 2024, 4:38:18 AMAug 25
to PyInstaller

Hi,
Thanks @bwoodsend and @Chris. Correcting the layout seems to have solved the problem as you envisioned. But I had also to introduce a dedicated "main" script for pyinstaller that I called pyinstmain.py and put in src. It reuses the code of __main__.py in src/yaas, avoiding the use of relative imports, that seems to pose problems as I found in an issue.
I also renamed things to avoid ambiguities (like my yaas.py in yaas folder renamed to app.py).

The import error disappeared. Now I have a dll not found error (below) with the github actions version but it is unrelated. I will investigate before eventualy asking for help.

Best,
Gaël



Traceback (most recent call last):
  File "pyinstmain.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 378, in exec_module
  File "yaas\app.py", line 15, in <module>
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 378, in exec_module
  File "yaas\worker.py", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 378, in exec_module
  File "torch\__init__.py", line 148, in <module>
    raise err
OSError: [WinError 126] Le module spécifié est introuvable. Error loading "C:\Users\Gaël de Chalendar\AppData\Local\Temp\_MEI191802\torch\lib\fbgemm.dll" or one of its dependencies.
Le vendredi 23 août 2024 à 21:59:28 UTC+2, bwoodsend a écrit :

Gaël de Chalendar

unread,
Aug 25, 2024, 8:06:53 AMAug 25
to PyInstaller
Just a last note to confirm that the dll error was related to incompatibilities between versions in the github actions runner windows, python, pytorch and numpy. There was issues reported elsewhere with workaround using specific versions. It works now.
Thanks again.
Reply all
Reply to author
Forward
0 new messages