12👍
If you run one vagrant VM per project, then there is no direct reason to use virtualenv.
If other contributors do not use vagrant, but do use virtualenv, then you might want to use it and support it to make their lives easier.
31👍
As Devin stated, it is not necessary to use virtualenv
when you deploy to a vagrant machine as long as you are the sole user of the machine. However, I would still enable the use of a virtualenv
, setup.py, etc. even if you do not use it for development or deployment.
In my (not so) humble opinion, any Python project should:
- Include a .cvsignore, .gitignore, .hgignore, … file that ignores the common Python intermediate files as well as
virtualenv
directories. - A requirements.txt file that lists the required packages in a pip-compliant format
-
Include a Makefile with the following targets:
- environment: create the virtual environment using
virtualenv
orpyvenv
- requirements: install required packages using
pip
and the requirements.txt file - develop: run
setup.py develop
using the virtual environment - test: run
setup.py test
- clean: remove intermediate files, coverage reports, etc.
- maintainer-clean: remove the virtual environment
The idea is to keep the Makefile as simple as possible. The dependencies should be set up so that you can clone the repository (or extract the source tarball) and run
make test
. It should create a virtual environment, install the requirements, and run the unit tests. - environment: create the virtual environment using
You can also include a Vagrantfile and a vagrant target in the Makefile that runs vagrant up. Add a vagrant destroy
to the maintainer-clean target while you are at it.
This makes your project usable by anyone that is using vagrant or developing without it. If (when) you need to use deploy alongside another project in a vagrant or physical environment, including a clean setup.py and a Vagrantfile that describes your minimal environment makes it simple to install into a virtual environment or a shared vagrant machine.
- [Django]-Storing an Integer Array in a Django Database
- [Django]-Convert an IP string to a number and vice versa
- [Django]-Error: "dictionary update sequence element #0 has length 1; 2 is required" on Django 1.4
9👍
Virtualenv and other forms of isolation (Docker, dedicated VM, …) are not necessarily mutually exclusive. Using virtualenv is still a good idea, even in an isolated environment, to shield the virtual system Python from your project packages. *nix systems use plethora of Python based utilities dependent on specific versions of packages being available in system Python and you don’t want to mess with these.
Mind that virtualenv can still only go as far as pure Python packages and doesn’t solve the situation with native extensions that will still mix with the system.
- [Django]-Filter Django database for field containing any value in an array
- [Django]-Displaying graphs/charts in Django
- [Django]-How to clear the whole cache when using django's page_cache decorator?