Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion conda_lock/pypi_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def get_package(locked: LockedDependency) -> PoetryPackage:
locked.name,
source_type="url",
source_url=locked.source.url,
version="0.0.0",
version=locked.version,
)
else:
return PoetryPackage(locked.name, version=locked.version)
Expand Down
24 changes: 24 additions & 0 deletions tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
from conda_lock.invoke_conda import is_micromamba, reset_conda_pkgs_dir
from conda_lock.lockfile import parse_conda_lock_file
from conda_lock.lockfile.v2prelim.models import (
DependencySource,
HashModel,
LockedDependency,
MetadataOption,
Expand All @@ -94,6 +95,7 @@
MANYLINUX_TAGS,
PlatformEnv,
_strip_auth,
get_package,
parse_pip_requirement,
solve_pypi,
)
Expand Down Expand Up @@ -3480,6 +3482,28 @@ def test_pip_full_whl_url(
)


def test_get_package_preserves_version_for_url_source():
"""A URL-sourced locked dep must reconcile with its real version, not a 0.0.0 placeholder."""
url = "https://example.com/foo-1.2.3-py3-none-any.whl"
locked = LockedDependency(
name="foo",
version="1.2.3",
manager="pip",
platform="linux-64",
dependencies={},
url=url,
hash=HashModel(),
source=DependencySource(type="url", url=url),
)

package = get_package(locked)

assert str(package.version) == "1.2.3"
# The dependency stays URL-pinned.
assert package.source_type == "url"
assert package.source_url == url


def test_when_merging_lockfiles_content_hashes_are_updated(
conda_exe: str,
monkeypatch: "pytest.MonkeyPatch",
Expand Down
Loading