Skip to content

Commit

Permalink
_validate_pip_in_conda_packages
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Feb 25, 2025
1 parent bc2323e commit 556573b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions unidep/pixi_to_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ def convert_pixi_to_conda_lock(
# Process PyPI packages
logging.info("Processing PyPI packages")
pypi_packages = process_pypi_packages(pixi_data, platforms)
if pypi_packages:
_validate_pip_in_conda_packages(conda_packages)

conda_lock_data["package"].extend(pypi_packages) # type: ignore[attr-defined]
logging.info("Added %d PyPI package entries to conda-lock data", len(pypi_packages))

Expand All @@ -456,6 +459,19 @@ def convert_pixi_to_conda_lock(
return conda_lock_data


def _validate_pip_in_conda_packages(conda_packages: list[dict[str, Any]]) -> None:
pip_included = any(
pkg.get("name") == "pip" and pkg.get("manager") == "conda"
for pkg in conda_packages
)
if not pip_included:
msg = (
"PyPI packages are present but no pip package found in conda packages. "
"Please ensure that pip is included in your pixi.lock file."
)
raise ValueError(msg)


def main() -> int:
"""Main function to convert pixi.lock to conda-lock.yml."""
parser = argparse.ArgumentParser(description="Convert pixi.lock to conda-lock.yml")
Expand Down

0 comments on commit 556573b

Please sign in to comment.