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

Add support for pip/virtualenv environments #55

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

akx
Copy link
Contributor

@akx akx commented Jul 24, 2024

The main meat of this PR is PipInstall, a sibling of CondaInstall that runs venv (or uv venv) and pip install (or uv pip install) to install requirements from requirements.txt files.

The base image needs to have a python3 on PATH for this to work at all, of course.

As alluded to above, this also includes support for the uv package installer as a faster alternative to pip; this is enabled by the currently-undocumented COTAINR_USE_UV environment variable being set to a non-empty value.

All tests, old and new, pass locally (using a dockerized singularity since I'm on a Mac).

@akx akx force-pushed the pip branch 2 times, most recently from a6cd6cd to c430f1a Compare July 25, 2024 07:01
@akx akx changed the title Add PipInstall Add support for pip/virtualenv environments Jul 25, 2024
@eskech
Copy link
Contributor

eskech commented Jul 30, 2024

Just a short comment. @Chroxvi is on vacation and is back in two weeks. I really want him to do the review. Sorry for letting you wait until he is back.

@akx
Copy link
Contributor Author

akx commented Aug 26, 2024

Gentle nudge (as I too am back from vacation) :)

@Chroxvi Chroxvi self-assigned this Aug 27, 2024
@Chroxvi Chroxvi added the enhancement New feature or request label Aug 27, 2024
@akx
Copy link
Contributor Author

akx commented Sep 11, 2024

Rebased post #56.

@akx akx mentioned this pull request Oct 6, 2024
@Chroxvi
Copy link
Contributor

Chroxvi commented Oct 7, 2024

Admittedly, adding support for additional conda/pip package managers in cotainr is pretty far down the line on our roadmap since:

  • We should already be able to serve all conda/pip use cases via our current conda/mamba setup.
  • The alternative pip/conda package managers of interest (uv and pixi, mostly, I think) are still in the process of maturing, so we don't know exactly what we are trying to support long term.
  • We are a fairly small development team so:
    1. We are a bit concerned about committing to a larger maintenance burden.
    2. We would generally like to prioritize enabling other use cases (e.g. R package management) over implementing alternatives way to handle conda/pip packages.

That being said, we are still open to implementing support for uv, if it enables some significant use cases - after all the cotainr development is driven by requests for support for various use cases.

@akx, picking up on your comment in #68 (comment) stating that you would be using cotainr on LUMI if this PR #55 was merged, what is your main motivation for wanting uv over the current conda/mamba implementation in cotainr that allows you to install pip packages by adding them to your conda_env.yml file as show in e.g. the cotainr LUMI PyTorch example? (You can even directly include requirements.txt in the conda_env.yml.) Are you looking for a faster environment installer? Or a better dependency solver than pip? Or something else?

I think it is likely that conda/mamba at some point is going to be replaced by pixi (which uses rattler for installing conda packages and uv for installing pip packages) or uv (if at some point it implements support for conda packages which I believe is essential to the Scientific Python community). Even though it appears that pixi can be used as a direct replacement for conda/pip, it still has a slightly different design philosophy around managing projects and not just environments making it somewhat odd to integrate into cotainr. @akx Do you have any opinion about pros/cons of integrating cotainr with pixi and using it's uv integration over directly interfacing with uv?

@akx
Copy link
Contributor Author

akx commented Oct 8, 2024

Admittedly, adding support for additional conda/pip package managers in cotainr is pretty far down the line on our roadmap

To be clear, the primary thing this PR adds support for is vanilla standard Python virtualenvs, i.e. not using Conda/Mamba distributions.

uv support here is an experimental option, and it's really only just replacing python -m venv with uv venv and python -m pip with uv pip.

What is your main motivation for wanting uv over the current conda/mamba implementation in cotainr that allows you to install pip packages by adding them to your conda_env.yml file [...]

The reason I wrote this was that I don't know (or care, to be honest) much about Conda-based distributions (and I've had my share of headaches troubleshooting customer Conda images over at $dayjob (@valohai)). I wanted a simpler option, when you have e.g. a standard pyproject.toml based project (e.g. by way of -e . in a requirements file) or a requirements.txt that you just want to use without having to write a YAML file or, well, deal with Conda/Mamba. As a side effect, you won't be required to accept the Miniforge license terms with this method...

Are you looking for a faster environment installer? Or a better dependency solver than pip? Or something else?

Again, uv support for making installation faster and resolution more stable is a side effect in this PR. This does not use uv's project management features that'd use uv.lock, etc.

Do you have any opinion about pros/cons of integrating cotainr with pixi and using it's uv integration over directly interfacing with uv?

I hadn't heard of Pixi before, again because I don't keep tabs on the Conda/Mamba world. No opinion.

@akx
Copy link
Contributor Author

akx commented Feb 8, 2025

Rebased, though some tests now fail.

@joasode, @Chroxvi, will there be a chance this will be reviewed and/or merged if it's green? (This PR has been open for 6 months now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants