edit thanks @adisbladis
Check out this project if you want to import arbitrary python packages on the fly https://github.com/t184256/nixpkgs-python-importer
usage for now until in unstable
nix-shell -I 'nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz' -p 'python3.withPackages(ps: with ps; [ ps.nixpkgs ps.ipython ])' --run 'ipython'
if you are looking at this much later use
nix-shell -p 'python3.withPackages(ps: with ps; [ ps.nixpkgs ps.ipython ])' --run 'ipython'
So crazy idea here of something I have wanted in python (and want to implement) that I feel that nixpkgs may be able to make possible. Suppose we have a python with no packages installed only stdlib. I would like to write the following and override the import statement such that it calls nixpkgs to download the package if it does not exist. Completely fine with partial answers and solutions that are hacks.
import numpy as np np.array([1, 2, 3, 4])
In python it is possible to add import hooks to the “import” statement. It would try to import numpy and return an import error which would be caught and it would be fed off to call nixpkgs to add numpy to the environment via PYTHONPATH
python37Packages.numpy for example.
Is something like this possible? I realize that in order for this to work the PYTHONPATH and PATH environment variables but not sure if others as well.