-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from mariusvniekerk/channel-spec
Allow channel::package in package specifications
- Loading branch information
Showing
7 changed files
with
112 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from typing import Optional | ||
|
||
from ..src_parser import VersionedDependency | ||
from ..vendor.conda.models.channel import Channel | ||
from ..vendor.conda.models.match_spec import MatchSpec | ||
|
||
|
||
def conda_spec_to_versioned_dep(spec: str, category: str) -> VersionedDependency: | ||
"""Convert a string form conda spec into a versioned dependency for a given category. | ||
This is used by the environment.yaml and meta.yaml specification parser | ||
""" | ||
|
||
try: | ||
ms = MatchSpec(spec) | ||
except Exception as e: | ||
raise RuntimeError(f"Failed to turn `{spec}` into a MatchSpec") from e | ||
|
||
package_channel: Optional[Channel] = ms.get("channel") | ||
if package_channel: | ||
channel_str = package_channel.canonical_name | ||
else: | ||
channel_str = None | ||
return VersionedDependency( | ||
name=ms.name, | ||
version=ms.get("version", ""), | ||
manager="conda", | ||
optional=category != "main", | ||
category=category, | ||
extras=[], | ||
build=ms.get("build"), | ||
conda_channel=channel_str, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
channels: | ||
# This example is constructed in this way to mirror a real life packaging | ||
# issue that was experienced in 2022-07. | ||
# In this case we have the channel order as recommended by rapids ai for | ||
# installing cudf, but we want to force getting cuda-python from conda-forge | ||
# instead of from the nvidia channel which would normally have higher priority | ||
- rapidsai | ||
- nvidia | ||
- conda-forge | ||
dependencies: | ||
- cudf | ||
- conda-forge::cuda-python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters