Skip to content

Commit

Permalink
Performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Jun 22, 2023
1 parent 2efac0d commit 2e098de
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions mypy/test/testpep561.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,19 @@ def virtualenv(python_executable: str = sys.executable) -> Iterator[tuple[str, s
yield venv_dir, os.path.abspath(os.path.join(venv_dir, "bin", "python"))


def upgrade_pip(python_executable: str, version_str: str) -> None:
"""Install a newer pip version."""
install_cmd = [python_executable, "-m", "pip", "install", f"pip{version_str}"]
def upgrade_pip(python_executable: str) -> None:
"""Install pip>=21.3.1. Required for editable installs with PEP 660."""
if (
sys.version_info >= (3, 11)
or (3, 10, 3) <= sys.version_info < (3, 11)
or (3, 9, 11) <= sys.version_info < (3, 10)
or (3, 8, 13) <= sys.version_info < (3, 9)
):
# Skip for more recent Python releases which come with pip>=21.3.1
# out of the box - for performance reasons.
return

install_cmd = [python_executable, "-m", "pip", "install", "pip>=21.3.1"]
try:
with filelock.FileLock(pip_lock, timeout=pip_timeout):
proc = subprocess.run(install_cmd, capture_output=True, env=os.environ)
Expand Down Expand Up @@ -107,7 +117,7 @@ def test_pep561(testcase: DataDrivenTestCase) -> None:
venv_dir, python_executable = venv
if editable:
# Editable installs with PEP 660 require pip>=21.3
upgrade_pip(python_executable, ">=21.3.1")
upgrade_pip(python_executable)
for pkg in pkgs:
install_package(pkg, python_executable, editable)

Expand Down

0 comments on commit 2e098de

Please sign in to comment.