Skip to content

Commit

Permalink
Make conda lookup private
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb committed Sep 15, 2024
1 parent e1a90e3 commit 90fe793
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions conda_lock/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_pypi_lookup(mapping_url: str) -> Dict[NormalizedName, MappingEntry]:


@lru_cache(maxsize=None)
def get_conda_lookup(mapping_url: str) -> Dict[str, MappingEntry]:
def _get_conda_lookup(mapping_url: str) -> Dict[str, MappingEntry]:
"""
Reverse grayskull name mapping to map conda names onto PyPI
"""
Expand All @@ -64,7 +64,7 @@ def get_conda_lookup(mapping_url: str) -> Dict[str, MappingEntry]:

def conda_name_to_pypi_name(name: str, mapping_url: str) -> NormalizedName:
"""return the pypi name for a conda package"""
lookup = get_conda_lookup(mapping_url=mapping_url)
lookup = _get_conda_lookup(mapping_url=mapping_url)
cname = canonicalize_name(name)
return lookup.get(cname, {"pypi_name": cname})["pypi_name"]

Expand Down
11 changes: 4 additions & 7 deletions tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
LockedDependency,
MetadataOption,
)
from conda_lock.lookup import DEFAULT_MAPPING_URL, get_conda_lookup
from conda_lock.lookup import DEFAULT_MAPPING_URL, conda_name_to_pypi_name
from conda_lock.models.channel import Channel
from conda_lock.models.lock_spec import Dependency, VCSDependency, VersionedDependency
from conda_lock.models.pip_repository import PipRepository
Expand Down Expand Up @@ -2691,18 +2691,15 @@ def test_lookup_sources():
Path(__file__).parent / "test-lookup" / "emoji-to-python-dateutil-lookup.yml"
)
url = f"file://{lookup.absolute()}"
conda_lookup = get_conda_lookup(url)
assert conda_lookup["emoji"]["pypi_name"] == "python-dateutil"
assert conda_name_to_pypi_name("emoji", url) == "python-dateutil"

# Test that the lookup can be read from a straight filename
url = str(lookup.absolute())
conda_lookup = get_conda_lookup(url)
assert conda_lookup["emoji"]["pypi_name"] == "python-dateutil"
assert conda_name_to_pypi_name("emoji", url) == "python-dateutil"

# Test that the default remote lookup contains expected nontrivial mappings
url = DEFAULT_MAPPING_URL
conda_lookup = get_conda_lookup(url)
assert conda_lookup["python-build"]["pypi_name"] == "build"
assert conda_name_to_pypi_name("python-build", url) == "build"


@pytest.fixture
Expand Down

0 comments on commit 90fe793

Please sign in to comment.