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

pip install git+... from a branch/tag could be faster #13060

Open
1 task done
fandreuz opened this issue Oct 30, 2024 · 6 comments
Open
1 task done

pip install git+... from a branch/tag could be faster #13060

fandreuz opened this issue Oct 30, 2024 · 6 comments
Labels
C: vcs pip's interaction with version control systems like git, svn and bzr type: enhancement Improvements to functionality type: performance Commands take too long to run

Comments

@fandreuz
Copy link

fandreuz commented Oct 30, 2024

What's the problem this feature will solve?

pip install git+...@foo-branch clones the whole repository and then checks out foo-branch. This process takes some time if the repository has a long history or many branches.

Describe the solution you'd like

I'd like to leverage git clone parameters to make the whole thing faster when a specific branch is requested. In particular, I'd use `the following:

  • --branch foo-branch
  • --depth 1

Alternative Solutions

The current solution works fine, but is slow in some specific situations.

Additional context

https://git-scm.com/docs/git-clone

Code of Conduct

@fandreuz fandreuz added S: needs triage Issues/PRs that need to be triaged type: feature request Request for a new feature labels Oct 30, 2024
@fandreuz
Copy link
Author

I can take this if this improvement is approved, I've spotted where the changes should go

@notatallshaw
Copy link
Member

notatallshaw commented Oct 30, 2024

Thanks for reporting, but check this comment: #12949 (comment)

we actually tried this before and had to revert due to packages relying on SCM metadata to build

Also, other previous discussions:

@notatallshaw notatallshaw closed this as not planned Won't fix, can't repro, duplicate, stale Oct 30, 2024
@ichard26 ichard26 added type: enhancement Improvements to functionality C: vcs pip's interaction with version control systems like git, svn and bzr type: performance Commands take too long to run and removed type: feature request Request for a new feature S: needs triage Issues/PRs that need to be triaged labels Oct 30, 2024
@ichard26
Copy link
Member

It's also not true that pip always clones the entire repository. Since pip 21.3, pip performs blobless clones where possible (aka git >= 2.17) to speed up clones without breaking projects which rely on git history in their build process.

# Git added support for partial clone in 2.17
# https://git-scm.com/docs/partial-clone
# Speeds up cloning by functioning without a complete copy of repository
self.run_command(
make_command(
"clone",
"--filter=blob:none",

Perhaps the --single-branch flag could be added when a specific branch is required, but that'd require additional investigation. It's not immediately clear how pip would know how to determine whether a specified revision is a branch (and not a tag or commit SHA).

@notatallshaw
Copy link
Member

pip performs blobless clones where possible (aka git >= 2.17) to speed up clones without breaking projects which rely on git history in their build process

And even that optimization broke some people's build process: #10652

@fandreuz
Copy link
Author

Thanks @notatallshaw, indeed I did not consider those kinds of builds. I guess some flag to enable "unsafe" optimizations is out of the question, right?

Perhaps the --single-branch flag could be added when a specific branch is required, but that'd require additional investigation.

We could query the repository for the existence of a branch with the given name. However, this would not solve the which compelled me to open the issue, which is more about the history than the number of branches.

@notatallshaw
Copy link
Member

notatallshaw commented Oct 31, 2024

I guess some flag to enable "unsafe" optimizations is out of the question, right?

I don't think it's "out of the question", but I do think it's a question of complexity vs. benefit, if it's not the default behavior of pip it doesn't add significant benefit, so the complexity should be very low.

I'll reopen this ticket with it being the idea of adding a "non-default" optimization, but I don't know how much traction it will get with pip maintainers.

@notatallshaw notatallshaw reopened this Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: vcs pip's interaction with version control systems like git, svn and bzr type: enhancement Improvements to functionality type: performance Commands take too long to run
Projects
None yet
Development

No branches or pull requests

3 participants