1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
pip/tests/functional/test_wheel.py
Miro Hrončok 75c2201d5a Mark 3 tests as network tests
________________ test_constraints_local_editable_install_pep518 ________________
    ...
    ----------------------------- Captured stdout call -----------------------------
    Script result: python -m pip download setuptools wheel -d /tmp/pytest-of-mockbuild/pytest-0/test_constraints_local_editabl0/data/packages
      return code: 1
    -- stderr: --------------------
      Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fba7fdeb160>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
      Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fba7fdeb0b8>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
      Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fba7fdeb4e0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
      Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fba7fdeb6d8>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
      Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fba7fdeb860>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
      Could not find a version that satisfies the requirement setuptools (from versions: )
    No matching distribution found for setuptools

    _____________ test_pep517_wheels_are_not_confused_with_other_files _____________
    ...
    -- stdout: --------------------
    Processing /tmp/pytest-of-mockbuild/pytest-0/test_pep517_wheels_are_not_con0/data/src/withpyproject
      Installing build dependencies: started
      Installing build dependencies: finished with status 'error'
      Complete output from command /tmp/pytest-of-mockbuild/pytest-0/test_pep517_wheels_are_not_con0/workspace/venv/bin/python /builddir/build/BUILDROOT/python-pip-19.0.2-1.fc30.x86_64/usr/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pytest-of-mockbuild/pytest-0/test_pep517_wheels_are_not_con0/workspace/tmp/pip-build-env-3un7dqu3/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel:
      Collecting setuptools
        Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb7cf5a8898>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
        Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb7cf5b9588>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
        Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb7cf5b9470>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
        Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb7cf5b9278>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
        Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb7cf5b9208>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
        Could not find a version that satisfies the requirement setuptools (from versions: )
      No matching distribution found for setuptools

    ________________________ test_upgrade_argparse_shadowed ________________________
    ...
    ----------------------------- Captured stdout call -----------------------------
    Script result: python -m pip install argparse==1.3
      return code: 1
    -- stderr: --------------------
      Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7ff07d6db240>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/argparse/
      Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7ff07d6db358>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/argparse/
      Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7ff07d6db400>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/argparse/
      Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7ff07d6db518>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/argparse/
      Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7ff07d6c7710>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/argparse/
      Could not find a version that satisfies the requirement argparse==1.3 (from versions: )
    No matching distribution found for argparse==1.3
2019-02-13 13:01:04 +01:00

248 lines
8.8 KiB
Python

