pipx icon indicating copy to clipboard operation
pipx copied to clipboard

Add PIPX_DISABLE_SHARED_LIBS_AUTO_UPGRADE environment variable to disable automatic shared library upgrades

Open G26karthik opened this issue 2 months ago • 1 comments

Summary

Fixes #1650

This PR implements the feature requested in #1650 by adding a new environment
variable PIPX_DISABLE_SHARED_LIBS_AUTO_UPGRADE that allows users to disable
automatic upgrades of shared libraries (pip, setuptools, wheel).

Motivation

Users who need to maintain compatibility with older Python versions (e.g., Python 3.8) can encounter errors when pip automatically upgrades to versions that no longer support their Python version. This environment variable provides a way to disable the automatic upgrade behavior while still allowing manual upgrades via pipx upgrade-shared.

Changes Made

  1. Added PIPX_DISABLE_SHARED_LIBS_AUTO_UPGRADE constant to src/pipx/constants.py
  2. Modified src/pipx/venv.py to check the environment variable before auto-upgrading
  3. Added documentation in docs/examples.md explaining the new feature
  4. Added test in tests/test_shared_libs.py to verify the behavior

Usage

# Linux/MacOS
export PIPX_DISABLE_SHARED_LIBS_AUTO_UPGRADE=1
pipx install <package>  # Will NOT auto-upgrade shared libraries

# Windows (PowerShell)
$env:PIPX_DISABLE_SHARED_LIBS_AUTO_UPGRADE=1
pipx install <package>  # Will NOT auto-upgrade shared libraries

G26karthik avatar Oct 07 '25 16:10 G26karthik

@Maintainers Pls Review and Approve for Tests

G26karthik avatar Oct 14 '25 10:10 G26karthik