New submission from Jon Nabozny: I would like to see some enhancement where the activate.bat and activate scripts allow the script to determine where the python executable resides.
When the executable cannot be found (because the path doesn't exist for some reason), the system will ultimately find the installed version of python. This can cause side effects that may be non-obvious to users. Example: User creates a virtual environment: python -m venv C:\Location\To\Project venv User manually changes location of project: xcopy /E C:\Location\To\Project C:\New\Project\Location User runs activate.bat: (venv) C:\New\Project\Location At this point, the user will get the modified prompt, but will actually be using his/her globally installed python. Therefore, running anything like pip will taint their install. Further, if they had set up the environment previously, it can cause errors because modules won't be found (because it's pointing at the wrong Lib\site-packages folder). Code: activate.bat ;Replace set "VIRTUAL_ENV=__VENV_DIR__" set "VIRTUAL_ENV=%~dp0..\" activate FILE=$(readlink -f "$0") FILE_DIR=$(dirname "$FILE") # Replace VIRTUAL_ENV="__VENV_DIR__" VIRTUAL_ENV="$FILE_DIR/../" Somewhat related, I've also found that's it's incredibly convenient to also include activate and deactivate files at the root of the venv: python -m venv C:\project venv # Now, C:\project looks like this: .\venv .\activate.bat .\deactivate.bat # activate and deactivate are very simple: ;activate.bat @ECHO OFF pushd env\Scripts call activate popd ;deactivate.bat @ECHO OFF pushd env\Scripts call deactivate popd ---------- components: Demos and Tools messages: 266583 nosy: widmo priority: normal severity: normal status: open title: Make VENV_DIR relative to Script directory type: enhancement versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27148> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com