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

Internal pyinstaller hook to include dynamic libraries on Windows. #2058

Merged
merged 1 commit into from Aug 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions setup.cfg
Expand Up @@ -19,3 +19,7 @@ commands =
[pylint.MESSAGES CONTROL]
extension-pkg-whitelist=pygame
disable=useless-object-inheritance

[options.entry_points]
pyinstaller40 =
hook-dirs = pygame.__pyinstaller:get_hook_dirs
6 changes: 4 additions & 2 deletions setup.py
Expand Up @@ -792,13 +792,15 @@ def run(self):
'pygame.tests.run_tests__tests.timeout',
'pygame.tests.run_tests__tests.everything',
'pygame.docs',
'pygame.examples'],
'pygame.examples',
'pygame.__pyinstaller'],
"package_dir": {'pygame': 'src_py',
'pygame._sdl2': 'src_py/_sdl2',
'pygame.threads': 'src_py/threads',
'pygame.tests': 'test',
'pygame.docs': 'docs',
'pygame.examples': 'examples'},
'pygame.examples': 'examples',
'pygame.__pyinstaller': 'src_py/__pyinstaller'},
"headers": headers,
"ext_modules": extensions,
"data_files": data_files,
Expand Down
5 changes: 5 additions & 0 deletions src_py/__pyinstaller/__init__.py
@@ -0,0 +1,5 @@
import os


def get_hook_dirs():
return [os.path.dirname(__file__)]
19 changes: 19 additions & 0 deletions src_py/__pyinstaller/hook-pygame.py
@@ -0,0 +1,19 @@
"""
binaries hook for pygame seems to be required for pygame 2.0 Windows.
Otherwise some essential DLLs will not be transfered to the exe.
"""

import platform

if platform.system() == "Windows":

from PyInstaller.utils.hooks import collect_dynamic_libs

pre_binaries = collect_dynamic_libs('pygame')
binaries = []

for b in pre_binaries:
binary, location = b
# settles all the DLLs into the top level folder, which prevents duplication
# with the DLLs already being put there.
binaries.append((binary, "."))