Skip to main content

Introduction

Reroll is an exploratory codebase which generates conda repodata.json-like entries for a wheel. It's uploaded as py-reroll on pypi.org

from reroll import reroll

reroll("path-to-wheel.whl")

Reroll's principles are:

  1. Correctness - A rerolled package should faithfully translate name, version, architecture, extras and more between the pypi and conda ecosystem without loss-of-specificity
  2. Ecosystem-wide compatibility - Reroll is designed towards broadly supporting the pypi ecosystem. That means not just supporting simple regex-based solutions or other shortcuts, but truly parsing and understanding the wheel requirements
  3. Broadly usable - Reroll is modular and designed for integration into larger projects. It doesn't have any conda dependencies, so it can be installed in a normal python environment. Its API surface is compatible for conversion of large scale pypi registries - neither the wheel or the full metadata is required (just store the parsed fields reroll cares about)

In order to achieve these goals, reroll is deliberately not fully-compliant with the proposed wheel repodata CEP, although it aims to be directionally compatible. the -145 pull currently does not support arch-specific repodata, and that is required to achieve broad, accurate repodata for all wheels (even *-none-any wheels with arch-specific dependencies)

How it works

At its core, reroll is based around two technologies: markerpry and the pep508-to-matchspec converter in this repository. Creating accurate repodata largely involves accurate mapping between conda's subdir-based architecture for platform-specific packages, and pypi's wheel name and conditional dependencies system. Markerpry helps bridge the gap by partially solving a packaging.requirements.Marker, in order to simplify it under certain conditions. For example, if you were creating repodata for linux-64, you would know that your os_name was posix. By partially solving, we can eliminate conditional markers that depend on os_name, and collapse them to true/false. The remaining tree is then (hopefully) expressable in conda's new conditional dependency syntax.

Additionally, this repository hopes to contribute a useful tool of converting a PEP-508 style requirement to a matchspec requirement. There are lots of subleties around versions (with .rc1 for example), ranges, varying support for conditional expressions and more.

Batch usage

Reroll is designed to allow users to have a separate wheel data ingestion stage, separate from repodata emission. Reroll only needs the filename and a JSON-serializable representation of a subset of the wheel's metadata. The reroll-data repository contains one such mechanism for saving the entire pypi metadata on a local sqlite database.

In such a scenario, the first step is data ingestion. Reroll does not care, nor does it provide any mechanism to download data from a pip index url. Use reroll-data, or other tools to accomplish it. However, once you do have the filename and the METADATA file, simply call:

from reroll.stages import extract_metadata_file, parse_metadata

wheel_metadata_contents: str = "..."
metadata = parse_metadata(wheel_metadata_contents)
data_json = metadata.model_dump_json()  # Save this to a database, along with the filename

And later, when you're ready to generate repodata:

from reroll import WheelMetadata
from reroll.stages import get_wheel_records

data_json = "..."  # Load from your database
wheel_filename = "..."  # Load from your database
metadata = WheelMetadata.model_validate_json(data_json)
records = get_wheel_records(metadata, filename)

PEP to Matchspec helper

If you ever have a PEP-440 style requirement and want to turn it into a matchspec, to_matchspec has you covered. It will convert the string if it can, otherwise an error will be raised if there's no compatible translation to matchspec

>>> from reroll import to_matchspec
>>> to_matchspec('packageA ; python_version < "3.9"')
'packagea[when="python<3.9.0a0"]'

Acknowledgements

I'm so grateful to have learned much about this topic from @jjhelmus. Together we created the original prototype for this concept several years ago, before conda had any support for conditional dependencies, optional dependencies (extras), or .whl support in repodata.json. The reroll codebase in a large sense is just an outgrowth of the original conda-whl-channel prototype to explore repodata conversion at scale.

This approach wouldn't be possible without conditional or optional support in conda, so cheers to everyone who pushed those CEP's over the line.

Reroll takes advantage of other community tooling to parse, translate, and validate pieces of data, including:

  • Rattler
  • uv
  • conda-lock
  • grayskull
  • parselmouth

The usage of these tools for this project has uncovered corner cases (or otherwise) in some of these tools, and I appreciate folks taking a look at the bug reports and PR's

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_reroll-0.1.1.tar.gz (55.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_reroll-0.1.1-py3-none-any.whl (75.7 kB view details)

Uploaded Python 3

File details

Details for the file py_reroll-0.1.1.tar.gz.

File metadata

  • Download URL: py_reroll-0.1.1.tar.gz
  • Upload date:
  • Size: 55.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for py_reroll-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d73997063de7937d8992e9c1327b605deeeda0d73e1d82c640f65b3b3012e7b6
MD5 eb69ca4dadf23b86ec4f54aefa9fe0a9
BLAKE2b-256 064de03b8da89285634e16869b6b9a06ab2d787c3b5603907922e5fa33f5f6cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_reroll-0.1.1.tar.gz:

Publisher: publish.yml on intentionally-left-nil/reroll

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_reroll-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: py_reroll-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 75.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for py_reroll-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 34b10393a5960a08831cae994c866d26cf44b5e12bf21ae968abdf6fb2ed624e
MD5 7c76df433e5eb0dcb26b5c6a3dd17674
BLAKE2b-256 2813bf4e301d35388a58cdc1e86b3fb64d43944835d0b22233eca2fab13da634

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_reroll-0.1.1-py3-none-any.whl:

Publisher: publish.yml on intentionally-left-nil/reroll

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page