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

Update resource callback docs #449

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ Rust and people may not even know because they never see a `libpython`,
:house: The official home of the `PyOxidizer` project is
https://github.com/indygreg/PyOxidizer.

:notebook_with_decorative_cover: Documentation (generated from the `docs/` directory) is available
at https://pyoxidizer.readthedocs.io/en/latest/index.html.
:notebook_with_decorative_cover: Documentation (generated from the `docs/` and
`pyoxidizer/docs/` directories) is available at
https://pyoxidizer.readthedocs.io/en/latest/index.html.

:speech_balloon: The [pyoxidizer-users](https://groups.google.com/forum/#!forum/pyoxidizer-users)
mailing list is a forum for users to discuss all things PyOxidizer.
Expand Down
20 changes: 15 additions & 5 deletions pyoxidizer/docs/pyoxidizer_packaging_resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,26 @@ else to memory:
.. code-block:: python

def resource_callback(policy, resource):
if type(resource) in ("PythonModuleSource", "PythonPackageResource", "PythonPackageDistributionResource"):
if resource.package == "my_package":
resource.add_location = "filesystem-relative:lib"
else:
resource.add_location = "in-memory"
package_name = "my_package"

if (
type(resource) in ("PythonPackageResource", "PythonPackageDistributionResource")
and resource.package == package_name
):
resource.add_location = "filesystem-relative:lib"
return

if type(resource) in ("PythonModuleSource") and resource.name == package_name:
resource.add_location = "filesystem-relative:lib"
return

resource.add_location = "in-memory"

def make_exe():
dist = default_python_distribution()

policy = dist.make_python_packaging_policy()
policy.resources_location_fallback = "filesystem-relative:lib"
policy.register_resource_callback(resource_callback)

exe = dist.to_python_executable(
Expand Down