Use python-dotenv for environment variables.

PyCharm did not load conda environment variables.
communication
junos 2020-12-24 14:03:36 +01:00
parent 471aca4587
commit 9711c1b202
3 changed files with 5 additions and 24 deletions

1
.gitignore vendored 100644
View File

@ -0,0 +1 @@
/.env

View File

@ -20,29 +20,9 @@ To install:
conda activate straw2analysis conda activate straw2analysis
``` ```
2. Follow [the instructions](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#saving-environment-variables) to set DB_PASSWORD as the environment variable. 2. Provide an .env file to be used by `python-dotenv` which should be placed in the top folder of the application
and should have the form:
In short, use:
```shell
cd $CONDA_PREFIX
mkdir -p ./etc/conda/activate.d
mkdir -p ./etc/conda/deactivate.d
touch ./etc/conda/activate.d/env_vars.sh
touch ./etc/conda/deactivate.d/env_vars.sh
``` ```
and then edit `./etc/conda/activate.d/env_vars.sh` as follows: DB_PASSWORD=database-password
```bash
#!/bin/sh
export DB_PASSWORD='database-password'
```
and `./etc/conda/deactivate.d/env_vars.sh` as follows:
```bash
#!/bin/sh
unset DB_PASSWORD
``` ```