test_wheel: upgrade pip inside virtualenv, don't write bytecode

This commit is contained in:
rdb 2019-04-30 10:32:01 +02:00
parent d9d30cdfd2
commit 9512187156

View File

@ -17,31 +17,34 @@ from optparse import OptionParser
def test_wheel(wheel, verbose=False): def test_wheel(wheel, verbose=False):
envdir = tempfile.mkdtemp(prefix="venv-") envdir = tempfile.mkdtemp(prefix="venv-")
print("Setting up virtual environment in {0}".format(envdir)) print("Setting up virtual environment in {0}".format(envdir))
sys.stdout.flush()
if sys.version_info >= (3, 0):
subprocess.call([sys.executable, "-m", "venv", "--clear", envdir])
else:
subprocess.call([sys.executable, "-m", "virtualenv", "--clear", envdir])
# Make sure pip is up-to-date first. # Make sure pip is up-to-date first.
if subprocess.call([sys.executable, "-m", "pip", "install", "-U", "pip"]) != 0: subprocess.call([sys.executable, "-B", "-m", "pip", "install", "-U", "pip"])
shutil.rmtree(envdir)
sys.exit(1)
# Install pytest into the environment, as well as our wheel. # Create a virtualenv.
if sys.platform == "win32": if sys.version_info >= (3, 0):
pip = os.path.join(envdir, "Scripts", "pip.exe") subprocess.call([sys.executable, "-B", "-m", "venv", "--clear", envdir])
else: else:
pip = os.path.join(envdir, "bin", "pip") subprocess.call([sys.executable, "-B", "-m", "virtualenv", "--clear", envdir])
if subprocess.call([pip, "install", "pytest", wheel]) != 0:
shutil.rmtree(envdir)
sys.exit(1)
# Run the test suite. # Determine the path to the Python interpreter.
if sys.platform == "win32": if sys.platform == "win32":
python = os.path.join(envdir, "Scripts", "python.exe") python = os.path.join(envdir, "Scripts", "python.exe")
else: else:
python = os.path.join(envdir, "bin", "python") python = os.path.join(envdir, "bin", "python")
# Upgrade pip inside the environment too.
if subprocess.call([python, "-m", "pip", "install", "-U", "pip"]) != 0:
shutil.rmtree(envdir)
sys.exit(1)
# Install pytest into the environment, as well as our wheel.
if subprocess.call([python, "-m", "pip", "install", "pytest", wheel]) != 0:
shutil.rmtree(envdir)
sys.exit(1)
# Run the test suite.
test_cmd = [python, "-m", "pytest", "tests"] test_cmd = [python, "-m", "pytest", "tests"]
if verbose: if verbose:
test_cmd.append("--verbose") test_cmd.append("--verbose")