Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatchSpec parses incorrectly when channel is passes as a URL #793

Closed
travishathaway opened this issue Jul 25, 2024 · 2 comments · Fixed by #810
Closed

MatchSpec parses incorrectly when channel is passes as a URL #793

travishathaway opened this issue Jul 25, 2024 · 2 comments · Fixed by #810

Comments

@travishathaway
Copy link
Contributor

What happened?

While using the py-rattler library, I discovered a possible problem with how MatchSpecs are parsed when passing the channel name as a URL

>>> from rattler import MatchSpec
>>> m = MatchSpec("https://conda.anaconda.org/conda-forge::python[version=3.9]")
>>> m
MatchSpec("*")
>>> print(m.channel)
None

The following happens when specifying the channel as a MatchSpec key:

>>> from rattler import MatchSpec
>>> m = MatchSpec("python[channel=https://conda.anaconda.org/conda-forge,version=3.9]")
InvalidMatchSpecException                 Traceback (most recent call last)
Cell In[21], line 1
----> 1 m = MatchSpec("python[channel=https://conda.anaconda.org/python/conda,version=3.9]")

File ~/opt/testminiconda/envs/pyrattler/lib/python3.12/site-packages/rattler/match_spec/match_spec.py:85, in MatchSpec.__init__(self, spec, strict)
     83 def __init__(self, spec: str, strict: bool = False) -> None:
     84     if isinstance(spec, str):
---> 85         self._match_spec = PyMatchSpec(spec, strict)
     86     else:
     87         raise TypeError(
     88             "MatchSpec constructor received unsupported type" f" {type(spec).__name__!r} for the 'spec' parameter"
     89         )

InvalidMatchSpecException: invalid bracket key: channel

What should happen?

I would expect rattler to be able to parse full URLs properly. This is currently also a bug in conda as reported here:

But, micromamba appears to be parsing this correctly.

@ruben-arts
Copy link
Collaborator

ruben-arts commented Jul 25, 2024

Just to verify. The channel name of https://software.repos.intel.com/python/conda should be conda right? Not python/conda.

EDIT: That was wrong it needs to be python/conda

@baszalmstra
Copy link
Collaborator

We just merged #792 which fixes:

>>> from rattler import MatchSpec
>>> m = MatchSpec("https://conda.anaconda.org/conda-forge::python[version=3.9]")
>>> m
MatchSpec("conda-forge::python ==3.9")
>>> m.channel
Channel(name="conda-forge", base_url="https://conda.anaconda.org/conda-forge/")

Parsing python[channel=https://conda.anaconda.org/python/conda,version=3.9] still fails because we dont recognize the channel key yet. That will be next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants