Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipenv: Multiple Environments

Right now I'm using virtualenv and just switching over to Pipenv. Today in virtualenv I load in different environment variables and settings depending on whether I'm in development, production, or testingby setting DJANGO_SETTINGS_MODULE to myproject.settings.development, myproject.settings.production, and myproject.settings.testing.

I'm aware that I can set an .env file, but how can I have multiple versions of that .env file?

like image 283
aroooo Avatar asked Feb 27 '19 00:02

aroooo


Video Answer


1 Answers

You should create different .env files with different prefixes depending on the environment, such as production.env or testing.env. With pipenv, you can use the PIPENV_DONT_LOAD_ENV=1 environment variable to prevent pipenv shell from automatically exporting the .env file and combine this with export $(cat .env | xargs).

export $(cat production.env | xargs) && PIPENV_DONT_LOAD_ENV=1 pipenv shell would configure your environment variables for production and then start a shell in the virtual environment.

like image 96
A. J. Parr Avatar answered Sep 20 '22 23:09

A. J. Parr