6
you are viewing a single comment's thread
view the rest of the comments
[-] logging_strict@programming.dev 1 points 3 weeks ago* (last edited 3 weeks ago)

Finally got to a Python question

On Nix(OS) can i setup a python development environment from requirements files without ruffling the package managers feathers?

When ready to create a wheel, python -m build, how does Nix(OS) want the python package to be built to gain all the benefits of Nix(OS) build reproducibility?

[-] ruffsl@programming.dev 2 points 3 weeks ago* (last edited 3 weeks ago)

If you just want to quickly create a local python develop environment on the side using Python module metadata, installing uv from nixpkgs, and enabling nix-ld to run pre-compiled binaries from PyPI keeps things simple, and replicating the same virtual python environment workflow you to have on any other distribution:

https://discourse.nixos.org/t/i-want-understanding-nix-packages-and-flake-basics/67365/3

If you wanted to package a python module for nix or for proper distribution via nixpkgs, you'd want to add a nix derivation file that encapsulates all the inputs, i.e. software building materials (SBOM). There are existing nix library functions that can automate most of the packaging, not unlike Debian macros:

https://wiki.nixos.org/wiki/Python

The second approach is more rigorous, and combined with something like flakes for pinning the exact hash for all inputs via lock file ensures reproducibility, like when sharing with other nix users. While as the first approach is more subject to your current system, i.e. linking to whatever system wide libraries are presently installed, but it's less upfront effort to reuse existing python-package-managers than to nixify everything.

this post was submitted on 31 Jul 2025
6 points (100.0% liked)

Python

7406 readers
1 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS