Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py-rattler: add support for mirror middleware #859

Open
2 tasks done
pavelzw opened this issue Sep 10, 2024 · 0 comments
Open
2 tasks done

py-rattler: add support for mirror middleware #859

pavelzw opened this issue Sep 10, 2024 · 0 comments

Comments

@pavelzw
Copy link
Contributor

pavelzw commented Sep 10, 2024

Checklist

  • I added a descriptive title
  • I searched open requests and couldn't find a duplicate

What is the idea?

Both pixi and rattler-build allow you to specify mirrors: https://pixi.sh/latest/reference/pixi_configuration/#mirror-configuration

It would be nice if we could have this feature exposed in py-rattler as well.

Why is this needed?

We currently have a python script that installs a pixi.lock file into a custom prefix (as pixi only installs into .pixi/envs/default).
It would be nice to have this working with mirror configuration as well.

The following example currently doesn't do this but maybe adding it to AuthenticatedClient could be a way forward.

#!/usr/bin/env -S pixi exec --spec py-rattler --spec typer -- python

import asyncio
from pathlib import Path

from rattler import install as rattler_install
from rattler import LockFile, Platform
from rattler.networking.authenticated_client import AuthenticatedClient
import typer


app = typer.Typer()


async def _install(
    lock_file_path: Path,
    environment_name: str,
    platform: Platform,
    target_prefix: Path,
) -> None:
    lock_file = LockFile.from_path(lock_file_path)
    environment = lock_file.environment(environment_name)
    records = environment.conda_repodata_records_for_platform(platform)
    await rattler_install(
        records=records,
        target_prefix=target_prefix,
        client=AuthenticatedClient(),
    )


@app.command()
def install(
    lock_file_path: Path = Path("pixi.lock").absolute(),
    environment_name: str = "default",
    platform: str = str(Platform.current()),
    target_prefix: Path = Path("env").absolute(),
):
    asyncio.run(
        _install(
            lock_file_path=lock_file_path,
            environment_name=environment_name,
            platform=Platform(platform),
            target_prefix=target_prefix,
        )
    )


if __name__ == "__main__":
    app()

What should happen?

No response

Additional Context

No response

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

No branches or pull requests

1 participant