Skip to content

Mirror conda packages - #593

Merged
andrew merged 2 commits into
git-pkgs:mainfrom
simonchrz:feat/mirror-conda
Oct 25, 2026
Merged

andrew merged 2 commits into
git-pkgs:mainfrom
simonchrz:feat/mirror-conda

Conversation

@simonchrz

Copy link
Copy Markdown
Contributor

Part of #414. Builds on #592; the first commit is that PR.

A conda version is mirrored with every build anaconda.org lists for it. Each build is cached under the key /conda/{channel}/{subdir}/{file} reads, so conda and pixi get it from the cache.

  • The channel comes from the namespace (pkg:conda/conda-forge/numpy@2.1.0) or the channel qualifier. A package without one is refused, as retention keys without one are.
  • subdir, build and type select builds, e.g. ?subdir=linux-64&type=conda.
  • Builds with a listed sha256 are checked against it. Older builds that only have an MD5 are fetched unchecked, as the conda handler fetches them.
  • Files are listed from anaconda.org, so with a custom upstream.conda mirroring conda fails with a message saying so. The old message said "give a version", which doesn't help here.

Which files a version has, which qualifiers select them and where the handler caches them is now described per ecosystem in internal/mirror/files.go, so PyPI and conda share mirrorFiles.

Tested through the mirror and the conda handler with the upstream closed (internal/server/mirror_conda_test.go). Against anaconda.org I mirrored pkg:conda/conda-forge/tomli@2.0.1 and pkg:conda/zstandard@0.23.0?channel=conda-forge&subdir=osx-arm64 (24 builds), then served both from the cache with upstream.conda unreachable; the sha256 matched anaconda.org's.

Mirroring a PyPI version passed each file's sha256 as the integrity
GetOrFetchArtifactFromURLWithIntegrity records with the version. Wheels of
one version share the name and version they are cached under, so the last
file's checksum replaced the others', and serving the other wheels from
the cache failed the integrity check.

The mirror now passes the sha256 as a digest, which is checked against
that file's content hash alone.
A conda version is mirrored with every build anaconda.org lists for it,
each cached under the channel, name, version and subdir/filename the conda
download handler reads from its path. The channel comes from the namespace
or the channel qualifier; a package without one is refused, as retention
keys without one are. The subdir, build and type qualifiers select builds.

Which files a version has, which qualifiers select them and where the
handler caches them is now described per ecosystem, so PyPI and conda share
mirrorFiles.

Part of git-pkgs#414.
@andrew
andrew merged commit b5b36dc into git-pkgs:main Oct 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ Proxy