"""'pip wheel' tests"""
import os
from os.path import exists
import pytest
from pip._internal.cli.status_codes import ERROR, PREVIOUS_BUILD_DIR_ERROR
from pip._internal.locations import write_delete_marker_file
from tests.lib import pyversion
@pytest.fixture(autouse=True)
def auto_with_wheel(with_wheel):
pass
def add_files_to_dist_directory(folder):
(folder / 'dist').makedirs()
(folder / 'dist' / 'a_name-0.0.1.tar.gz').write("hello")
# Not adding a wheel file since that confuses setuptools' backend.
# (folder / 'dist' / 'a_name-0.0.1-py2.py3-none-any.whl').write("hello")
def test_wheel_exit_status_code_when_no_requirements(script):
"""
Test wheel exit status code when no requirements specified
"""
result = script.pip('wheel', expect_error=True)
assert "You must give at least one requirement to wheel" in result.stderr
assert result.returncode == ERROR
def test_wheel_exit_status_code_when_blank_requirements_file(script):
"""
Test wheel exit status code when blank requirements file specified
"""
script.scratch_path.join("blank.txt").write("\n")
script.pip('wheel', '-r', 'blank.txt')
def test_pip_wheel_success(script, data):
"""
Test 'pip wheel' success.
"""
result = script.pip(
'wheel', '--no-index', '-f', data.find_links,
'simple==3.0',
)
wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion[0]
wheel_file_path = script.scratch / wheel_file_name
assert wheel_file_path in result.files_created, result.stdout
assert "Successfully built simple" in result.stdout, result.stdout
def test_basic_pip_wheel_downloads_wheels(script, data):
"""
Test 'pip wheel' downloads wheels
"""
result = script.pip(
'wheel', '--no-index', '-f', data.find_links, 'simple.dist',
)
wheel_file_name = 'simple.dist-0.1-py2.py3-none-any.whl'
wheel_file_path = script.scratch / wheel_file_name
assert wheel_file_path in result.files_created, result.stdout
assert "Saved" in result.stdout, result.stdout
def test_pip_wheel_builds_when_no_binary_set(script, data):
data.packages.join('simple-3.0-py2.py3-none-any.whl').touch()
# Check that the wheel package is ignored
res = script.pip(
'wheel', '--no-index', '--no-binary', ':all:',
'-f', data.find_links,
'simple==3.0')
assert "Building wheel for simple" in str(res), str(res)
def test_pip_wheel_builds_editable_deps(script, data):
"""
Test 'pip wheel' finds and builds dependencies of editables
"""
editable_path = os.path.join(data.src, 'requires_simple')
result = script.pip(
'wheel', '--no-index', '-f', data.find_links,
'-e', editable_path
)
wheel_file_name = 'simple-1.0-py%s-none-any.whl' % pyversion[0]
wheel_file_path = script.scratch / wheel_file_name
assert wheel_file_path in result.files_created, result.stdout
def test_pip_wheel_builds_editable(script, data):
"""
Test 'pip wheel' builds an editable package
"""
editable_path = os.path.join(data.src, 'simplewheel-1.0')
result = script.pip(
'wheel', '--no-index', '-f', data.find_links,
'-e', editable_path
)
wheel_file_name = 'simplewheel-1.0-py%s-none-any.whl' % pyversion[0]
wheel_file_path = script.scratch / wheel_file_name
assert wheel_file_path in result.files_created, result.stdout
def test_pip_wheel_fail(script, data):
"""
Test 'pip wheel' failure.
"""
result = script.pip(
'wheel', '--no-index', '-f', data.find_links,
'wheelbroken==0.1',
expect_error=True,
)
wheel_file_name = 'wheelbroken-0.1-py%s-none-any.whl' % pyversion[0]
wheel_file_path = script.scratch / wheel_file_name
assert wheel_file_path not in result.files_created, (
wheel_file_path,
result.files_created,
)
assert "FakeError" in result.stdout, result.stdout
assert "Failed to build wheelbroken" in result.stdout, result.stdout
assert result.returncode != 0
def test_no_clean_option_blocks_cleaning_after_wheel(script, data):
"""
Test --no-clean option blocks cleaning after wheel build
"""
build = script.venv_path / 'build'
result = script.pip(
'wheel', '--no-clean', '--no-index', '--build', build,
'--find-links=%s' % data.find_links,
'simple',
expect_temp=True,
)
build = build / 'simple'
assert exists(build), "build/simple should still exist %s" % str(result)
def test_pip_wheel_source_deps(script, data):
"""
Test 'pip wheel' finds and builds source archive dependencies
of wheels
"""
# 'requires_source' is a wheel that depends on the 'source' project
result = script.pip(
'wheel', '--no-index', '-f', data.find_links,
'requires_source',
)
wheel_file_name = 'source-1.0-py%s-none-any.whl' % pyversion[0]
wheel_file_path = script.scratch / wheel_file_name
assert wheel_file_path in result.files_created, result.stdout
assert "Successfully built source" in result.stdout, result.stdout
def test_pip_wheel_fail_cause_of_previous_build_dir(script, data):
"""
Test when 'pip wheel' tries to install a package that has a previous build
directory
"""
# Given that I have a previous build dir of the `simple` package
build = script.venv_path / 'build' / 'simple'
os.makedirs(build)
write_delete_marker_file(script.venv_path / 'build' / 'simple')
build.join('setup.py').write('#')
# When I call pip trying to install things again
result = script.pip(
'wheel', '--no-index', '--find-links=%s' % data.find_links,
'--build', script.venv_path / 'build',
'simple==3.0', expect_error=True, expect_temp=True,
)
# Then I see that the error code is the right one
assert result.returncode == PREVIOUS_BUILD_DIR_ERROR, result
def test_wheel_package_with_latin1_setup(script, data):
"""Create a wheel from a package with latin-1 encoded setup.py."""
pkg_to_wheel = data.packages.join("SetupPyLatin1")
result = script.pip('wheel', pkg_to_wheel)
assert 'Successfully built SetupPyUTF8' in result.stdout
def test_pip_wheel_with_pep518_build_reqs(script, data, common_wheels):
result = script.pip('wheel', '--no-index', '-f', data.find_links,
'-f', common_wheels, 'pep518==3.0',)
wheel_file_name = 'pep518-3.0-py%s-none-any.whl' % pyversion[0]
wheel_file_path = script.scratch / wheel_file_name
assert wheel_file_path in result.files_created, result.stdout
assert "Successfully built pep518" in result.stdout, result.stdout
assert "Installing build dependencies" in result.stdout, result.stdout
def test_pip_wheel_with_pep518_build_reqs_no_isolation(script, data):
script.pip_install_local('simplewheel==2.0')
result = script.pip(
'wheel', '--no-index', '-f', data.find_links,
'--no-build-isolation', 'pep518==3.0',
)
wheel_file_name = 'pep518-3.0-py%s-none-any.whl' % pyversion[0]
wheel_file_path = script.scratch / wheel_file_name
assert wheel_file_path in result.files_created, result.stdout
assert "Successfully built pep518" in result.stdout, result.stdout
assert "Installing build dependencies" not in result.stdout, result.stdout
def test_pip_wheel_with_user_set_in_config(script, data, common_wheels):
config_file = script.scratch_path / 'pip.conf'
script.environ['PIP_CONFIG_FILE'] = str(config_file)
config_file.write("[install]\nuser = true")
result = script.pip(
'wheel', data.src / 'withpyproject',
'--no-index', '-f', common_wheels
)
assert "Successfully built withpyproject" in result.stdout, result.stdout
@pytest.mark.network
def test_pep517_wheels_are_not_confused_with_other_files(script, tmpdir, data):
"""Check correct wheels are copied. (#6196)
"""
pkg_to_wheel = data.src / 'withpyproject'
add_files_to_dist_directory(pkg_to_wheel)
result = script.pip('wheel', pkg_to_wheel, '-w', script.scratch_path)
assert "Installing build dependencies" in result.stdout, result.stdout
wheel_file_name = 'withpyproject-0.0.1-py%s-none-any.whl' % pyversion[0]
wheel_file_path = script.scratch / wheel_file_name
assert wheel_file_path in result.files_created, result.stdout
def test_legacy_wheels_are_not_confused_with_other_files(script, tmpdir, data):
"""Check correct wheels are copied. (#6196)
"""
pkg_to_wheel = data.src / 'simplewheel-1.0'
add_files_to_dist_directory(pkg_to_wheel)
result = script.pip('wheel', pkg_to_wheel, '-w', script.scratch_path)
assert "Installing build dependencies" not in result.stdout, result.stdout
wheel_file_name = 'simplewheel-1.0-py%s-none-any.whl' % pyversion[0]
wheel_file_path = script.scratch / wheel_file_name
assert wheel_file_path in result.files_created, result.stdout