|
11 | 11 |
|
12 | 12 | import pytest |
13 | 13 |
|
| 14 | +from pex.dist_metadata import ProjectNameAndVersion |
14 | 15 | from pex.interpreter import PythonInterpreter |
15 | 16 | from pex.interpreter_constraints import COMPATIBLE_PYTHON_VERSIONS |
16 | 17 | from pex.os import LINUX, MAC, WINDOWS |
| 18 | +from pex.pep_503 import ProjectName |
| 19 | +from pex.venv.virtualenv import InstallationChoice, Virtualenv |
17 | 20 | from testing.cli import run_pex3 |
| 21 | +from testing.local_project import create as create_local_project |
18 | 22 | from testing.pytest_utils.tmp import Tempdir |
19 | 23 |
|
20 | 24 |
|
@@ -221,3 +225,37 @@ def test_vcs_subdir_via_pex_lock(tmpdir): |
221 | 225 | "wheel", "--pip-version", "latest-compatible", "--lock", lock, "-d", dest_dir |
222 | 226 | ).assert_success() |
223 | 227 | assert [EXPECTED_SDEV_LOGGING_UTILS_WHL] == os.listdir(dest_dir) |
| 228 | + |
| 229 | + |
| 230 | +@pytest.mark.skipif( |
| 231 | + sys.version_info < (3, 7), |
| 232 | + reason=( |
| 233 | + "Modern setuptools (>= 64.0.0) with support for pep-660 build_editable is required, and " |
| 234 | + "setuptools 64 requires at least Python 3.7." |
| 235 | + ), |
| 236 | +) |
| 237 | +def test_wheel_editable(tmpdir): |
| 238 | + # type: (Tempdir) -> None |
| 239 | + |
| 240 | + local_project = create_local_project(tmpdir.join("project")) |
| 241 | + dest_dir = tmpdir.join("dest") |
| 242 | + run_pex3("wheel", "-e", local_project, "ansicolors==1.1.8", "-d", dest_dir).assert_success() |
| 243 | + |
| 244 | + wheels_by_project_name = { |
| 245 | + ProjectNameAndVersion.from_filename(whl).canonicalized_project_name: whl |
| 246 | + for whl in os.listdir(dest_dir) |
| 247 | + } |
| 248 | + assert "ansicolors-1.1.8-py2.py3-none-any.whl" == wheels_by_project_name.pop( |
| 249 | + ProjectName("ansicolors") |
| 250 | + ) |
| 251 | + local_project_editable_whl = wheels_by_project_name.pop(ProjectName("local_project")) |
| 252 | + assert not wheels_by_project_name |
| 253 | + |
| 254 | + venv = Virtualenv.create( |
| 255 | + tmpdir.join("venv"), |
| 256 | + install_pip=InstallationChoice.YES, |
| 257 | + other_installs=[os.path.join(dest_dir, local_project_editable_whl)], |
| 258 | + ) |
| 259 | + assert b"foo" == subprocess.check_output(args=[venv.bin_path("local-project"), "foo"]) |
| 260 | + local_project.edit_all_caps(True) |
| 261 | + assert b"FOO" == subprocess.check_output(args=[venv.bin_path("local-project"), "foo"]) |
0 commit comments