-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c04c42c
commit 6257b49
Showing
6 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from os.path import dirname | ||
|
||
|
||
HERE = dirname(__file__) | ||
|
||
|
||
def get_hook_dirs(): | ||
return [HERE] | ||
|
||
|
||
def get_test_dirs(): | ||
return [HERE] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from PyInstaller.utils.conftest import * # noqa: F403 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# ruff: noqa: N999 | ||
|
||
from PyInstaller.utils.hooks import collect_dynamic_libs | ||
|
||
# Init variables that PyInstaller will pick up. | ||
hiddenimports = [] | ||
datas = [] | ||
binaries = [] | ||
|
||
# Add modules that are safe to add, i.e. don't pull in dependencies that we don't want. | ||
hiddenimports += ["rendercanvas.offscreen"] | ||
|
||
# Since glfw does not have a hook like this, it does not include the glfw binary | ||
# when freezing. We can solve this with the code below. Makes the binary a bit | ||
# larger, but only marginally (less than 300kb). | ||
try: | ||
import glfw # noqa: F401 | ||
except ImportError: | ||
pass | ||
else: | ||
hiddenimports += ["rendercanvas.glfw"] | ||
binaries += collect_dynamic_libs("glfw") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
script = """ | ||
# The script part | ||
import sys | ||
import importlib | ||
from rendercanvas.auto import RenderCanvas | ||
if "glfw" not in RenderCanvas.__name__.lower(): | ||
raise RuntimeError(f"Expected a glfw canvas, got {RenderCanvas.__name__}") | ||
# The test part | ||
if "is_test" in sys.argv: | ||
included_modules = [ | ||
"rendercanvas.glfw", | ||
"rendercanvas.offscreen", | ||
"glfw", | ||
] | ||
excluded_modules = [ | ||
"PySide6.QtGui", | ||
"PyQt6.QtGui", | ||
] | ||
for module_name in included_modules: | ||
importlib.import_module(module_name) | ||
for module_name in excluded_modules: | ||
try: | ||
importlib.import_module(module_name) | ||
except ModuleNotFoundError: | ||
continue | ||
raise RuntimeError(module_name + " is not supposed to be importable.") | ||
""" | ||
|
||
|
||
def test_pyi_rendercanvas(pyi_builder): | ||
pyi_builder.test_source(script, app_args=["is_test"]) | ||
|
||
|
||
# We could also test the script below, but it's not that interesting since it uses direct imports. | ||
# To safe CI-time we don't actively test it. | ||
script_qt = """ | ||
import sys | ||
import importlib | ||
import PySide6 | ||
from rendercanvas.qt import RenderCanvas | ||
assert "qt" in RenderCanvas.__name__.lower() | ||
""" |