pyjuliapkg icon indicating copy to clipboard operation
pyjuliapkg copied to clipboard

First try at accommodating "modern" editable python packages

Open dingraha opened this issue 9 months ago • 0 comments

The pyjuliapkg docs explain that the package will search for juliapkg.json files in the following locations:

  • {project}/pyjuliapkg where project is as above (depending on your environment).
  • Every directory and direct sub-directory in sys.path.

Unfortunately, when a Python package is installed in --editable mode, it appears that its source location is not, sometimes, added to sys.path. (The source location does appear to be added to sys.path if the --config-settings editable_mode=compat option is used with pip, but that option is deprecated: https://setuptools.pypa.io/en/latest/userguide/development_mode.html#legacy-behavior) Instead, some strange-looking files starting with an __editable__ prefix are added to site-packages, which Python somehow uses to find the editable package.

This PR looks for those __editable__ files in each entry in sys.path, and then uses the _EditableFinder thingies in sys.meta_path to find the install location of the editable Python packages, and finally uses those locations when looking for juliapkg.json files.

dingraha avatar Mar 14 '25 17:03 dingraha