Skip to content

Use Direnv and put back venv into ardupilot directory#32731

Open
khancyr wants to merge 3 commits into
ArduPilot:masterfrom
khancyr:direnv
Open

Use Direnv and put back venv into ardupilot directory#32731
khancyr wants to merge 3 commits into
ArduPilot:masterfrom
khancyr:direnv

Conversation

@khancyr

@khancyr khancyr commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

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)

  • [ X] Checked by a human programmer
  • Non-functional change
  • [ X] No-binary change
  • [ X] Infrastructure change (e.g. unit tests, helper scripts)
  • [ X] Automated test(s) verify changes (e.g. unit test, autotest)
  • [ X] Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Tested locally, without venv, with .venv, with /home/user/venv-ardupilot, with another shell (zsh) and on docker

@khancyr khancyr added the DevEnv label Apr 10, 2026

@yuri-rage yuri-rage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested under 24.04 - nice work!

Comment thread wscript
Comment on lines +479 to +488

# 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.'
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the value in this and see lots of potential annoyance. Please remove it.

@cclauss cclauss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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' ] ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This month, Plucky will probably disappear from https://ports.ubuntu.com/ubuntu-ports/dists

@Hwurzburg Hwurzburg requested a review from peterbarker April 13, 2026 11:34
@cclauss

cclauss commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Will need a rebase now that #32754 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants