Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VERSION file not properly found by pyInstaller #52

Closed
VolkerSiep opened this issue Jan 29, 2021 · 8 comments
Closed

VERSION file not properly found by pyInstaller #52

VolkerSiep opened this issue Jan 29, 2021 · 8 comments

Comments

@VolkerSiep
Copy link

VolkerSiep commented Jan 29, 2021

After updating from 1.4.1 to 1.5.2, pyInstaller cannot find the VERSION file when using the iapws package as part of the bundle:

Traceback (most recent call last):
  File "ydb\ydb_server.py", line 30, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
  File "ydb\__init__.py", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
  File "ydb\iapws_ydb.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
  File "iapws\__init__.py", line 15, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\...\\dist_test_3\\ydb_server\\iapws\\VERSION'

I don't know how other packages do not cause this trouble with their datafiles, otherwise I could suggest a solution directly.

I was a bit in a hurry .. will investigate more on my side:

  1. Whether the file was bundled but is just in another directory
  2. Whether I can reproduce this in a minimal example.
@jjgomera
Copy link
Owner

jjgomera commented Feb 1, 2021

I don't use pyinstaller neither windows, so I can't reproduce your error, it's like the file path of VERSION file don't be correct, would be
C:\Users\...\dist_test_3\ydb_server\iapws\iapws\VERSION

Can you show the the initial code of iapws_init_.py, it's like you are not using the latest version or I don't know how pyinstaller path work

@jjgomera
Copy link
Owner

jjgomera commented Feb 1, 2021

Maybe the error came from here:
https://pyinstaller.readthedocs.io/en/stable/runtime-information.html

@jjgomera
Copy link
Owner

jjgomera commented Feb 1, 2021

Ok, I think solved in last commit, try with that (github repo only)
Pyinstaller need a code release in pypi or similar?

@VolkerSiep
Copy link
Author

I just created a minimal example and see that the data file VERSION is not bundled at all. Once the file is bundled, I'm sure we can make it found by the code. You have my empathy not using Windows.

I would run into the same issue with my own stuff soon, so I'll investigate this further and keep you updated on this channel.

Here a minimal example (including a readme.txt how to recreate the issue): iapws_test.zip

@VolkerSiep
Copy link
Author

I tried several things but decided to take this up on stackoverflow.

@jjgomera
Copy link
Owner

jjgomera commented Feb 3, 2021

Install the last version from github with last commit and try again

@VolkerSiep
Copy link
Author

I did that I think:

devel#C:\...\iapws_test\iapws>git log -1
commit de7a0930ce086ee397eb02603ece82381d79b2ac (HEAD -> master, origin/master, origin/HEAD)
Author: jjgomera <...>
Date:   Mon Feb 1 12:30:40 2021 +0100

    Fix pyinstaller bundle file path using absolute path

But I also saw now that this is likely not in your hands. pyInstaller maintains a huge set of hook files (short python scripts) that do special things for special packages. One such special thing is to collect data files. There are 232 files in

\Lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks.

For instance for imageio:

from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('imageio', subdir="resources")

I will create a similar hook-file for iapws and share it with you. Once the file is collected correctly, your recent commit will likely make it work alltogether.

@VolkerSiep
Copy link
Author

Now it works. I created a standard hook from pyInstaller, hook-iapws.py consisting of the two lines:

from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('iapws')

Then I added the containing directory into the Analysis part of the pyInstaller spec file:

a = Analysis(['main.py'],
             ...
             hookspath=["pyinstaller-hooks"],
             ...
             )

Then it even worked with iapws release 1.5.2, but also with the latest commit.

Thanks for your collaboration and fast responses. In the end, this was not on your side. Only if you like, I just found there is actually a way to tell pyInstaller about an existing hook for your package: here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants