PyOxidizer icon indicating copy to clipboard operation
PyOxidizer copied to clipboard

read_package_root ignores python modules?

Open MattBlack85 opened this issue 3 years ago • 2 comments

hi!

it seems using exe.read_package_root(..) doesn't work perfectly, I have the following folder structure

/home/matt/data/repos/testastropy
|-- pyoxidizer.bzl
|-- alien/
|      |-- __init__.py
|      |__ look.py
|_ goal.py

my code for packaging lookslike the following:

def make_exe():
    dist = default_python_distribution()

    policy = dist.make_python_packaging_policy()
    policy.resources_location = "in-memory"
    policy.resources_location_fallback = "filesystem-relative:lib"
    policy.set_resource_handling_mode("files")
    policy.extension_module_filter = "all"

    python_config = dist.make_python_interpreter_config()
    python_config.module_search_paths = ["$ORIGIN/lib", "$ORIGIN"]
    python_config.run_module = "alien.look"

    exe = dist.to_python_executable(
        name="apprun",
        packaging_policy=policy,
        config=python_config,
    )

    for resource in exe.pip_download(["astropy==5.0.4", "numpy", "scipy", "photutils"]):
        resource.add_location = "filesystem-relative:lib"
        exe.add_python_resource(resource)

    main_resource = exe.read_package_root(
        path="/home/matt/data/repos/testastropy",
        packages=["alien", "goal"],
    )
    print("main resource", main_resource)
    main_resource[0].add_location = "in-memory"
    exe.add_python_resource(main_resource[0])
    print(exe.resources)

    return exe

My program fails to start, additionally the print I put around shows me an empty list, am I doing something wrong?

MattBlack85 avatar Apr 15 '22 14:04 MattBlack85

I've got exactly the same problem.

Maybe that has to do with the policy.set_resource_handling_mode("files") ?

julienfr112 avatar Jul 10 '22 19:07 julienfr112

I've got exactly the same problem.

Maybe that has to do with the policy.set_resource_handling_mode("files") ?

Yep I'm having the same issue. Setting to "classify" does include my module, but unfortunately my app doesn't run in classify mode.

fooblahblah avatar Dec 05 '23 02:12 fooblahblah