Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,20 @@ def is_satisfied(self, req: InstallRequirement):
match.version, prereleases=True
)
if req.link is None:
return True
elif req.editable and req.link.is_vcs:
# For editable VCS dependencies, check if the source directory exists
# This ensures we reinstall if the source checkout is missing
src_dir = os.path.join(os.getcwd(), "src")
if not os.path.exists(src_dir):
return False

# If we have a specific package directory, check that too
if req.name:
pkg_dir = os.path.join(src_dir, req.name)
if not os.path.exists(pkg_dir):
return False

return True
elif req.editable and req.link.is_file:
requested_path = req.link.file_path
Expand Down
56 changes: 56 additions & 0 deletions tests/integration/test_editable_vcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os

Check failure on line 1 in tests/integration/test_editable_vcs.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

tests/integration/test_editable_vcs.py:1:8: F401 `os` imported but unused
import shutil
from pathlib import Path

import pytest

from pipenv.utils.processes import subprocess_run

Check failure on line 7 in tests/integration/test_editable_vcs.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

tests/integration/test_editable_vcs.py:7:36: F401 `pipenv.utils.processes.subprocess_run` imported but unused


@pytest.mark.integration
@pytest.mark.install
@pytest.mark.editable
@pytest.mark.vcs
def test_editable_vcs_reinstall(pipenv_instance_private_pypi):
"""Test that editable VCS dependencies are reinstalled when the source checkout is missing."""
with pipenv_instance_private_pypi() as p:
# Create a Pipfile with an editable VCS dependency
with open(p.pipfile_path, "w") as f:
f.write("""
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
gunicorn = {git = "https://github.com/benoitc/gunicorn", ref = "23.0.0", editable = true}
""".strip())

# Install the dependency
c = p.pipenv("install")
assert c.returncode == 0, f"Failed to install: {c.stderr}"

# Verify the src directory was created
src_dir = Path(p.path) / "src"
assert src_dir.exists(), "src directory was not created"
assert any(src_dir.iterdir()), "src directory is empty"

# Import the package to verify it's installed correctly
c = p.pipenv("run python -c 'import gunicorn'")
assert c.returncode == 0, f"Failed to import gunicorn: {c.stderr}"

# Remove the src directory to simulate the issue
shutil.rmtree(src_dir)
assert not src_dir.exists(), "Failed to remove src directory"

# Run pipenv install again to see if it reinstalls the dependency
c = p.pipenv("install")
assert c.returncode == 0, f"Failed to reinstall: {c.stderr}"

# Verify the src directory was recreated
assert src_dir.exists(), "src directory was not recreated"
assert any(src_dir.iterdir()), "recreated src directory is empty"

# Import the package again to verify it's reinstalled correctly
c = p.pipenv("run python -c 'import gunicorn'")
assert c.returncode == 0, f"Failed to import gunicorn after reinstall: {c.stderr}"
Loading