Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a PyInstaller hook to handle files correctly in PyInstaller
  • Loading branch information
Metadorius committed Mar 27, 2026
commit d2db7c7e70c0652a515808c2bd19238967d6523a
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ email = "pythonnet@python.org"
Homepage = "https://pythonnet.github.io/"
Sources = "https://github.com/pythonnet/pythonnet"

[project.entry-points.pyinstaller40]
hook-dirs = "pythonnet._pyinstaller:get_hook_dirs"

[tool.setuptools]
zip-safe = false
py-modules = ["clr"]
Expand Down
4 changes: 4 additions & 0 deletions pythonnet/_pyinstaller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os

def get_hook_dirs():
return [os.path.dirname(__file__)]
9 changes: 9 additions & 0 deletions pythonnet/_pyinstaller/hook-clr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from PyInstaller.utils.hooks import collect_data_files, collect_dynamic_libs

try:
binaries = collect_dynamic_libs("pythonnet")
datas = collect_data_files("pythonnet")
except Exception:
# name conflict with https://pypi.org/project/clr/, do not crash if just clr is present
binaries = []
datas = []