Use Direnv and put back venv into ardupilot directory#32731
Conversation
yuri-rage
left a comment
There was a problem hiding this comment.
Tested under 24.04 - nice work!
|
|
||
| # Check if running inside the deprecated ~/venv-ardupilot venv | ||
| deprecated_venv = os.path.join(os.path.expanduser('~'), 'venv-ardupilot') | ||
| if sys.executable.startswith(os.path.realpath(deprecated_venv)): | ||
| cfg.fatal( | ||
| f'You are using the deprecated venv at {deprecated_venv}. ' | ||
| 'Please re-run Tools/environment_install/install-prereqs-ubuntu.sh ' | ||
| 'to update your environment to use the new .venv in the repository root.' | ||
| ) | ||
|
|
There was a problem hiding this comment.
I don't see the value in this and see lots of potential annoyance. Please remove it.
There was a problem hiding this comment.
$APT_GET install python3-venv should work for all these distros (Jammy included).
Why are we trying to reuse venvs? The docs clearly say in big red text that venvs are not portable. They should not be moved to a new location or checked into GitHub. Just create new ones.
Activating a venv automatically deactivates any previously activated venvs.
| # instead of auto-loading in the shell login file. | ||
| USE_DIRENV=false | ||
| if [ ${RELEASE_CODENAME} == 'bookworm' ]; then | ||
| PYTHON_VENV_PACKAGE=python3.11-venv |
There was a problem hiding this comment.
| PYTHON_VENV_PACKAGE=python3.11-venv | |
| PYTHON_VENV_PACKAGE=python3-venv |
Proof:
% docker run -it debian:bookworm
# apt update && \
DEBIAN_FRONTEND=noninteractive apt install --yes lsb-release python3-venv && \
lsb_release -ds && \
python3 -m venv --upgrade-deps .venv && \
source .venv/bin/activate &&
python -V && \
pip -V
Debian GNU/Linux 12 (bookworm)
Python 3.11.2
pip 26.0.1 from /.venv/lib/python3.11/site-packages/pip (python 3.11)
| PYTHON_VENV_PACKAGE=python3.11-venv | ||
| USE_DIRENV=true | ||
| elif [ ${RELEASE_CODENAME} == 'noble' ]; then | ||
| PYTHON_VENV_PACKAGE=python3.12-venv |
There was a problem hiding this comment.
| PYTHON_VENV_PACKAGE=python3.12-venv | |
| PYTHON_VENV_PACKAGE=python3-venv |
Proof:
% docker run -it ubuntu:noble
# apt update && \
DEBIAN_FRONTEND=noninteractive apt install --yes lsb-release python3-venv && \
lsb_release -ds && \
python3 -m venv --upgrade-deps .venv && \
source .venv/bin/activate &&
python -V && \
pip -V
Ubuntu 24.04.4 LTS
Python 3.12.3
pip 26.0.1 from /.venv/lib/python3.12/site-packages/pip (python 3.12)
| PYTHON_VENV_PACKAGE=python3.12-venv | ||
| USE_DIRENV=true | ||
| elif [ ${RELEASE_CODENAME} == 'trixie' ] || | ||
| [ ${RELEASE_CODENAME} == 'plucky' ] || |
There was a problem hiding this comment.
This month, Plucky will probably disappear from https://ports.ubuntu.com/ubuntu-ports/dists
|
Will need a rebase now that #32754 is merged. |
Summary
we are currently make a venv into home space and load it as a global environement. This cause a lot of issue for developpers that want to use some other venv or Tools as we are overriding everything.
This PR put back the things properly into ardupilot directory.
Drawback is that people won't have global scope ardupilot tools anymore unless they enable the venv manually
This also install direnv that is an utility to autoload and unload venv when entering into ardupilot directory. That would make thing easier and transparent for most developper and allow those that don't want it to not use it and manage their venv as they want.
A blocking text is added to waf to ask people to move out from the old installation
Classification & Testing (check all that apply and add your own)
Tested locally, without venv, with .venv, with /home/user/venv-ardupilot, with another shell (zsh) and on docker