Skip to content

Commit

Permalink
Handle UV bug (#1388)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek authored Apr 14, 2024
1 parent 62ed6c3 commit 7569838
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/src/hatchling/dep/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def dependency_in_sync(
else:
return False
result = subprocess.run(vcs_cmd, capture_output=True, text=True) # noqa: PLW1510
if result.returncode:
if result.returncode or not result.stdout.strip():
return False
latest_commit_id, *_ = result.stdout.split()
return commit_id == latest_commit_id
Expand Down
30 changes: 28 additions & 2 deletions tests/backend/dep/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_extra_met(platform, uv_on_path):

@pytest.mark.requires_internet
@pytest.mark.requires_git
def test_dependency_git(platform):
def test_dependency_git_pip(platform):
with TempVirtualEnv(sys.executable, platform) as venv:
platform.run_command(
['pip', 'install', 'requests@git+https://github.com/psf/requests'], check=True, capture_output=True
Expand All @@ -85,14 +85,40 @@ def test_dependency_git(platform):

@pytest.mark.requires_internet
@pytest.mark.requires_git
def test_dependency_git_revision(platform):
def test_dependency_git_uv(platform, uv_on_path):
with TempUVVirtualEnv(sys.executable, platform) as venv:
platform.run_command(
[uv_on_path, 'pip', 'install', 'requests@git+https://github.com/psf/requests'],
check=True,
capture_output=True,
)
assert not dependencies_in_sync([Requirement('requests@git+https://github.com/psf/requests')], venv.sys_path)


@pytest.mark.requires_internet
@pytest.mark.requires_git
def test_dependency_git_revision_pip(platform):
with TempVirtualEnv(sys.executable, platform) as venv:
platform.run_command(
['pip', 'install', 'requests@git+https://github.com/psf/requests@main'], check=True, capture_output=True
)
assert dependencies_in_sync([Requirement('requests@git+https://github.com/psf/requests@main')], venv.sys_path)


@pytest.mark.requires_internet
@pytest.mark.requires_git
def test_dependency_git_revision_uv(platform, uv_on_path):
with TempUVVirtualEnv(sys.executable, platform) as venv:
platform.run_command(
[uv_on_path, 'pip', 'install', 'requests@git+https://github.com/psf/requests@main'],
check=True,
capture_output=True,
)
assert not dependencies_in_sync(
[Requirement('requests@git+https://github.com/psf/requests@main')], venv.sys_path
)


@pytest.mark.requires_internet
@pytest.mark.requires_git
def test_dependency_git_commit(platform, uv_on_path):
Expand Down

0 comments on commit 7569838

Please sign in to comment.