2010-07-01 07:07:34 +02:00
|
|
|
import os
|
2014-01-28 15:17:51 +01:00
|
|
|
from os.path import exists
|
2013-08-23 13:12:37 +02:00
|
|
|
|
2017-05-16 12:16:30 +02:00
|
|
|
import pytest
|
2017-06-13 14:17:00 +02:00
|
|
|
|
2018-07-30 06:10:59 +02:00
|
|
|
from pip._internal.cli.status_codes import PREVIOUS_BUILD_DIR_ERROR
|
2010-04-18 14:10:04 +02:00
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_no_clean_option_blocks_cleaning_after_install(script, data):
|
2013-03-27 06:26:52 +01:00
|
|
|
"""
|
2013-05-25 02:11:15 +02:00
|
|
|
Test --no-clean option blocks cleaning after install
|
2013-03-27 06:26:52 +01:00
|
|
|
"""
|
2014-11-12 01:19:32 +01:00
|
|
|
build = script.base_path / 'pip-build'
|
|
|
|
script.pip(
|
|
|
|
'install', '--no-clean', '--no-index', '--build', build,
|
2020-06-01 12:28:18 +02:00
|
|
|
'--find-links={}'.format(data.find_links), 'simple',
|
|
|
|
expect_temp=True,
|
|
|
|
# TODO: allow_stderr_warning is used for the --build deprecation,
|
|
|
|
# remove it when removing support for --build
|
|
|
|
allow_stderr_warning=True,
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2014-11-12 01:19:32 +01:00
|
|
|
assert exists(build)
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2013-05-25 02:11:15 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2020-06-04 17:05:54 +02:00
|
|
|
def test_cleanup_prevented_upon_build_dir_exception(
|
|
|
|
script,
|
|
|
|
data,
|
|
|
|
use_new_resolver,
|
|
|
|
):
|
2013-07-24 11:02:08 +02:00
|
|
|
"""
|
|
|
|
Test no cleanup occurs after a PreviousBuildDirError
|
|
|
|
"""
|
2014-11-12 01:19:32 +01:00
|
|
|
build = script.venv_path / 'build'
|
|
|
|
build_simple = build / 'simple'
|
|
|
|
os.makedirs(build_simple)
|
2019-07-02 07:00:32 +02:00
|
|
|
build_simple.joinpath("setup.py").write_text("#")
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '-f', data.find_links, '--no-index', 'simple',
|
2014-11-12 01:19:32 +01:00
|
|
|
'--build', build,
|
2020-06-04 17:05:54 +02:00
|
|
|
expect_error=(not use_new_resolver),
|
|
|
|
expect_temp=(not use_new_resolver),
|
2020-06-23 14:14:29 +02:00
|
|
|
expect_stderr=True,
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2013-08-22 22:17:01 +02:00
|
|
|
|
2020-06-23 14:14:29 +02:00
|
|
|
assert (
|
|
|
|
"The -b/--build/--build-dir/--build-directory "
|
|
|
|
"option is deprecated."
|
|
|
|
) in result.stderr
|
|
|
|
|
2020-06-04 17:05:54 +02:00
|
|
|
if not use_new_resolver:
|
|
|
|
assert result.returncode == PREVIOUS_BUILD_DIR_ERROR, str(result)
|
|
|
|
assert "pip can't proceed" in result.stderr, str(result)
|
|
|
|
assert exists(build_simple), str(result)
|
2020-01-01 14:45:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.network
|
|
|
|
def test_pep517_no_legacy_cleanup(script, data, with_wheel):
|
|
|
|
"""Test a PEP 517 failed build does not attempt a legacy cleanup"""
|
|
|
|
to_install = data.packages.joinpath('pep517_wrapper_buildsys')
|
|
|
|
script.environ["PIP_TEST_FAIL_BUILD_WHEEL"] = "1"
|
|
|
|
res = script.pip(
|
|
|
|
'install', '-f', data.find_links, to_install,
|
|
|
|
expect_error=True
|
|
|
|
)
|
|
|
|
# Must not have built the package
|
|
|
|
expected = "Failed building wheel for pep517-wrapper-buildsys"
|
|
|
|
assert expected in str(res)
|
|
|
|
# Must not have attempted legacy cleanup
|
|
|
|
assert "setup.py clean" not in str(res)
|