From 2bbe8e1f6a67d9ab1f735e5c1df165f60f9e9bff Mon Sep 17 00:00:00 2001 From: SimonBiggs Date: Fri, 24 Sep 2021 10:37:16 +1000 Subject: [PATCH] update resource callback docs --- README.md | 5 +++-- .../docs/pyoxidizer_packaging_resources.rst | 20 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5ef5b58d6..323948886 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/pyoxidizer/docs/pyoxidizer_packaging_resources.rst b/pyoxidizer/docs/pyoxidizer_packaging_resources.rst index 8224cd6e4..f99455f1c 100644 --- a/pyoxidizer/docs/pyoxidizer_packaging_resources.rst +++ b/pyoxidizer/docs/pyoxidizer_packaging_resources.rst @@ -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(