Plugins cannot respond to `TERMINATE` event on non-Windows systems after `poetry run`
mtkennerly opened this issue · comments
- Poetry version: 1.5.1
- Python version: 3.10.7
- OS version and name: Windows 11
- pyproject.toml: Any
- I am on the latest stable Poetry version, installed using a recommended method.
- I have searched the issues of this repo and believe that this is not a duplicate.
- I have consulted the FAQ and blog for any relevant entries or release notes.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option) and have included the output below.
Issue
On non-Windows systems, poetry run
uses os.execvpe
:
poetry/src/poetry/utils/env/generic_env.py
Lines 90 to 91 in 6e94298
Because of how this function replaces the current process, a plugin cannot respond to the TERMINATE
event. atexit
hooks are also not called.
Could subprocess.Popen
simply be used for all systems instead of Windows only?
My use case is that my plugin makes some temporary modifications to set the version number, and it needs to revert them when the command is done. Right now, I just have the plugin ignore poetry run
and poetry shell
since it can't clean up after them.
This may be related, or may need it's own issue (maybe in the poetry-dynamic-versioning repo)...
I have a case where I have an internal library to a script that we have installed as a submodule, then refer to it in the dependency section of pyproject.toml using direct path reference:
That library is also a Poetry Python project, and both use poetry-dynamic-versioning to update the version.
- When Poetry installs the submodule it builds it and the build ends up with the correct version (1.0.1), but when running
poetry install
it finds the '0.0.0' version, I assume from pyproject directly, and decides it needs to downgrade from 1.0.1 to 0.0.0. - It also reports the parent project as version 0.0.0
Ideally Poetry would trigger the plugin and somehow get the correct VCS-inspired version rather than the 0.0.0 text in pyproject.toml.
Note
- The parent project in the .venv/Lib/site-packages shows up as version 0.0.0 (despite git version being 0.0.1)
- The library/submodule version is actually installed as 1.0.1 in site-packages, rather than the 0.0.0 reported by the
poetry install
command.
I'm working on a small plugin that needs to do some cleanup after a poetry run
, it would be nice if this could get fixed
@LightCC I think that would be a separate issue. It also came up in the poetry-dynamic-versioning repo here: mtkennerly/poetry-dynamic-versioning#154 (comment) . I think you're right that Poetry is showing the static version from pyproject.toml before it's far enough along in the process to trigger the plugin.