As the title says, what is the technically correct place to store Python virtual environments on Linux operating systems according to Linux FHS?
Another way is indicated that allows you to get a clear answer: Is it “technically correct” to separate the location of the Python virtual environment from the data files that you serve?
Note: This question is different from the closest, already asked question, which I could find , since virtual environments contain libraries, binaries, header files and scripts.
As an additional complication, I prefer to write code that supports services available on the Internet. However, I do not see this as a significant difference between my needs and scenarios in which service consumers are other processes on the same server. I mention this detail in case my comments replies include "web dev" content.
For reference, I use the following documentation as a Linux FHS definition: http://www.pathname.com/fhs/pub/fhs-2.3.html
I do not believe that the popular virtualenv-wrapper script offers the correct action, since by default it stores virtual environments in the user's home directory. This violates the implicit notion that the directory is intended for user files, as well as the assertion that “no program should rely on this location”.
From the root level of the file system, I lean towards /usr (general read-only data) or /srv (Data for the services provided by this system), but this is where I can hardly decide further.
If I agreed with the decision of my reverse proxy, that means /usr . Nginx is usually packaged to log in to / usr / share / nginx or / usr / local / nginx, however / usr / is supposed to be mounted read-only according to FHS . I find this strange because I never worked on one project in which development was so slow that "unmounting as soon as read / reboot with writing, unmounting / reloading as soon as read" was considered worthy of work.
/srv is another possible location, but is indicated as “location of data files for a specific service”, while the Python virtual environment is more oriented to libraries and binaries for what provides the service (without this differentiation, .so files will also be in srv) . In addition, several services with the same requirements can share a virtual environment that violates the “specific” details of the description.
I believe that part of the difficulty in choosing the right location is that the virtual environment is a “medium” that consists of binary files and libraries (almost like its own small hierarchy), which makes me feel like somewhere under /usr is more conditional:
virtual-env/ ├── bin ~= /usr/local : "for use by the system administrator when installing software locally" ├── include ~= /usr/include : "Header files included by C programs" ├── lib ~= /usr/lib : "Libraries for programming and packages" └── share ~= /usr/local
Based on my assumptions and thoughts: consider a common Nginx script acting as a reverse proxy for a Python application. Is it correct to place the virtual environment and source code (for example, application.py) under /usr/local/service_name/ when using /srv for files that change more often (for example, "static" assets, images, css)?
edit: To be clear: I know why and how to use virtualenvs. I am in no way confused with the layout of the project or working in a development environment.