feat: use built-in venv, prevent silent failures, avoid pip compatibility issues, and ensure cleanup even if deactivate fails#5357
Conversation
…lity issues, and ensure cleanup even if deactivate fails
There was a problem hiding this comment.
Pull request overview
Updates the Linux installer build script to create and use a Python virtual environment via the standard library, enforce stricter shell error handling, and reduce failure modes around environment teardown.
Changes:
- Enable strict bash error handling (
set -euo pipefail). - Switch from
virtualenvtopython3 -m venvfor venv creation. - Upgrade pip in the venv before installing requirements; make
deactivatenon-fatal.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| set -euo pipefail | ||
|
|
||
| python3 -m venv .venv | ||
|
|
There was a problem hiding this comment.
With set -euo pipefail, any failure in venv creation / dependency install / pyinstaller will exit the script before the teardown lines run, leaving .venv behind. If the intent is to always clean up, add an EXIT/ERR trap that performs deactivate (if defined) and rm -rf .venv, while still propagating the original failure status.
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
There was a problem hiding this comment.
Switching from virtualenv to python3 -m venv can fail on Debian/Ubuntu images that don’t have the python3-venv (and/or ensurepip) components installed, which would break the build at this step. Consider adding an explicit preflight check with a clear error message (e.g., instructing to install python3-venv) so failures are actionable.
| # Preflight check: ensure that the Python venv module is available. | |
| if ! python3 -m venv --help >/dev/null 2>&1; then | |
| echo "Error: Python 'venv' module is not available for python3." >&2 | |
| echo "On Debian/Ubuntu, install it with: sudo apt-get install python3-venv" >&2 | |
| exit 1 | |
| fi |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Improvements in script installer/build-linux.sh
Changes
Changes in installer/build-linux.sh:
Testing
I carefully tested this new version of installer/build-linux.sh a few times
Checklist
@ktsakalozos fyi