mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
nox: Better handle execution with protected pip
This commit is contained in:
parent
a6b06059c9
commit
4048daeddf
1 changed files with 15 additions and 8 deletions
23
noxfile.py
23
noxfile.py
|
@ -47,14 +47,18 @@ def get_author_list():
|
||||||
return sorted(authors, key=lambda x: x.lower())
|
return sorted(authors, key=lambda x: x.lower())
|
||||||
|
|
||||||
|
|
||||||
def protected_pip(*arguments):
|
def run_with_protected_pip(session, *arguments):
|
||||||
"""Get arguments for session.run, that use a "protected" pip.
|
"""Do a session.run("pip", *arguments), using a "protected" pip.
|
||||||
|
|
||||||
This invokes a wrapper script, that forwards calls to original virtualenv
|
This invokes a wrapper script, that forwards calls to original virtualenv
|
||||||
(stable) version, and not the code being tested. This ensures pip being
|
(stable) version, and not the code being tested. This ensures pip being
|
||||||
used is not the code being tested.
|
used is not the code being tested.
|
||||||
"""
|
"""
|
||||||
return ("python", LOCATIONS["protected-pip"]) + arguments
|
env = {"VIRTUAL_ENV": session.virtualenv.location}
|
||||||
|
|
||||||
|
command = ("python", LOCATIONS["protected-pip"]) + arguments
|
||||||
|
kwargs = {"env": env, "silent": True}
|
||||||
|
session.run(*command, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def should_update_common_wheels():
|
def should_update_common_wheels():
|
||||||
|
@ -84,15 +88,18 @@ def should_update_common_wheels():
|
||||||
def test(session):
|
def test(session):
|
||||||
# Get the common wheels.
|
# Get the common wheels.
|
||||||
if should_update_common_wheels():
|
if should_update_common_wheels():
|
||||||
session.run(*protected_pip(
|
run_with_protected_pip(
|
||||||
|
session,
|
||||||
"wheel",
|
"wheel",
|
||||||
"-w", LOCATIONS["common-wheels"],
|
"-w", LOCATIONS["common-wheels"],
|
||||||
"-r", REQUIREMENTS["common-wheels"],
|
"-r", REQUIREMENTS["common-wheels"],
|
||||||
))
|
)
|
||||||
|
|
||||||
# Install sources and dependencies
|
# Install sources
|
||||||
session.run(*protected_pip("install", "."))
|
run_with_protected_pip(session, "install", ".")
|
||||||
session.run(*protected_pip("install", "-r", REQUIREMENTS["tests"]))
|
|
||||||
|
# Install test dependencies
|
||||||
|
run_with_protected_pip(session, "install", "-r", REQUIREMENTS["tests"])
|
||||||
|
|
||||||
# Parallelize tests as much as possible, by default.
|
# Parallelize tests as much as possible, by default.
|
||||||
arguments = session.posargs or ["-n", "auto"]
|
arguments = session.posargs or ["-n", "auto"]
|
||||||
|
|
Loading…
Reference in a new issue