Skip to content

Don't exclude setuptools, distribute & wheel from freeze output on Python 3.12+ - #12032

Merged
pradyunsg merged 3 commits into
pypa:mainfrom
SpecLad:freeze-setuptools
Jul 7, 2023
Merged

Don't exclude setuptools, distribute & wheel from freeze output on Python 3.12+#12032
pradyunsg merged 3 commits into
pypa:mainfrom
SpecLad:freeze-setuptools

Conversation

@SpecLad

@SpecLad SpecLad commented May 15, 2023

Copy link
Copy Markdown
Contributor

Due to the advent of build isolation, it is no longer necessary to install setuptools and wheel in an environment just to install other packages. Moreover, on Python 3.12 both ensurepip (python/cpython#95299) and virtualenv (pypa/virtualenv#2558) are to stop installing setuptools & wheel by default. This means that when those packages are present in a Python 3.12+ environment, it is reasonable to assume that they are runtime dependencies of the user's project, and therefore should be included in freeze output.

distribute is just obsolete.

Closes #4256.

Comment thread noxfile.py Outdated
Comment thread tests/functional/test_freeze.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This also doesn't seem directly related to this PR. It's a sensible addition, but why is it included here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just making sure that pip is still hidden by default.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A comment mentioning pip should hide itself from freeze would be useful

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doesn't the test docstring say exactly that?

Comment thread tests/functional/test_freeze.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we do this test by mocking the value of sys.version_info, rather than having the test do different things depending on what Python version it's run under? That may be overkill, and may be difficult to achieve because the test runs pip in a subprocess, so I'm not suggesting that this is essential, but it's worth thinking about (especially as CI currently won't check this change at all).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Seems like overkill, frankly. 3.12 will be added to CI sooner or later anyway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 to mocking, doing conditional here makes running tests locally unnecessarily difficult.

@SpecLad SpecLad May 18, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I gave it more thought, and mocking sys.version_info really does not seem like a good idea. Imagine that pip (or one of its dependencies) does something like this in the code:

if sys.version_info >= (3, 12):
    # use feature that is only available in 3.12+

Then if you set sys.version_info to 3.12.x while running on, say, 3.8.x, then this code will break.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or two tests with different skip_if decorators?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of mocking sys.version_info directly, I’d add a function that toggles freeze output, and mock that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Instead of mocking sys.version_info directly, I’d add a function that toggles freeze output, and mock that.

Okay, I did it.

@SpecLad
SpecLad force-pushed the freeze-setuptools branch from 6e263eb to 28217cc Compare May 15, 2023 22:12
@SpecLad
SpecLad force-pushed the freeze-setuptools branch from 28217cc to 7b6a81b Compare May 28, 2023 22:30
Comment thread news/4256.removal.rst Outdated
SpecLad added 2 commits July 7, 2023 01:46
…thon 3.12+

Due to the advent of build isolation, it is no longer necessary to install
setuptools and wheel in an environment just to install other packages.
Moreover, on Python 3.12 both ensurepip [1] and virtualenv [2] are to stop
installing setuptools & wheel by default. This means that when those packages
are present in a Python 3.12+ environment, it is reasonable to assume that
they are runtime dependencies of the user's project, and therefore should be
included in freeze output.

distribute is just obsolete.

[1] python/cpython#95299
[2] pypa/virtualenv#2558
This makes it possible to test both branches on any Python version.
@SpecLad
SpecLad force-pushed the freeze-setuptools branch from 9610d5b to 393ccfb Compare July 6, 2023 22:46
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
Comment on lines -64 to +75
" {}".format(", ".join(DEV_PKGS))
" {}".format(", ".join(_dev_pkgs()))

@uranusjr uranusjr Jul 7, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a minor note, it’d be a good idea to add some sorting here so the order package appear is more stable. But honestly nobody cares that much about these help messages anyway so it’s fine to keep things as-is.

@pradyunsg
pradyunsg merged commit 177cf88 into pypa:main Jul 7, 2023
@SpecLad
SpecLad deleted the freeze-setuptools branch July 8, 2023 12:49
@atugushev

Copy link
Copy Markdown
Contributor

@pradyunsg will this be released in 23.2 or sooner?

@pfmoore

pfmoore commented Jul 9, 2023

Copy link
Copy Markdown
Member

It's been merged, so it will be in 23.2.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revisit displaying setuptools in pip freeze?

6 participants