Package: runenv
Wrapper to run programs with modified environment variables loaded from given file. You can userunenvto manage your
app settings using12-factorprinciples.You can use same environment file withrunenvand withdockerusingenv-fileparameterFree software: BSD licenseDocumentation:https://runenv.readthedocs.org.FeaturesCLI:command-line tool to load environment variables from given filePython API:load variables from a file (.envor passed filename)load only variables with givenprefixprefixcan be stripped during loaddetect whether environment was loaded byrunenvCLIforce load even ifrunenvCLI was usedsearch_parentoption which allows to look forenv_filein parent dirsInstallationIn order to install usepip$pipinstall-UrunenvUsageRun from shell$runenvenv.development./manage.pyrunserverexampleenv.developmentfileBASE_URL=http://127.0.0.1:8000DATABASE_URI=postgres://postgres:password@localhost/dbnameSECRET_KEY=y7W8pbRcuPuAmgTHsJtEpKocb7XPcV0u# email settingsEMAIL_HOST=smtp.mandrillapp.comEMAIL_PORT=587EMAIL_HOST_USER=someuserEMAIL_HOST_PASSWORD=hardpasswordEMAIL_FROM=dev@local.hostEMAIL_USE_TLS=1Python APIload_env(env_file=’.env’, prefix=None, strip_prefix=True, force=False, search_parent=0)Loads environment from givenenv_file`(default.env).Options:optiondefaultdescriptionenv_file.envrelative or absolute path to file with environment variablesprefixNoneprefix to match variables e.g.APP_strip_prefixTrueshould the prefix be stripped during loaforceFalseload env_file, even thoughrunenvCLI command was usedsearch_parent0To what level traverse parents in search of fileIfprefixoption is provided only variables starting with it will be loaded to environment, with their keys stripped of that prefix. To preserve prefix, you can setstrip_prefixtoFalse.Example$echo'APP_SECRET_KEY=bzemAG0xfdMgFrHBT3tJBbiYIoY6EeAj'>.env$python>>>importos>>>fromrunenvimportload_env>>>load_env(prefix='APP_')>>>'APP_SECRET_KEY'inos.environFalse>>>'SECRET_KEY'inos.environTrue>>>load_env(prefix='APP_',strip_prefix=False)>>>'APP_SECRET_KEY'inos.environTrueNotice: Environment will not be loaded if command was fired byrunenvwrapper, unless you set theforceparameter toTrueload_envdoes not load variables when wrapperrunenvis used. Also_RUNENV_WRAPPEDis set to1Example$echo'APP_SECRET_KEY=bzemAG0xfdMgFrHBT3tJBbiYIoY6EeAj'>.env$python>>>importos>>>fromrunenvimportload_env>>>os.environ['_RUNENV_WRAPPED']='1'>>>load_env()>>>'APP_SECRET_KEY'inos.environFalse>>>load_env(force=True)>>>'APP_SECRET_KEY'inos.environTrueDjango/Flask integrationTo useload_envwithDjangoorFlask, put the followin inmanage.pyandwsgi.pyfromrunenvimportload_envload_env()Similar projectshttps://github.com/jezdez/envdir- runs another program with a modified environment according to files in a specified directoryhttps://github.com/theskumar/python-dotenv- Reads the key,value pair from .env and adds them to environment variableHistory1.0.1 (2017-02-03)fix package description syntax1.0.0 (2017-02-03)changed version to1.0.00.4.0 (2016-08-08)add support forsearch_parentoption0.3.1 (2016-06-21)add support for quoted values0.3.0 (2016-02-14)changeDevelopment Statusto5 - Production/Stable0.2.5 (2015-11-30)do not look for executable as absolute path0.2.4 (2015-07-06)skipload_envif env file does not exists0.2.3 (2015-06-26)support to run programs from PATH0.2.2 (2015-06-16)fix compatibility with python30.2.1 (2015-06-16)addstrip_prefixoption toload_env0.2.0 (2015-06-16)addload_env(python api)0.1.4 (2015-06-15)Check if file to run exists and is executable0.1.3 (2015-06-01)Support for env file comments by ‘#’0.1.2 (2015-06-01)Return code from runned command0.1.1 (2015-05-31)First release on PyPI.