rattler
rattler copied to clipboard
py-rattler: add support for mirror middleware
Checklist
- [X] I added a descriptive title
- [X] 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