{ "info": { "author": "Jacob Wasserman", "author_email": "jwasserman@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "======\nenviro\n======\n\nSimple Python module and IPython extension for setting OS environment variables from config files.\n\n.. image:: https://travis-ci.org/jwass/enviro.svg?branch=master\n :target: https://travis-ci.org/jwass/envior\n\nIn web app and software-as-a-service development, it is widely considered best programming practice to separate application code from its configuration. Temporary or sensitive values such as authorization credentials, database handles, and keys to other services should reside in a separate file, never as part of the code repository. The application code should read these values from OS environment variables, which are set by the execution environment. Tools like foreman and honcho read environment files - lines containing key=value settings - and update the OS environment prior to running the server, workers, etc.\n\nThis practice should be extended to analysis and interactive environments. Not only is it a good idea to separate config values from the code, but analysis tools often need to be configured from the same source as a deployment, for debugging or other analysis.\n\n``enviro`` (pronounced en-vye-ro) is a simple Python module and IPython extension that can set OS environment variables `os.environ` from environment files.\n\nUsage\n=====\nSimply import ``enviro`` and call ``conf()``. By default it reads ``.env``:\n\n.. code-block:: python\n\n import enviro\n enviro.conf() # Load contents of .env into os.environ\n\nA different file may be specified:\n\n.. code-block:: python\n\n enviro.conf('production.env')\n\n\nIPython Extension\n=================\n``enviro`` also provides an IPython extension so that it is always easily available as a line magic function without the need to import:\n\n.. code-block::\n\n $ ipython\n In [1]: %enviro\n\nAs above, it reads ``.env`` in the current directory by default, but an alternate file can be specified on the line:\n\n.. code-block::\n\n In [1]: %enviro production.env\n\n\nExample\n=======\n``.env`` in the current directory has the following contents:\n\n::\n\n SERVICE_API_KEY = abc123\n SERVICE_API_SECRET = def456\n DATABASE_URI = postgres://user:password@host/dbname\n\n\n.. code-block:: python\n\n >>> import enviro\n >>> import os\n\n >>> enviro.conf()\n >>> os.environ['SERVICE_API_KEY']\n 'abc123'\n >>> os.environ['SERVICE_API_SECRET']\n 'def456'\n >>> os.environ['DATABASE_URI']\n 'postgres://user:password@host/dbname'\n\nInstallation\n============\nThe easiest way to install is to use ``pip``.\n\n.. code-block::\n\n pip install enviro\n\nTo load the IPython extension every time IPython starts, add `'enviro_ipy_ext'` to the extensions in your IPython config file (usually `~/.ipython/profile_default/ipython_config.py`):\n\n.. code-block:: python\n\n c.InteractiveShellApp.extensions = [\n 'enviro_ipy_ext',\n ]\n\nand\n\n.. code-block:: python\n\n c.TerminalIPythonApp.extensions = [\n 'enviro_ipy_ext',\n ]\n\nTo load the IPython extension without modifying your ``ipython_config.py`` you can run ``%load_ext enviro_ipy_ext`` to expose the ``%enviro`` magic function, although that's just as easy as importing it directly so best to add it to your config and avoid this step.\n\nSee also\n========\n* `The Twelve-Factor App `__ (particularly the Config section)\n* `Using IPython extensions `__\n* `heroku-config plugin `__\n* `autoenv `__", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jwass/enviro", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "enviro", "package_url": "https://pypi.org/project/enviro/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/enviro/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/jwass/enviro" }, "release_url": "https://pypi.org/project/enviro/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "Simple configuration of OS environment variables", "version": "0.0.2" }, "last_serial": 1435266, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "1a057d3964119abcf7a9abba0aea8e26", "sha256": "7d5c53161d98b95ca1ae2b072d8007f672b3f4cb439f025024521cd8ac9142ac" }, "downloads": -1, "filename": "enviro-0.0.1.tar.gz", "has_sig": false, "md5_digest": "1a057d3964119abcf7a9abba0aea8e26", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3478, "upload_time": "2014-12-30T06:44:27", "url": "https://files.pythonhosted.org/packages/0e/b7/f337a10a71229c207a2ca0eaedf43a494e7b704c494452a5436dc0d40b38/enviro-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "9aa60238ce6d20ee59520d705ceb7f4d", "sha256": "04c8b909a45879f2ca7aa5c3e085e602442ca15d03732c7cece73fc59112aaf6" }, "downloads": -1, "filename": "enviro-0.0.2.tar.gz", "has_sig": false, "md5_digest": "9aa60238ce6d20ee59520d705ceb7f4d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3547, "upload_time": "2015-02-23T20:17:47", "url": "https://files.pythonhosted.org/packages/6f/fb/216bfc578194e3365f97532eb6f39eb5fe24d54348036f2e1bbe6cf48a31/enviro-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9aa60238ce6d20ee59520d705ceb7f4d", "sha256": "04c8b909a45879f2ca7aa5c3e085e602442ca15d03732c7cece73fc59112aaf6" }, "downloads": -1, "filename": "enviro-0.0.2.tar.gz", "has_sig": false, "md5_digest": "9aa60238ce6d20ee59520d705ceb7f4d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3547, "upload_time": "2015-02-23T20:17:47", "url": "https://files.pythonhosted.org/packages/6f/fb/216bfc578194e3365f97532eb6f39eb5fe24d54348036f2e1bbe6cf48a31/enviro-0.0.2.tar.gz" } ] }