Skip to content

Commit

Permalink
Rename normalize_pypi_name → pypi_name_to_conda_name
Browse files Browse the repository at this point in the history
This name is much more explicit. Also add a doctest.
  • Loading branch information
maresb committed Sep 14, 2024
1 parent 1c4b833 commit 14a25bd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions conda_lock/src_parser/pyproject_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@
)


def normalize_pypi_name(name: str) -> str:
def pypi_name_to_conda_name(name: str) -> str:
"""Convert a PyPI package name to a conda package name.
>>> pypi_name_to_conda_name("build")
'python-build'
>>> pypi_name_to_conda_name("zpfqzvrj")
'zpfqzvrj'
"""
cname = canonicalize_pypi_name(name)
if cname in get_lookup():
lookup = get_lookup()[cname]
Expand Down Expand Up @@ -292,7 +300,7 @@ def parse_poetry_pyproject_toml(
)

if manager == "conda":
name = normalize_pypi_name(depname)
name = pypi_name_to_conda_name(depname)
version = poetry_version_to_conda_version(poetry_version_spec)
else:
name = depname
Expand Down Expand Up @@ -506,7 +514,7 @@ def parse_python_requirement(
conda_version = ",".join(sorted(conda_version.split(",")))

if normalize_name:
conda_dep_name = normalize_pypi_name(name)
conda_dep_name = pypi_name_to_conda_name(name)
else:
conda_dep_name = name
extras = list(parsed_req.extras)
Expand Down

0 comments on commit 14a25bd

Please sign in to comment.