Skip to content

feat: use built-in venv, prevent silent failures, avoid pip compatibility issues, and ensure cleanup even if deactivate fails#5357

Open
immanuwell wants to merge 2 commits into
canonical:masterfrom
immanuwell:feature/build-linux-improvement
Open

feat: use built-in venv, prevent silent failures, avoid pip compatibility issues, and ensure cleanup even if deactivate fails#5357
immanuwell wants to merge 2 commits into
canonical:masterfrom
immanuwell:feature/build-linux-improvement

Conversation

@immanuwell

Copy link
Copy Markdown

Summary

Improvements in script installer/build-linux.sh

Changes

Changes in installer/build-linux.sh:

  • ensure exit on errors, undefined variables, and pipe failures
  • use the built-in venv module, removing an external dependency (virtualenv)
  • ensure you're using a recent pip version, avoiding potential compatibility issues
  • suppresses errors if deactivate fails (which can happen in non-interactive shells)

Testing

I carefully tested this new version of installer/build-linux.sh a few times

Checklist

  • Read the contributions page.
  • Submitted the CLA form, if you are a first time contributor.
  • The introduced changes are covered by unit and/or integration tests.

@ktsakalozos fyi

…lity issues, and ensure cleanup even if deactivate fails

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 virtualenv to python3 -m venv for venv creation.
  • Upgrade pip in the venv before installing requirements; make deactivate non-fatal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread installer/build-linux.sh
Comment on lines +3 to 6
set -euo pipefail

python3 -m venv .venv

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread installer/build-linux.sh
#!/bin/bash

set -euo pipefail

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

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

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.

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

Copilot uses AI. Check for mistakes.
Comment thread installer/build-linux.sh Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants