G
G
GeraZlo2016-01-12 13:26:33
Python
GeraZlo, 2016-01-12 13:26:33

Should I add virtualenv to git?

Actually, for a faster and more convenient deployment, I decided to collect the entire environment in a virtualenv, is it worth throwing it into the git repository and is it generally legal? And if not, what are the best ways to use to synchronize the working environment with several working computers + server.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Andrey Shubin, 2016-01-12
@GeraZlo

It is better to write dependencies in requirements.txt and add this file to git.
An example of a file (you can specify versions through ==, you can without):

Django==1.8.5
django-flat-theme==1.1.1
mysql-python==1.2.5
gunicorn==19.4.1
pytz==2015.6
python-memcached==1.57
django-debug-toolbar==1.4

When cloning the repository to another computer or server, do (after creating and activating the necessary virtual environment):
Thus, you will install all the necessary packages at once.

S
Stanislav Pugachev, 2016-01-13
@Stqs

It often happens that some of the packages are needed during development and are not needed in production. And vice versa. Therefore, it would be desirable to separate the requirements for development and for production.
Requirements files can be included in one another. In this way, dependencies can usually be split into 3 separate files.
For example:
reqs/
- common.txt
- prod.txt
- dev.txt
common.txt will contain all required common dependencies. Ceiling example:

Django==1.8.5
mysql-python==1.2.5

dev.txt will contain packages specific to development only but including common. An example again from the ceiling:
-r common.txt
ipyhton
ipdb
django-debug-toolbar==1.4

prod.txt will also include common but will also contain things that are mandatory in production and not needed at all in your local environment:
-r common.txt
gunicorn==19.4.1
whateverelse=1.0.0

соответственно когда мы собираемся разрабатывать мы устанавливаем зависимости так
в продакшене
pip install -r reqs/prod.txt

Y
Yura Khlyan, 2016-01-12
@MAGistr_MTM

В директории с ГИТ-ом пропиши:
И в этой же директории будет создан файл с нужными пакетами. А потом как написал Андрей Шубин

G
GeraZlo, 2016-01-14
@GeraZlo Автор вопроса

Всем спасибо за ответы, вам удалось раскрыть проблему даже лучше чем я того ожидал.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question