hatch icon indicating copy to clipboard operation
hatch copied to clipboard

bug: Custom plugin `path` can't be a symlink

Open johnpyp opened this issue 1 year ago • 2 comments

Currently, the custom plugins that allow for easy local plugin usage check to make sure that the plugin file is a real file, excluding symlinks, e.g here: https://github.com/pypa/hatch/blob/master/src/hatch/env/collectors/custom.py#L31

Seems like an easy fix, though I don't know if there would be any other negative effects from allowing symlinks here without other handling.


To replicate, symlink some plugin (e.g an environment collector plugin) to some other path (e.g my_plugin.py), and set the path:

[tool.hatch.env.collectors.custom]
path = "./my_plugin.py"

This will fail with "Plugin script does not exist", as expected given the file-checking logic currently.

johnpyp avatar May 09 '24 19:05 johnpyp

Thanks! We wouldn't be able to do this for custom build plugins because those get packaged into the source distribution and then when building from that weird stuff might happen but this seems relatively innocuous.

Should that be changed to just exists? My intention is to also make sure that it is not a directory if it exists.

ofek avatar May 09 '24 19:05 ofek

Yep! Sounds reasonable to me. Makes sense on the build plugin side.

johnpyp avatar May 10 '24 03:05 johnpyp