Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow skipping maintenance tasks for list command #1163

Merged
merged 6 commits into from Jan 4, 2024

Conversation

Gitznik
Copy link
Contributor

@Gitznik Gitznik commented Dec 22, 2023

  • I have added an entry to docs/changelog.md

Summary of changes

Add a --skip-maintenance flag to the list command. This sets a new state on the _SharedLibs class, that is used to skip the shared libs upgrade step by setting needs_upgrade to False. This change allows the user to skip the functionality that reaches out to pip, which makes executing the command a lot faster when offline.
resolves #1081

Test plan

Introduced a new test case test_skip_maintenance. It first adds some packages to introduce shared libs. It then verifies that a normal list command sets the expected state on the shared_libs object. Then it verifies that running list with --skip-maintenance results in state on the shared_libs object that indicates that no upgrade was performed.

Tested by running nox -s tests-3.12

pipx list --skip-maintenance

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.

Concerning the test, probably really collect the times after running the CLI, and compare the durations.

src/pipx/commands/list_packages.py Outdated Show resolved Hide resolved
@Gitznik
Copy link
Contributor Author

Gitznik commented Dec 23, 2023

Concerning the test, probably really collect the times after running the CLI, and compare the durations.

I did this manually:
python3 src/pipx list --skip-maintenance 0.42s user 0.14s system 87% cpu 0.638 total
vs with maintenance
python3 src/pipx list 0.72s user 0.21s system 10% cpu 8.623 total
when running offline and being in a state that would require an upgrade.

Do you have a suggestion on how to automate this with a test? My only suggestion would be to modify pipx_temp_env to allow creating an unresponsive local pypi server, but that feels like a lot of custom logic for one test.

@Gitznik Gitznik requested a review from chrysle December 23, 2023 16:37
uranusjr
uranusjr previously approved these changes Dec 25, 2023
Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

@gaborbernat gaborbernat enabled auto-merge (squash) December 28, 2023 00:39
Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

Needs merge conflicts fixed and rebased.

auto-merge was automatically disabled December 29, 2023 15:42

Head branch was pushed to by a user without write access

@Gitznik
Copy link
Contributor Author

Gitznik commented Dec 29, 2023

Needs merge conflicts fixed and rebased.

Done

dukecat0
dukecat0 previously approved these changes Dec 30, 2023
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.

Option for the list command not to go out to the internet
5 participants