Skip to content

Trim distlib to only include scripts code #13342

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ichard26
Copy link
Member

Follow up to #13337.

Distlib is our largest dependency. The vast majority of that is the Windows stub executables which we can't get rid of. However, distlib is a general purpose low-level packaging library, of which we only use the scripts module.

image

By line count, this results in a 5% reduction in the total (_internal and _vendor) LOC of pip, which translates to ~250 KB of uncompressed and 64 KB of compressed (wheel) savings.

I have a few more ways of reducing the size of our vendored dependencies, but they are more invasive changes with lower benefits. I'm only looking to propose simple tweaks that lead to a significant reduction. Broadly, I do not want to redefine our vendoring policy to say that we will or even plan to trim our dependencies. For example, the dependency groups dependency added in the --group PR has CLI functionality that we're never going to use but the code involved is so small (<100 LOC) that it isn't worth it.

Distlib is our largest dependency. The vast majority of that is the
Windows stub executables which we can't get rid of. However, distlib
is a general purpose low-level packaging library, of which we only
use the scripts module.

By line count, trimming the parts of distlib that aren't used for
scripts results in a 5% reduction in total (`_internal` and `_vendor`)
size, which translates to ~250 KB of uncompressed and 64 KB of
compressed (wheel) savings.
@ichard26 ichard26 added skip news Does not need a NEWS file entry (eg: trivial changes) project: vendored dependency Related to a vendored dependency labels Apr 20, 2025
@ichard26 ichard26 added this to the 25.2 milestone Apr 20, 2025
@ichard26
Copy link
Member Author

I chose to target pip 25.2 as we're too close to the upcoming release for comfort IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project: vendored dependency Related to a vendored dependency skip news Does not need a NEWS file entry (eg: trivial changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant