The context

I'm currently running a Gentoo desktop and want to move towards doing proper Python development on my system.

I have tried to install some packages, namely docker-compose, through the Gentoo's emerge system. Due to docker-compose's reliance on an older version of the requests module, my system updates became hairy and difficult to resolve.

I then switched to pip and followed a recommendation to use the --user flag for pip installs to avoid conflicts with the system-wide tools/libraries. I installed docker-compose at this user level and all was well until I added Pipenv to the mix for managing dependencies for individual projects. Pipenv doesn't like the --user flag and when set in the pip.conf file will refuse to install dependencies into its virtualenv.

getting to the point...

I would like a way to isolate the different levels of Python packages I need on my system. I would like to leave the system dependencies in place as they have been set by the Gentoo emerge tool, have a place to install tools and libraries that I want my primary user to have access to, and finally somewhere that I can store libraries that I need only for a specific project. As my machine has only a single user, I'm not worried so much about sharing the "user" dependencies between users, but ensuring that I can access them from any directory.

I have looked into virtualenvs, however it seems that that works better for a "per-project" level rather than a "user" level. From what I can tell, only one virtualenv can be active at a time, therefore if I install a tool like docker-compose in an always-active virtualenv from my home dir, then switch to a new virtualenv for a project, I will lose access to the docker-compose tool and anything else I have installed into the "user" level virtualenv.

In short, what options do I have to manage different "levels" of Python dependencies? What are the best practices to ensuring that I don't tread on my system dependencies from a user level and my user dependencies from a project level? What do you guys do to safely isolate these different levels, if you do it at all?

This is my first stackexchange post, so please let me know if I can clarify or improve this question. I have tried to do research beforehand, but feel as though I have come up short.

  • Something like chroot, namespace containers (systemd-nspawn) and/or virtual machines (KVM/qemu) could work, depending on the level of separation you need from the system OS. – Mioriin Aug 10 '18 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.