emacs-pet icon indicating copy to clipboard operation
emacs-pet copied to clipboard

Virtualenv is not detected when it is directly in the root directory

Open reinout opened this issue 1 year ago • 1 comments

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 the bin/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.

reinout avatar Dec 05 '23 21:12 reinout

Does adding "." to this defcustom solve your problem?

wyuenho avatar Apr 20 '24 15:04 wyuenho

I'm closing this as solved as there's a defcustom for many months.

wyuenho avatar Jun 01 '24 22:06 wyuenho