Here is my problem, I am trying to make an application which copies data files during its setup. When i am doing pip install the setup copies a few files to a directory.
Now my question is, When inside a virtual environment, what is the behaviour that the customer expects- does he want all the created data files inside the virtual environment directory for each virtualenv or copy all the files into a common directory outside the virtual environment directory.
While running the application there will be new files that will be created and stored along these copied files. What is the ideal behaviour that is expected form a python virtualenv. common or isolated?

- 1
- 1
-
A virtual environment is usually interpreted as a sandboxed environment where you do not reach outside. – poke May 29 '17 at 11:48
2 Answers
virtualenv is more for development, not for deployment. There are many scenarios to deploy Python app. but if you prefer virtualenv usage and you have common files, they can be anywhere IMHO, because virtualenv is not real isolation, it's only Python paths mangling/modification mechanism (not like "chroot"), so you decide where to place your common files, even /usr/share/my-app-1.0/datafiles/. Also, virtualenv is used to isolate binaries/scripts, but if data files are static, you can place them when you prefer.

- 3,367
- 19
- 30
In my opinion, that depends on application, which you create. Virtualenv is just way of running on same machine multiple applications with different dependencies. Data from applications is another thing.
When I would write web application, that will be single app on server, then I would use one directory.
On the other hand, when I would write GUI app, then things get different. If data is something that must be changed with every version, but end user does not touch it directly (e.g. some dictionaries, translation, etc) I would put it in dist-packages along the application package (see package data in setup.py). On the other hand, if user can "touch" and use those files, then I would put them in users home directory. See How to find the real user home directory using python?

- 2,649
- 24
- 32
-
There are 2 options for me either create data files inside the virtualenv directory or a common on user home directory. The user can totally add and customize the old files as per need. In this scenario, with multiple users do you think keeping all the data files in a single directory will be a good idea? – Jasminder Sidhu May 30 '17 at 06:44