Skip to content

Commit

Permalink
Make PyInstaller bundle all necessary binaries for the mip library.
Browse files Browse the repository at this point in the history
Note that the release command has an additional parameter, as
detailed in the README.

Addresses coin-or/python-mip#76, and will
become obsolete when
pyinstaller/pyinstaller#4762 makes it into
the pyinstaller release.
  • Loading branch information
pgoelz committed Mar 23, 2020
1 parent ed0b301 commit bc141f4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ To make a single file executable, we use [PyInstaller](https://pyinstaller.readt
The command is:

```
python -m eel script.py web --onefile --noconsole
python -m eel script.py web --additional-hooks-dir=. --onefile --noconsole
```

**Platform** means Windows, Mac OS X or Linux. So if you run the above command on Linux, you can give the file to someone else running Linux. So if the person who wants the app is running Windows, you need to run the above command on Windows.
Expand Down
15 changes: 15 additions & 0 deletions hook-mip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Ensures that PyInstaller copies the CBC binaries for the mip library.
# See https://github.com/coin-or/python-mip/issues/76.
# Should become obsolete once https://github.com/pyinstaller/pyinstaller/pull/4762
# gets merged and makes it into the pyinstaller release.

import os
from PyInstaller.utils.hooks import get_package_paths

datas = []
_, mip_path = get_package_paths("mip")
lib_path = os.path.join(mip_path, "libraries")

for f in os.listdir(lib_path):
if f.endswith(".so") or f.endswith(".dll") or f.endswith(".dylib"):
datas.append((os.path.join(lib_path, f), "mip/libraries"))

0 comments on commit bc141f4

Please sign in to comment.