You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if anyone had succeeded in packaging a Python module with a PyTorch dependency, and if so, if you could share the bzl file? I am trying the below, but it fails with an error:
def make_exe():
dist = default_python_distribution()
policy = dist.make_python_packaging_policy()
python_config = dist.make_python_interpreter_config()
exe = dist.to_python_executable(
name="pyox_test",
# If no argument passed, the default `PythonPackagingPolicy` for the
# distribution is used.
packaging_policy=policy,
# If no argument passed, the default `PythonInterpreterConfig` is used.
config=python_config,
)
# Install PyTorch and dependencies using pip
for resource in exe.pip_install([
"torch",
"numpy",
]):
# PyTorch is a native extension, it must be on the filesystem
resource.add_location = "filesystem-relative:lib"
exe.add_python_resource(resource)
# Read Python files from a local directory and add them to our embedded
# context, taking just the resources belonging to the `foo` and `bar`
# Python packages.
exe.add_python_resources(exe.read_package_root(
path="./",
packages=["main"],
))
return exe
def make_embedded_resources(exe):
return exe.to_embedded_resources()
def make_install(exe):
# Create an object that represents our installed application file layout.
files = FileManifest()
# Add the generated executable to our install layout in the root directory.
files.add_python_resource(".", exe)
return files
# Call our function to set up automatic code signers.
register_code_signers()
# Tell PyOxidizer about the build targets defined above.
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)
register_target("msi_installer", make_msi, depends=["exe"])
# Resolve whatever targets the invoker of this configuration file is requesting
# be resolved.
resolve_targets()
Error:
error[PYOXIDIZER_PYTHON_EXECUTABLE]: adding PythonPackageDistributionResource<package=MarkupSafe, name=INSTALLER>
Caused by:
0: adding PythonPackageDistributionResource<MarkupSafe, INSTALLER>
1: resource collector does not allow resources in filesystem-relative
--> ./pyoxidizer.bzl:225:9
|
225 | exe.add_python_resource(resource)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ add_python_resource
error: adding PythonPackageDistributionResource<package=MarkupSafe, name=INSTALLER>
Caused by:
0: adding PythonPackageDistributionResource<MarkupSafe, INSTALLER>
1: resource collector does not allow resources in filesystem-relative
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all,
I was wondering if anyone had succeeded in packaging a Python module with a PyTorch dependency, and if so, if you could share the
bzl
file? I am trying the below, but it fails with an error:Error:
has anyone seen this/solved this?
Beta Was this translation helpful? Give feedback.
All reactions