Metadata-Version: 2.4
Name: pixi-to-conda-lock
Version: 0.4.2
Summary: pixi-to-conda-lock converts a pixi.lock file to a conda-lock.yml file.
Author-email: Bas Nijholt <bas@nijho.lt>
Project-URL: Homepage, https://github.com/basnijholt/pixi-to-conda-lock
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyyaml
Requires-Dist: py-rattler
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pre-commit; extra == "test"
Requires-Dist: coverage; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Provides-Extra: rich
Requires-Dist: rich; extra == "rich"
Provides-Extra: docs
Dynamic: license-file

# pixi-to-conda-lock

[![Build](https://github.com/basnijholt/pixi-to-conda-lock/actions/workflows/pytest.yml/badge.svg)](https://github.com/basnijholt/pixi-to-conda-lock/actions)
[![Coverage](https://img.shields.io/codecov/c/github/basnijholt/pixi-to-conda-lock)](https://codecov.io/gh/basnijholt/pixi-to-conda-lock)
[![GitHub Stars](https://img.shields.io/github/stars/basnijholt/pixi-to-conda-lock.svg?style=social)](https://github.com/basnijholt/pixi-to-conda-lock/stargazers)
[![PyPI](https://img.shields.io/pypi/v/pixi-to-conda-lock.svg)](https://pypi.org/project/pixi-to-conda-lock)
[![License](https://img.shields.io/github/license/basnijholt/pixi-to-conda-lock)](https://github.com/basnijholt/pixi-to-conda-lock/blob/main/LICENSE)
[![Downloads](https://img.shields.io/pypi/dm/pixi-to-conda-lock)](https://pypi.org/project/pixi-to-conda-lock)
![Open Issues](https://img.shields.io/github/issues-raw/basnijholt/pixi-to-conda-lock)

**pixi-to-conda-lock** is a Python utility designed to bridge the gap between the lightning-fast `pixi lock` and the traditionally slow generation of `conda-lock` files.
By converting your fast-generated `pixi.lock` file into a fully functional `conda-lock.yml`, you can enjoy rapid lock file creation without sacrificing the reproducibility of your conda environments.

<details><summary><b>Table of Contents</b></summary>

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Features](#features)
- [Usage](#usage)
- [Installation](#installation)
- [Examples](#examples)
  - [Basic Conversion](#basic-conversion)
  - [Converting a Specific Environment](#converting-a-specific-environment)
  - [Specifying an Output Directory](#specifying-an-output-directory)
  - [Enable Verbose Logging](#enable-verbose-logging)
- [How It Works](#how-it-works)
- [Support and Contributions](#support-and-contributions)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

</details>

---

## Features

- **Speed Boost:** Generate a `conda-lock.yml` file quickly by leveraging the performance of `pixi lock`.
- **Accurate Conversion:** Uses repodata to extract detailed package metadata from your `pixi.lock` file.
- **Multi-Environment Support:** Convert all environments in your pixi.lock file or select specific ones.
- **Multi-Manager Support:** Handles both conda and PyPI packages, ensuring comprehensive environment reproduction.
- **Fully Tested:** Comprehensive tests ensure robust and reliable behavior.
- **Typed & Readable:** Written in Python with full type annotations for clarity and maintainability.

---

## Usage

Transform your fast-generated `pixi.lock` file into reproducible conda lock files with a single command:

```bash
pixi-to-conda-lock --help
```

This will display the help message:

<!-- CODE:BASH:START -->
<!-- echo '```bash' -->
<!-- pixi-to-conda-lock --help -->
<!-- echo '```' -->
<!-- CODE:END -->

<!-- OUTPUT:START -->
<!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
```bash
usage: pixi-to-conda-lock [-h] [--output OUTPUT] [--environment ENVIRONMENT]
                          [--verbose]
                          pixi_lock

Convert pixi.lock to conda-lock.yml

positional arguments:
  pixi_lock             Path to pixi.lock file

options:
  -h, --help            show this help message and exit
  --output, -o OUTPUT   Output directory for conda-lock files (default:
                        current directory)
  --environment, -e ENVIRONMENT
                        Specific environment to convert (default: convert all
                        environments)
  --verbose, -v         Enable verbose logging
```

<!-- OUTPUT:END -->

---

## Installation

Install **pixi-to-conda-lock** via [PyPI](https://pypi.org/project/pixi-to-conda-lock):

```bash
pip install pixi-to-conda-lock
```

Or clone the repository and install locally:

```bash
git clone https://github.com/basnijholt/pixi-to-conda-lock.git
cd pixi-to-conda-lock
pip install .
```

---

## Examples

### Basic Conversion

Convert all environments in your `pixi.lock` file to conda-lock files:

```bash
pixi-to-conda-lock /path/to/pixi.lock
```

This will generate:
- `conda-lock.yml` for the default environment
- `<env_name>.conda-lock.yml` for each additional environment

### Converting a Specific Environment

Convert only a specific environment from your pixi.lock file:

```bash
pixi-to-conda-lock /path/to/pixi.lock --environment dev
```

This will generate only `dev.conda-lock.yml` (or `conda-lock.yml` if the environment is "default").

### Specifying an Output Directory

Save the generated conda-lock files to a specific directory:

```bash
pixi-to-conda-lock /path/to/pixi.lock --output /path/to/output/dir
```

### Enable Verbose Logging

To see detailed logs during the conversion process:

```bash
pixi-to-conda-lock /path/to/pixi.lock --verbose
```

---

## How It Works

1. **Fast pixi.lock Parsing:** Reads the fast-generated `pixi.lock` file, which is created quickly compared to generating a conda lock file directly.
2. **Environment Detection:** Identifies all environments defined in the pixi.lock file or processes only the specified environment.
3. **Repodata Loading:** Retrieves detailed package metadata from repodata files (either automatically discovered or from a user-specified directory).
4. **Package Processing:** Processes both conda and PyPI packages for each environment. For conda packages, if repodata information isn't available, the tool falls back on URL parsing.
5. **Generating conda-lock.yml:** Combines the gathered information to generate fully reproducible conda-lock files that mirror your original environments.

This approach ensures you get the speed benefits of `pixi lock` without compromising on the quality and reproducibility of your conda environments.

---

## Support and Contributions

Contributions, bug reports, and feature suggestions are welcome! Please open an issue or submit a pull request on the [GitHub repository](https://github.com/basnijholt/pixi-to-conda-lock).

Happy converting!
