Skip to content

Commit 89a4b24

Browse files
Metadoriusfilmor
authored andcommitted
Add a PyInstaller hook to handle files correctly in PyInstaller
1 parent cf0ce2e commit 89a4b24

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ email = "pythonnet@python.org"
5555
Homepage = "https://pythonnet.github.io/"
5656
Sources = "https://github.com/pythonnet/pythonnet"
5757

58+
[project.entry-points.pyinstaller40]
59+
hook-dirs = "pythonnet._pyinstaller:get_hook_dirs"
60+
5861
[tool.setuptools]
5962
zip-safe = false
6063
py-modules = ["clr"]

pythonnet/_pyinstaller/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import os
2+
3+
def get_hook_dirs():
4+
return [os.path.dirname(__file__)]

pythonnet/_pyinstaller/hook-clr.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from PyInstaller.utils.hooks import collect_data_files, collect_dynamic_libs
2+
3+
try:
4+
binaries = collect_dynamic_libs("pythonnet")
5+
datas = collect_data_files("pythonnet")
6+
except Exception:
7+
# name conflict with https://pypi.org/project/clr/, do not crash if just clr is present
8+
binaries = []
9+
datas = []

0 commit comments

Comments
 (0)