Error when packaging extension modules statically
ofek opened this issue · comments
def make_exe():
dist = default_python_distribution(flavor="standalone_static")
policy = dist.make_python_packaging_policy()
python_config = dist.make_python_interpreter_config()
python_config.run_module = "ddqa"
exe = dist.to_python_executable(
name="ddqa",
packaging_policy=policy,
config=python_config,
)
exe.add_python_resources(exe.pip_install(["."]))
return exe
def make_embedded_resources(exe):
return exe.to_embedded_resources()
def make_install(exe):
files = FileManifest()
files.add_python_resource(".", exe)
return files
register_target("exe", make_exe)
register_target("resources", make_embedded_resources, depends=["exe"], default_build_script=True)
register_target("install", make_install, depends=["exe"], default=True)
resolve_targets()
...
Creating C:\Users\ofek\AppData\Local\Temp\pip-target-h8v3ub1g\bin
Successfully installed click-8.1.3 colorama-0.4.6 commonmark-0.9.1 ddqa-0.0.1 importlib-metadata-4.13.0 nanoid-2.0.0 pillow-9.4.0 pydantic-1.10.4 pygments-2.14.0 pyperclip-1.8.2 rich-13.1.0 textual-0.9.1 tomli-2.0.1 tomli-w-1.0.0 typing-extensions-4.4.0 zipp-3.11.0
error[PYOXIDIZER_PYTHON_EXECUTABLE]: adding PythonExtensionModule<name=PIL._imaging>
Caused by:
extension module PIL._imaging cannot be loaded from memory but memory loading required
--> app\pyoxidizer.bzl:17:5
|
17 | exe.add_python_resources(exe.pip_install(["."]))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ add_python_resources()
error: adding PythonExtensionModule<name=PIL._imaging>
Caused by:
extension module PIL._imaging cannot be loaded from memory but memory loading required
If I remove the static flavor then the build succeeds but when I run the executable it says in a pop up that the DLL file for Python 3.10 cannot be found (presumably because I don't have that installed currently)
Actually I tried removing Pillow and this is happening with other packages too:
Creating C:\Users\ofek\AppData\Local\Temp\pip-target-8ko7ie40\bin
Successfully installed click-8.1.3 colorama-0.4.6 commonmark-0.9.1 ddqa-0.0.1 importlib-metadata-4.13.0 nanoid-2.0.0 pydantic-1.10.4 pygments-2.14.0 pyperclip-1.8.2 rich-13.1.0 textual-0.9.1 tomli-2.0.1 tomli-w-1.0.0 typing-extensions-4.4.0 zipp-3.11.0
error[PYOXIDIZER_PYTHON_EXECUTABLE]: adding PythonExtensionModule<name=pydantic>
Caused by:
extension module pydantic cannot be loaded from memory but memory loading required
--> app\pyoxidizer.bzl:17:5
|
17 | exe.add_python_resources(exe.pip_install(["."]))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ add_python_resources()
error: adding PythonExtensionModule<name=pydantic>
Caused by:
extension module pydantic cannot be loaded from memory but memory loading required
@indygreg Am I doing something wrong with this configuration? I find it surprising that extension modules aren't working because the docs say it does and I'm quite certain that I've done it before
I twigged that this might be related to files embedded in the pillow package (and lots of other packages) and seemed to of fixed it by
policy.allow_files = True
I ran into a new issue after passing this one (as to be expected when starting out with something this complex) but hopefully, this helps you or others.
Thanks!
I also needed policy.resources_location_fallback = "filesystem-relative:prefix"