dominicprice / endplay

A suite of tools for generation and analysis of bridge deals. Read the documentation at https://endplay.readthedocs.io
MIT License
21 stars 5 forks source link

Wrapping endplay in a solution using PyInstaller #30

Closed ThorvaldAagaard closed 11 months ago

ThorvaldAagaard commented 11 months ago

I have written a small application, that is using Endplay, and wrapped that application in a standalone executable.

When I try to execute the application I get this error

RuntimeError: Unable to load the dds library: shared library object could not be loaded by ctypes.
Note: This probably means that the library was compiled for a different architecture to your current machine.
Note: If you have a C++ compiler on your computer, you can try to install the library from source with the command `pip install endplay --no-binary`
Note: Otherwise, please raise this as a bug on the github issue tracker ( https://github.com/dominicprice/endplay/issues ). You should include information about what platform you are on in the issue by including the result of running python -c "import platform; print(platform.architecture(), platform.machine())"
Note: The error raised by ctypes states the following reason:
Note: Failed to load dynlib/dll 'C:\\Users\\User\\AppData\\Local\\Temp\\_MEI62042\\endplay\\_dds\\dds.dll'. Most likely this dynlib/dll was not found when the application was frozen.

Now before I start the compiler it would be more interesting if I could just avoid loading dds as I am not using the dds at all.

My platform is: ('64bit', 'WindowsPE') AMD64

dominicprice commented 11 months ago

Hi, Yeah that is valid. You can avoid loading dds by just commenting out the large try block at the top of _dds/__init__.py which picks up the library (and then will probably get an AttributeError at the point you try and call anything which uses it which should solve your problem), but this is probably something which might be nice to be made switchable, perhaps an env var ENDPLAY_NO_DDS or something?

ThorvaldAagaard commented 11 months ago

I am using dds in other solutions and there is no problem including it

Lorand Dali has this implementation: https://github.com/lorserker/ben/blob/main/src/ddsolver/dds.py but I am not sure if that requires the Anaconda-environment.

BUT I think the problem might be PyInstaller not picking up the DLL, and will make some more testing and return

ThorvaldAagaard commented 11 months ago

Yes, I was right. I found a way to add the dll, so now it is working

pyinstaller --add-binary "C:\Python311\Lib\site-packages\endplay\_dds\dds.dll;." TMPbn2LinVG.py -F --onefile