emacs-pet
emacs-pet copied to clipboard
Virtualenv is not detected when it is directly in the root directory
Description
I normally create my virtualenvs with python3 -m venv .
, this places the bin/
and lib/
directly inside the project root. Handy, as you now have bin/pip
and don't have to do venv/bin/pip
.
PET doesn't detect this. It looks for venv/
or .venv/
in the project root. Granted, those directories are recommended in the python documentation, but I think I see the .
-method quite a lot. At least in the projects inside my company :-)
Reproduction steps
- Emacs with PET and projectile and so.
- Some dir where you've done
git init
to make it recognizable for projectile. -
python3 -m venv .
-
touch some_script.py
- Start emacs, open
some_script.py
- Check
pet-verify-setup
,python-shell-interpreter
will be your system python, not thebin/python
inside the project dir.
Expected behavior
I expected python-shell-interpreter
to be the bin/python
inside the project dir.
After reading the PET lisp code, I discovered that PET looks for venv/env/.env. Creating the virtualenv with python3 -m venv venv
made everything work like a charm.
Versions
PET 20230906.46
, emacs 29.1
on osx (but those details won't matter I guess)
Possible solutions
I think it is perfectly OK to require the virtualenv to be in venv/env/.venv. The detection mechanism might be hard to get right otherwise, I fear. If that is indeed the case, an short addition to the README (noting that the virtualenv has to be in venv/env/.venv) might be handy.
Does adding "." to this defcustom solve your problem?
I'm closing this as solved as there's a defcustom for many months.