I’m trying to create a python derivation of a GitHub project that uses a setup.py.
The issue is that it uses dependencies that are a lot newer than the one’s nix offers. What is the correct way to install them? Is there a best practice?
The only option I can think of is to create derivations for each dependency and sub dependency until I got everything the application requires.
The main options for using non-nixpkgs python module versions are Mach-nix: Create python environments quick and easy or poetry2nix, and pypi2nix. You could also make an overlay in your nix-shell and override the python module versions to match the requirements.txt, but I would check out one of the above tools.
That reminds me that it would be cool if there was a buildPythonApplication equivalent function in mach-nix which automatically extracts requirements from setup.py / setup.cfg and so on. I put it on my list
I usually make overlays using python-package-init for the packages I need. It seems like the fastest way to add the new versions to the default environment.
That’s super cool!
The only problem with regexing the setup.py is that there are too many possibilities which are difficult to cover. Some projects load the requirements from another file or generate them via some strange methods.
I’ve already written some reliable setuptools dependency extractor for the crawlers for mach-nix. It could be reused for buildPythonApplication.
The downside with this extractor: Because it requires some patches for python builtins, it currently needs a rebuild of the whole python interpreter. This would be a bad user experience. Maybe there is a way of patching the python builtin .pyc files without rebuilding the whole thing.