Closed janoc closed 1 year ago
It should work properly now, I'll tag a new release after your confirmation.
Great, I will give it a test in the morning on my work machine and report back.
I have just tested it with both pipenv and poetry and both work fine! Thanks for the quick fix, really appreciated!
Description Pipenv virtualenv detection does not work right, even though the
Pipfile
andpipenv
itself are found just fine.Reproduction steps
arbitrary-config-file-path branch
forpet
Pipfile
isn't placed in the project root but in a subdirectory and a Python source file is in a subfolder below thePipfile
.pet-mode
(pet-virtualenv-root)
points to the wrong place,(pet-use-pipenv-p)
returns path topipenv
,(pet-pipfile)
returns content of thePipfile
Expected behavior Correct virtualenv is choosen.
PET version
arbitrary-config-file-path branch
, 21c2933Emacs version
29.1, self-built
Desktop (please complete the following information):
System tools versions
pre-commit
Additional context It seems the problem stems from this bit of code in
pet-virtualenv-root
:This will try to execute
pipenv --venv
from whichever directory Emacs is in when visiting the python file but that does not work! One has to startpipenv
from the directory where thePipfile
is located, otherwise it just fails, or, worse, in some cases generates a newPipfile
in the current folder (not for the--venv
command, though).This is different from
poetry
-poetry
will return the correct virtual env even when started from a folder below thepyproject.toml
where the visited source file is. Pipenv will not.Generally speaking, I think it would be safest to execute these tools from the folder where their corresponding config file is, even if it is not required e.g. for
poetry
(no idea aboutpdm
orpipx
, I don't use them).BTW, this is broken also on the main branch, if one uses a project that has source files in a subfolder and not right next to the
Pipfile
.