Skip to content

Conversation

dukecat0
Copy link
Member

@dukecat0 dukecat0 commented Jul 22, 2024

  • I have added a news fragment under changelog.d/ (if the patch affects the end users)

Summary of changes

Closes #1392
This allows users to choose from different backends and also speeds up the installation process.

Screenshot 2024-07-21 at 11 11 55 AM

Test plan

Tested by running

pipx install --backend uv --install uv black
pipx run --backend uv --installer uv black

Copy link
Contributor

@chrysle chrysle left a comment

Choose a reason for hiding this comment

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

Thank you very much for working on this feature! Some initial thoughts.

@dukecat0 dukecat0 marked this pull request as ready for review July 23, 2024 06:56
@dukecat0 dukecat0 marked this pull request as draft July 23, 2024 06:59
@dukecat0 dukecat0 changed the title [WIP] Support different backends Support different backends Aug 24, 2024
@dukecat0 dukecat0 marked this pull request as ready for review August 24, 2024 13:29
@chrysle
Copy link
Contributor

chrysle commented Sep 8, 2024

Per #1539 (comment), we should consider adding the --no-seed option to the virtualenv (not sure concerning the uv mechanism) backend invocation.

@dukecat0
Copy link
Member Author

dukecat0 commented Sep 8, 2024

It seems like uv doesn't have this issue since it doesn't carry extra seed packages by default:

activate      activate.fish  activate_this.py  python
activate.bat  activate.nu    deactivate.bat    python3
activate.csh  activate.ps1   pydoc.bat	       python3.9

Comment on lines +202 to 204
shared_libs.create(verbose=self.verbose, pip_args=pip_args)
if not override_shared and (self.backend != "uv" or self.installer != "uv"):
pipx_pth = get_site_packages(self.python_path) / PIPX_SHARED_PTH
Copy link
Member

Choose a reason for hiding this comment

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

Should the shared environment still be injected/exist after this or should it only be used (and thus maybe renamed) as the environment holding pip and allowing "{shared_libs.python_path}" -m pip --python "{self.python_path}" being used as an installer (rather than "{self.python_path}" -m pip in _run_pip)

Copy link
Member Author

Choose a reason for hiding this comment

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

Using --python option sounds reasonable, but would there be any scenarios where users would prefer to keep the .pth file?

Copy link
Member

Choose a reason for hiding this comment

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

The only thing that comes to mind would be if they were directly running python in an app venv to run pip instead of using pipx runpip.

@dukecat0 dukecat0 requested a review from Gitznik September 27, 2024 12:06
@dukecat0 dukecat0 requested a review from Copilot March 29, 2025 09:05
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for different virtual environment backends and installers, allowing users to choose between uv, venv, and virtualenv for the backend and between uv and pip for installation. Key changes include updated tests for backend/installer functionality, modifications to venv creation and inspection to store backend/installer data, and enhanced CLI argument parsing to accept these new options.

Reviewed Changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/* Added tests for custom backend and installer behavior
tests/conftest.py Cleared environment variables for backend and installer
src/pipx/venv_inspect.py Extended metadata signature to include backend and installer
src/pipx/venv.py Updated Venv constructor and methods to support backend/installer logic
src/pipx/util.py Renamed pip error handler to installer error handler
src/pipx/pipx_metadata_file.py Extended metadata version and included backend/installer fields
src/pipx/main.py Updated CLI options to pass backend and installer
src/pipx/commands/* Updated commands (install, upgrade, run, reinstall, interpreter) to pass backend/installer
src/pipx/backend.py Introduced DEFAULT_BACKEND, DEFAULT_INSTALLER and supported values
noxfile.py Added uv and virtualenv as test dependencies
mkdocs.yml, docs/* Updated documentation to include backend usage and examples
changelog.d/1392.feature.md Added changelog entry for supporting different backends/installers
Files not reviewed (1)
  • testdata/pipx_metadata_multiple_errors.json: Language not supported

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.

Support different backends for pipx?
5 participants