2011-03-14 21:45:47 +01:00
|
|
|
"""
|
|
|
|
Tests for compatibility workarounds.
|
|
|
|
|
|
|
|
"""
|
|
|
|
import os
|
2023-03-18 16:03:13 +01:00
|
|
|
from pathlib import Path
|
2017-05-16 12:16:30 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
import pytest
|
2017-06-13 14:17:00 +02:00
|
|
|
|
2023-06-05 16:06:11 +02:00
|
|
|
from tests.lib import (
|
|
|
|
PipTestEnvironment,
|
|
|
|
TestData,
|
|
|
|
assert_all_changes,
|
2023-09-21 02:00:34 +02:00
|
|
|
pyversion,
|
2023-06-05 16:06:11 +02:00
|
|
|
)
|
2011-03-14 21:45:47 +01:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2023-03-18 16:03:13 +01:00
|
|
|
def test_debian_egg_name_workaround(
|
|
|
|
script: PipTestEnvironment,
|
|
|
|
shared_data: TestData,
|
|
|
|
tmp_path: Path,
|
|
|
|
) -> None:
|
2011-03-14 21:45:47 +01:00
|
|
|
"""
|
|
|
|
We can uninstall packages installed with the pyversion removed from the
|
|
|
|
egg-info metadata directory name.
|
|
|
|
|
|
|
|
Refs:
|
|
|
|
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=618367
|
|
|
|
https://bugs.launchpad.net/ubuntu/+source/distribute/+bug/725178
|
|
|
|
https://bitbucket.org/ianb/pip/issue/104/pip-uninstall-on-ubuntu-linux
|
|
|
|
|
|
|
|
"""
|
2023-03-18 16:03:13 +01:00
|
|
|
result = script.run(
|
|
|
|
"python",
|
|
|
|
"setup.py",
|
|
|
|
"install",
|
|
|
|
"--single-version-externally-managed",
|
|
|
|
f"--record={tmp_path / 'record'}",
|
|
|
|
cwd=shared_data.src / "simplewheel-2.0",
|
|
|
|
)
|
2011-03-14 21:45:47 +01:00
|
|
|
|
|
|
|
egg_info = os.path.join(
|
2023-03-18 16:03:13 +01:00
|
|
|
script.site_packages, f"simplewheel-2.0-py{pyversion}.egg-info"
|
2021-02-13 07:27:17 +01:00
|
|
|
)
|
2011-03-14 21:45:47 +01:00
|
|
|
|
|
|
|
# Debian only removes pyversion for global installs, not inside a venv
|
2014-01-28 15:17:51 +01:00
|
|
|
# so even if this test runs on a Debian/Ubuntu system with broken
|
|
|
|
# setuptools, since our test runs inside a venv we'll still have the normal
|
|
|
|
# .egg-info
|
2021-02-13 07:27:17 +01:00
|
|
|
result.did_create(egg_info, message=f"Couldn't find {egg_info}")
|
2011-03-14 21:45:47 +01:00
|
|
|
|
|
|
|
# The Debian no-pyversion version of the .egg-info
|
2023-03-18 16:03:13 +01:00
|
|
|
mangled = os.path.join(script.site_packages, "simplewheel-2.0.egg-info")
|
2021-02-13 07:27:17 +01:00
|
|
|
result.did_not_create(mangled, message=f"Found unexpected {mangled}")
|
2011-03-14 21:45:47 +01:00
|
|
|
|
|
|
|
# Simulate a Debian install by copying the .egg-info to their name for it
|
2013-08-21 11:16:07 +02:00
|
|
|
full_egg_info = os.path.join(script.base_path, egg_info)
|
2011-03-14 21:45:47 +01:00
|
|
|
assert os.path.isdir(full_egg_info)
|
2013-08-21 11:16:07 +02:00
|
|
|
full_mangled = os.path.join(script.base_path, mangled)
|
2011-03-14 21:45:47 +01:00
|
|
|
os.renames(full_egg_info, full_mangled)
|
|
|
|
assert os.path.isdir(full_mangled)
|
|
|
|
|
|
|
|
# Try the uninstall and verify that everything is removed.
|
2023-03-18 16:03:13 +01:00
|
|
|
result2 = script.pip("uninstall", "simplewheel", "-y")
|
2014-02-24 22:52:23 +01:00
|
|
|
assert_all_changes(result, result2, [script.venv / "build", "cache"])
|
2011-03-22 02:51:23 +01:00
|
|
|
|
|
|
|
|
2021-09-13 00:31:12 +02:00
|
|
|
def test_setup_py_with_dos_line_endings(
|
|
|
|
script: PipTestEnvironment, data: TestData
|
|
|
|
) -> None:
|
2011-03-22 02:51:23 +01:00
|
|
|
"""
|
|
|
|
It doesn't choke on a setup.py file that uses DOS line endings (\\r\\n).
|
|
|
|
|
|
|
|
Refs https://github.com/pypa/pip/issues/237
|
|
|
|
"""
|
2019-07-02 07:00:32 +02:00
|
|
|
to_install = data.packages.joinpath("LineEndings")
|
2020-01-02 23:21:22 +01:00
|
|
|
script.pip("install", to_install)
|