Skip to content

Reproducible Python virtual environment using uv and nix #1387

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

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

yvan-sraka
Copy link
Contributor

This PR is a draft aimed at producing a reproducible Python virtual environment. uv seems like the right tool for this because it has a lock file mechanism (but we could alternatively use poetry), and nix would be my preferred choice for managing system dependencies (I’m not aware of many alternatives for pinning system dependencies, apart from possibly using a container with a pinned version of Alpine Linux?)

This is still a draft, the shell.nix is currently too convoluted (and ultimately I would like to rather rely on uv2nix), and the goal of this PR is to enable the use of this environment in GitHub Action jobs! Using this setup in CI would help avoid non-reproducible issues, such as this one.

n.b. that VLLM is currently broken on NixOS, debugging its derivation might be necessary at some point: nix-build /nix/var/nix/profiles/per-user/root/channels/nixos/ --run-env -A python3Packages.vllm

@yvan-sraka yvan-sraka requested a review from torymur January 22, 2025 10:50
@yvan-sraka yvan-sraka self-assigned this Jan 22, 2025
@yvan-sraka yvan-sraka force-pushed the reproducibility-with-nix-and-uv branch 2 times, most recently from d5c0359 to 91ca04e Compare January 30, 2025 16:08
@yvan-sraka yvan-sraka marked this pull request as ready for review January 30, 2025 16:08
@yvan-sraka yvan-sraka requested a review from rlouf January 30, 2025 16:08
@yvan-sraka yvan-sraka force-pushed the reproducibility-with-nix-and-uv branch from 91ca04e to a4442a3 Compare January 30, 2025 17:21
@yvan-sraka yvan-sraka marked this pull request as draft February 6, 2025 15:53
@rlouf
Copy link
Member

rlouf commented Feb 16, 2025

@yvan-sraka I see this was marked as a draft. Is it in a mergeable state?

@yvan-sraka
Copy link
Contributor Author

@yvan-sraka I see this was marked as a draft. Is it in a mergeable state?

You can merge it! I would have preferred to test it by making sure the tests pass first. I guess fixing the tests may require bumping dependencies, but that could be done in another PR. Also, I'm not 100% sure the Nix expression isn't missing anything since the tests didn't pass...

The sibling PR in outlines-core is finished, the tests pass, and the next step could be to integrate it into CI!

@rlouf rlouf marked this pull request as ready for review February 17, 2025 17:00
@rlouf rlouf merged commit ac49f57 into main Feb 17, 2025
7 checks passed
@rlouf rlouf deleted the reproducibility-with-nix-and-uv branch February 17, 2025 17:01
@maresb
Copy link

maresb commented Mar 3, 2025

Why was pre-commit added as a runtime dependency? This seems wrong.

@maresb
Copy link

maresb commented Mar 3, 2025

Ah, this was also mentioned in #1465

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.

3 participants