Skip to content

gh-110548: modernize venv EnvBuilder example#144745

Open
Gh-Novel wants to merge 1 commit intopython:mainfrom
Gh-Novel:fix-issue-110548
Open

gh-110548: modernize venv EnvBuilder example#144745
Gh-Novel wants to merge 1 commit intopython:mainfrom
Gh-Novel:fix-issue-110548

Conversation

@Gh-Novel
Copy link

@Gh-Novel Gh-Novel commented Feb 12, 2026

Summary

Modernizes the venv.EnvBuilder example in Doc/library/venv.rst.

The existing example used ez_setup.py to install setuptools and get-pip.py to install pip — both approaches are long deprecated. The ez_setup.py URL in the example has been dead since 2016.

Changes

  • Replaced the deprecated ez_setup.py + get-pip.py approach with a modern pattern using subprocess.run to call pip install
  • Removed obsolete methods: install_setuptools(), install_pip(), install_script(), reader()
  • Simplified ExtendedEnvBuilder to accept a packages argument
  • Updated CLI argument parsing to use --packages instead of --setuptools/--pip
  • Retained with_pip=True in EnvBuilder.__init__() since pip is now bootstrapped via ensurepip

Testing

  • Sphinx doc build passes with zero warnings
  • Ran the example code and verified it creates a venv and installs packages correctly

📚 Documentation preview 📚: https://cpython-previews--144745.org.readthedocs.build/

… ez_setup.py

Replace the deprecated ez_setup.py-based setuptools installation example
with a modern approach using pip (which is already bootstrapped via
ensurepip since Python 3.4).

The old example relied on downloading ez_setup.py from
bootstrap.pypa.io to install setuptools, which has been deprecated
since 2014. The new example demonstrates a cleaner pattern for
extending EnvBuilder to pre-install packages using pip subprocess
calls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant