Skip to content

Commit

Permalink
Merge branch 'main' into feat/total-order-for-dependency-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
tdejager authored Oct 5, 2024
2 parents 930065d + ba30fa9 commit 59408db
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
8 changes: 4 additions & 4 deletions py-rattler/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions py-rattler/rattler/channel/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def __init__(self, name: str, channel_configuration: Optional[ChannelConfig] = N

self._channel = PyChannel(name, channel_configuration._channel_configuration)

@classmethod
def _from_py_channel(cls, py_channel: PyChannel) -> Channel:
channel = cls.__new__(cls)
channel._channel = py_channel
return channel

def to_lock_channel(self) -> LockChannel:
"""
Returns a new [`LockChannel`] from existing channel.
Expand Down
5 changes: 2 additions & 3 deletions py-rattler/rattler/match_spec/match_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ def channel(self) -> Optional[Channel]:
"""
The channel of the package.
"""
if (channel := self._match_spec.channel) is not None:
return Channel(channel.name)
return None
channel = self._match_spec.channel
return channel and Channel._from_py_channel(channel)

@property
def subdir(self) -> Optional[str]:
Expand Down
22 changes: 22 additions & 0 deletions py-rattler/tests/unit/test_matchspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,25 @@ def test_parse_channel_from_url() -> None:
assert m.channel is not None
assert m.channel.name == "conda-forge"
assert m.channel.base_url == "https://conda.anaconda.org/conda-forge/"


def test_parse_channel_from_url_filesystem() -> None:
m = MatchSpec("file:///Users/rattler/channel0::python[version=3.9]")
assert m.channel is not None
assert m.channel.name == "channel0"
assert m.channel.base_url == "file:///Users/rattler/channel0/"


def test_parse_channel_from_url_localhost() -> None:
m = MatchSpec("http://localhost:8000/channel0::python[version=3.9]")
assert m.channel is not None
assert m.channel.name == "channel0"
assert m.channel.base_url == "http://localhost:8000/channel0/"


def test_parse_no_channel() -> None:
m = MatchSpec("python[version=3.9]")
assert m.channel is None
assert m.name is not None
assert m.name.normalized == "python"
assert m.version == "==3.9"

0 comments on commit 59408db

Please sign in to comment.