Dockertools image with Python-dependencies support

Hi folks, I am building a Docker image with dockerTools. It contains Python packages.

However, while the resulting image does contain the Python libraries I am looking for (i.e. it has the files in the nix store) I can’t import the Python libraries as ususal. For example import requests will fail. This is in contrast to my (non docker) usage of nix-shell where I can simply import the package after getting a shell for the package name.

Does anyone know how to make it work in Docker? Can’t find anything on Google.

I have tried adding lib to pathsToLink. This makes it so that the Python packages directly mentioned make it into the global site-packages.

In contrast, using nix shell seems to put every single dependency into the PYTHONPATH environment variable. It seems to me that this is the behaviour I would need to replicate to get to the desired results.

For reference if someone is looking for this: I had somewhat misunderstood the way you’re supposed to use this. Just let the build link a Python script to e.g. /bin. Nix will prefix that script in such a way that the dependencies are available from within the script using aito-generated import statements.

Therefore, no need to have all the Python packages available globally. I still kind of hate this approach but it works.