Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use static notation for setuptools in installation test
The `VirtualEnvironment` test helper is used in multiple places,
but it is only told to install/upgrade `pip` when used from
`test_installation`. It implements the functionality it would
ideally obtain by `upgrade_deps`, since the `upgrade_deps`
parameter is only avaiilable in `venv` when using Python 3.9 and
later.

When `pip` is installed, `upgrade_deps` would install `setuptools`
when using Python 3.11 or lower, but not when using Python 3.12 or
higher. `VirtualEnvironment` does the same. (The reason for this is
not just to avoid needlessly departing from what `upgrade_deps`
would do. Rather, it should not generally be necessary to have
`setuptools` installed for package management since Python 3.12,
and if it were necessary then this would a bug we would want to
detect while running tests.)

Previously this conditional specification of `setuptools` was done
by building different lists of package arguments to pass to `pip`,
by checking `sys.version_info` to decide whether to append the
string `setuptools`.

This commit changes how it is done, to use a static list of package
arguments instead. (The Python intepreter path continues to be
obtained dynamically, but all its positional arguments, including
those specifying packages, are now string literals.) The
conditional `setuptools` requirement is now expressed statically
using notation recognized by `pip`, as the string
`setuptools; python_version<"3.12"`.
  • Loading branch information
EliahKagan committed Jun 7, 2025
commit 31e1c035e1af514d5d2a9ed6630f71663df7b265
12 changes: 9 additions & 3 deletions test/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,15 @@ def __init__(self, env_dir, *, with_pip):

if with_pip:
# The upgrade_deps parameter to venv.create is 3.9+ only, so do it this way.
command = [self.python, "-m", "pip", "install", "--upgrade", "pip"]
if sys.version_info < (3, 12):
command.append("setuptools")
command = [
self.python,
"-m",
"pip",
"install",
"--upgrade",
"pip",
'setuptools; python_version<"3.12"',
]
subprocess.check_output(command)

@property
Expand Down
Loading