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

Failed to load registry bank #196

Closed
cedricscheepers opened this issue Apr 24, 2024 · 6 comments
Closed

Failed to load registry bank #196

cedricscheepers opened this issue Apr 24, 2024 · 6 comments

Comments

@cedricscheepers
Copy link

cedricscheepers commented Apr 24, 2024

Hi

First of all, great library! Thank you for all your hard work.

Please help me. I am having an issue with validating IBANs on Windows. For the IBAN GB84DEUT40508114998100, using the following code:

    from schwifty import IBAN     <-   Issue is here

I get the error: Failed to load registry bank. I also have to add that this is part of a pyinstaller compiled application.

A traceback gives me:
File "modules\classes.py", line 1311, in __validate_ibans
File "modules\classes.py", line 482, in init
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "schwifty_init
.py", line 6, in
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "schwifty\bban.py", line 9, in
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "schwifty\bic.py", line 465, in
File "schwifty\registry.py", line 93, in build_index
File "schwifty\registry.py", line 71, in get
ValueError: Failed to load registry bank

Could you please help me.

Kind regards
Cedric

@mdomke
Copy link
Owner

mdomke commented Apr 24, 2024

Maybe this #187 (comment) helps in your case as well?

@mdomke
Copy link
Owner

mdomke commented May 7, 2024

@cedricscheepers could you verify that something similar to

$ pyinstaller schwifty-test.py --name schwifty-test --onefile --console --add-data=C:\Users\christi\AppData\Local\Programs\Python\Python312\Lib\site-packages\schwifty:. --copy-metadata schwifty

helps?

@rokm
Copy link

rokm commented May 9, 2024

The canonical solution would be --collect-data schwifty --copy-metadata schwifty and to revert #92, because the bank_registry data directory is/should be collected as sys._MEIPASS/schwifty/bank_registry and not sys._MEIPASS/bank_registry. Plus, PyInstaller supports importlib.resources.files() since v4.6 (which predates #92), so no special handling is needed. (Alternatively, the package_path for frozen codepath should be fixed into package_path = Path(__file__).parent).

@mdomke
Copy link
Owner

mdomke commented May 9, 2024

@rokm Thank you very much for the clarification. I'm not a pyinstaller user myself and should have paid more attention when integrating the changes in #92. The aforementioned pull-request has been reverted in release 2024.05.1. As I understand from pyinstaller/pyinstaller#8458 you would be willing to add a hook that simplifies the integration of schwifty to pystinaller? Otherwise, I could also add some instructions to schwifty's documentation.

@mdomke
Copy link
Owner

mdomke commented May 9, 2024

@cedricscheepers with schwifty release 2024.05.2 you should be able to do

$ pyinstaller schwifty-test.py --copy-metadata schwifty --collect-data schwifty

Possibly, a custom pyinstaller-hook will make it even easier in the future. Can you confirm that this works for you?

@rokm
Copy link

rokm commented May 9, 2024

@rokm Thank you very much for the clarification. I'm not a pyinstaller user myself and should have paid more attention when integrating the changes in #92. The aforementioned pull-request has been reverted in release 2024.05.1. As I understand from pyinstaller/pyinstaller#8458 you would be willing to add a hook that simplifies the integration of schwifty to pystinaller? Otherwise, I could also add some instructions to schwifty's documentation.

Thanks for promptly taking care of the problem!

We will indeed add a hook for schwifty that will automatically perform the equivalent of --copy-metadata schwifty --collect-data schwifty - see pyinstaller/pyinstaller-hooks-contrib#742. After installing the release of pyinstaller-hooks-contrib that will include the linked PR, schwifty will work out-of-the-box with PyInstaller.

@mdomke mdomke closed this as completed May 10, 2024
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

3 participants