-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poetry can't run scripts from dependencies (which themselves use poetry) installed as editable on Windows #3265
Comments
Hello @kevincon, thanks a lot for reporting and your detailed investigation 👍 Do you think, you can provide a PR to fix it? :) fin swimmer |
Hey, I would like to work on this. Can I get assigned? Thanks. |
Ah sorry @avirlrma I forgot to call it out, but I have fixed this in a branch and I think I can put up a PR for it tomorrow. Do you mind if I finish it up? |
Yes sure, please go ahead. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).Issue
My team is experiencing that
poetry run
is unable to run scripts registered with poetry by editable-installed dependencies of our main poetry project on Windows.I've created this repo to provide a minimal project to demonstrate this issue: https://github.com/kevincon/poetry_editable_dep_script_bug_repro
Also I'm using Python 3.8.3 32-bit.
In that repo, the main project,
parent
, has a local, editable path dependency ofchild
which is itself a Poetry project.Both the
parent
project and thechild
project register a script using thetool.poetry.scripts
section in their respectivepyproject.toml
files. All these scripts do is print outHello from parent CLI!
orHello from child CLI!
, respectively.Installing the
parent
project is successful:As is running the
parent
project's script:But trying to run the
child
project's script fails with this error (with 100% reproducibility):(we would expect it to not throw an error and instead print out
Hello from child CLI!
)However, we can successfully run both the
parent
andchild
project scripts if we use poetry version 1.0.10.I think what changed to break this behavior between 1.0.10 and 1.1.x is #2360, which seems to have changed how scripts of editable projects are installed. Previously a
.exe
file was created for scripts registered with poetry in theScripts/
directory of the poetry-managed virtual environment (I think by pip?), but now a.cmd
file is created by poetry for these scripts instead.I think I understand that the
parent
project's script is run successfully in poetry 1.1.3 becausepoetry
finds it in theparent
project'spyproject.toml
file and takes this code path:poetry/poetry/console/commands/run.py
Lines 27 to 28 in 68d6939
But since the
child
project's script won't be found in theparent
project'spyproject.toml
file, it takes a different code path for thechild
script which ultimately tries to usesubprocess.Popen()
to call thechild
script:poetry/poetry/utils/env.py
Line 977 in 68d6939
Unfortunately it looks like the
subprocess.Popen
call which poetry uses to try to run thechild
script ends up calling_winapi.CreateProcess()
(as shown in the error output above) which I learned does not auto-resolve any other executable extensions besides.exe
, so it doesn't find the.cmd
executable for thechild
script. See https://stackoverflow.com/a/10555130 and https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa?redirectedfrom=MSDN#parameters.This seems to be supported by the fact that we are able to run the
child
project's script using poetry 1.1.3 if we add the.cmd
extension ourselves:The text was updated successfully, but these errors were encountered: