indygreg / PyOxidizer

A modern Python application packaging and distribution tool
Mozilla Public License 2.0
5.31k stars 227 forks source link

Add support for egg-link's #440

Open m00sey opened 2 years ago

m00sey commented 2 years ago

Expected result: Installing a dependency in a PyOxidizer project with pip install -e should load the resources correctly.

Actual result: "Module not found" error.

Config: https://github.com/WebOfTrust/keep/blob/main/ward/pyoxidizer.bzl


I am working on two projects in active development. A library, and a another application that will consume a 'PyOxidized' version of the the former.

I'm using the read_virtualenv resource loader.

Quite often we do not have a up to date published version of the library so we pip install -e /path/to/library in the 'PyOxidized' project. This generates a .egg-link file in the venv under /path/to/project/venv/lib/python3.9/site-packages/keri.egg-link which has the following format:

/path/to/library/src
../

If these all sounds "reasonable" the place to start seems to be read_virtualenv (I don't know under what other circumstances these "symlinks" are produced) and go from there?

My intention is to try fix it, but wanted to raise an issue in case I am doing something wrong, or not using PyOxidizer correctly.

indygreg commented 2 years ago

The existing resource scanning code doesn't support .egg-link files. It could and probably should be taught to do so.

I'll note that reading a pre-populated virtualenv is rather fragile, as there can be a disconnect between the Python used to populate the virtualenv and the Python that PyOxidizer uses. This can result in wonky behavior at run-time, including crashes. That's why the docs recommend using pip_download() or pip_install() for collecting Python resources.