METADATA 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. Metadata-Version: 2.0
  2. Name: python-dotenv
  3. Version: 0.7.1
  4. Summary: Add .env support to your django/flask apps in development and deployments
  5. Home-page: http://github.com/theskumar/python-dotenv
  6. Author: Saurabh Kumar
  7. Author-email: me+github@saurabh-kumar.com
  8. License: UNKNOWN
  9. Description-Content-Type: UNKNOWN
  10. Keywords: environment variables,deployments,settings,env,dotenv,configurations,python
  11. Platform: UNKNOWN
  12. Classifier: Development Status :: 5 - Production/Stable
  13. Classifier: Programming Language :: Python
  14. Classifier: Programming Language :: Python :: 2
  15. Classifier: Programming Language :: Python :: 2.7
  16. Classifier: Programming Language :: Python :: 3
  17. Classifier: Programming Language :: Python :: 3.0
  18. Classifier: Programming Language :: Python :: 3.1
  19. Classifier: Programming Language :: Python :: 3.2
  20. Classifier: Programming Language :: Python :: 3.3
  21. Classifier: Programming Language :: Python :: 3.4
  22. Classifier: Programming Language :: Python :: 3.5
  23. Classifier: Programming Language :: Python :: Implementation :: PyPy
  24. Classifier: Intended Audience :: Developers
  25. Classifier: Intended Audience :: System Administrators
  26. Classifier: License :: OSI Approved :: BSD License
  27. Classifier: Operating System :: OS Independent
  28. Classifier: Topic :: System :: Systems Administration
  29. Classifier: Topic :: Utilities
  30. Classifier: Environment :: Web Environment
  31. Requires-Dist: click (>=5.0)
  32. ::
  33. _______ .__ __. ____ ____
  34. | ____|| \ | | \ \ / /
  35. | |__ | \| | \ \/ /
  36. | __| | . ` | \ /
  37. __ | |____ | |\ | \ /
  38. (__)|_______||__| \__| \__/
  39. python-dotenv | |Build Status| |Coverage Status| |PyPI version| |PyPI|
  40. ======================================================================
  41. Reads the key,value pair from ``.env`` and adds them to environment
  42. variable. It is great of managing app settings during development and in
  43. production using `12-factor <http://12factor.net/>`__ principles.
  44. Do one thing, do it well!
  45. - `Usages <#usages>`__
  46. - `Installation <#installation>`__
  47. - `Command-line interface <#command-line-interface>`__
  48. - `iPython Support <#ipython-support>`__
  49. - `Setting config on remote servers <#setting-config-on-remote-servers>`__
  50. - `Related Projects <#releated-projects>`__
  51. - `Contributing <#contributing>`__
  52. - `Changelog <#changelog>`__
  53. Usages
  54. ======
  55. Assuming you have created the ``.env`` file along-side your settings
  56. module.
  57. ::
  58. .
  59. ├── .env
  60. └── settings.py
  61. Add the following code to your ``settings.py``
  62. .. code:: python
  63. # settings.py
  64. from os.path import join, dirname
  65. from dotenv import load_dotenv
  66. dotenv_path = join(dirname(__file__), '.env')
  67. load_dotenv(dotenv_path)
  68. # OR, the same with increased verbosity:
  69. load_dotenv(dotenv_path, verbose=True)
  70. Alternatively, you can use ``find_dotenv()`` method that will try to find a
  71. ``.env`` file by (a) guessing where to start using ``__file__`` or the working
  72. directory -- allowing this to work in non-file contexts such as IPython notebooks
  73. and the REPL, and then (b) walking up the directory tree looking for the
  74. specified file -- called ``.env`` by default.
  75. .. code:: python
  76. from dotenv import load_dotenv, find_dotenv
  77. load_dotenv(find_dotenv())
  78. You can also set _load_dotenv_ to override existing variables:
  79. .. code:: python
  80. from dotenv import load_dotenv, find_dotenv
  81. load_dotenv(find_dotenv(), override=True)
  82. Now, you can access the variables either from system environment
  83. variable or loaded from ``.env`` file. **System environment variables
  84. gets higher precedence** and it's advised not to include it in version control.
  85. .. code:: python
  86. # settings.py
  87. SECRET_KEY = os.environ.get("SECRET_KEY")
  88. DATABASE_PASSWORD = os.environ.get("DATABASE_PASSWORD")
  89. ``.env`` is a simple text file. With each environment variables listed
  90. per line, in the format of ``KEY="Value"``, lines starting with `#` is
  91. ignored.
  92. .. code:: shell
  93. SOME_VAR=someval
  94. # I am a comment and that is OK
  95. FOO="BAR"
  96. ``.env`` can interpolate variables using POSIX variable expansion, variables
  97. are replaced from the environment first or from other values in the ``.env``
  98. file if the variable is not present in the environment. (``Note``: Default Value
  99. Expansion is not supported as of yet, see `#30 <https://github.com/theskumar/python-dotenv/pull/30#issuecomment-244036604>`__.)
  100. .. code:: shell
  101. CONFIG_PATH=${HOME}/.config/foo
  102. DOMAIN=example.org
  103. EMAIL=admin@${DOMAIN}
  104. Django
  105. ------
  106. If you are using django you should add the above loader script at the
  107. top of ``wsgi.py`` and ``manage.py``.
  108. Installation
  109. ============
  110. ::
  111. pip install -U python-dotenv
  112. Command-line interface
  113. ======================
  114. A cli interface ``dotenv`` is also included, which helps you manipulate
  115. the ``.env`` file without manually opening it. The same cli installed on
  116. remote machine combined with fabric (discussed later) will enable you to
  117. update your settings on remote server, handy isn't it!
  118. ::
  119. Usage: dotenv [OPTIONS] COMMAND [ARGS]...
  120. This script is used to set, get or unset values from a .env file.
  121. Options:
  122. -f, --file PATH Location of the .env file, defaults to .env
  123. file in current working directory.
  124. -q, --quote [always|never|auto]
  125. Whether to quote or not the variable values.
  126. Default mode is always. This does not affect
  127. parsing.
  128. --help Show this message and exit.
  129. Commands:
  130. get Retrive the value for the given key.
  131. list Display all the stored key/value.
  132. set Store the given key/value.
  133. unset Removes the given key.
  134. iPython Support
  135. ---------------
  136. You can use dotenv with iPython. You can either let the dotenv search for .env with `%dotenv` or provide the path to .env file explicitly, see below for usages.
  137. ::
  138. %load_ext dotenv
  139. # Use find_dotenv to locate the file
  140. %dotenv
  141. # Specify a particular file
  142. %dotenv relative/or/absolute/path/to/.env
  143. # Use _-o_ to indicate override of existing variables
  144. %dotenv -o
  145. # Use _-v_ to turn verbose mode on
  146. %dotenv -v
  147. Setting config on remote servers
  148. --------------------------------
  149. We make use of excellent `Fabric <http://www.fabfile.org/>`__ to
  150. acomplish this. Add a config task to your local fabfile, ``dotenv_path``
  151. is the location of the absolute path of ``.env`` file on the remote
  152. server.
  153. .. code:: python
  154. # fabfile.py
  155. import dotenv
  156. from fabric.api import task, run, env
  157. # absolute path to the location of .env on remote server.
  158. env.dotenv_path = '/opt/myapp/.env'
  159. @task
  160. def config(action=None, key=None, value=None):
  161. '''Manage project configuration via .env
  162. e.g: fab config:set,<key>,<value>
  163. fab config:get,<key>
  164. fab config:unset,<key>
  165. fab config:list
  166. '''
  167. run('touch %(dotenv_path)s' % env)
  168. command = dotenv.get_cli_string(env.dotenv_path, action, key, value)
  169. run(command)
  170. Usage is designed to mirror the heroku config api very closely.
  171. Get all your remote config info with ``fab config``
  172. ::
  173. $ fab config
  174. Set remote config variables with ``fab config:set,<key>,<value>``
  175. ::
  176. $ fab config:set,hello,world
  177. Get a single remote config variables with ``fab config:get,<key>``
  178. ::
  179. $ fab config:get,hello
  180. Delete a remote config variables with ``fab config:unset,<key>``
  181. ::
  182. $ fab config:unset,hello
  183. Thanks entirely to fabric and not one bit to this project, you can chain
  184. commands like so ``fab config:set,<key1>,<value1> config:set,<key2>,<value2>``
  185. ::
  186. $ fab config:set,hello,world config:set,foo,bar config:set,fizz=buzz
  187. Related Projects
  188. =================
  189. - `Honcho <https://github.com/nickstenning/honcho>`__ - For managing
  190. Procfile-based applications.
  191. - `django-dotenv <https://github.com/jpadilla/django-dotenv>`__
  192. - `django-environ <https://github.com/joke2k/django-environ>`__
  193. - `django-configuration <https://github.com/jezdez/django-configurations>`__
  194. Contributing
  195. ============
  196. All the contributions are welcome! Please open `an
  197. issue <https://github.com/theskumar/python-dotenv/issues/new>`__ or send
  198. us a pull request.
  199. This project is currently maintained by `Saurabh Kumar`_ and
  200. would not have been possible without the support of these `awesome people <https://github.com/theskumar/python-dotenv/graphs/contributors>`__.
  201. Executing the tests:
  202. ::
  203. $ flake8
  204. $ pytest
  205. Changelog
  206. =========
  207. 0.7.1
  208. ----
  209. - Remove hard dependency on iPython (`@theskumar`_)
  210. 0.7.0
  211. ----
  212. - Add support to override system environment variable via .env. (`@milonimrod`_) (`#63`_)
  213. - Disable ".env not found" warning by default (`@maxkoryukov`_) (`#57`_)
  214. 0.6.5
  215. ----
  216. - Add support for special characters `\` (`@pjona`_) (`#60`_)
  217. 0.6.4
  218. ----
  219. - Fix issue with single quotes (`@Flimm`_) (`#52`_)
  220. 0.6.3
  221. ----
  222. - Handle unicode exception in setup.py (`#46`_)
  223. 0.6.2
  224. ----
  225. - Fix `dotenv list` command (`@ticosax`_)
  226. - Add iPython Suport (`@tillahoffmann`_)
  227. 0.6.0
  228. -----
  229. - Drop support for Python 2.6
  230. - Handle escaped charaters and newlines in quoted values. (Thanks `@iameugenejo`_)
  231. - Remove any spaces around unquoted key/value. (Thanks `@paulochf`_)
  232. - Added POSIX variable expansion. (Thanks `@hugochinchilla`_)
  233. 0.5.1
  234. -----
  235. - Fix `find_dotenv` - it now start search from the file where this function is called from.
  236. 0.5.0
  237. -----
  238. - Add ``find_dotenv`` method that will try to find a ``.env`` file. (Thanks `@isms`_)
  239. 0.4.0
  240. -----
  241. - cli: Added ``-q/--quote`` option to control the behaviour of quotes around values in ``.env``. (Thanks `@hugochinchilla`_).
  242. - Improved test coverage.
  243. .. _@maxkoryukov: https://github.com/milonimrod
  244. .. _@maxkoryukov: https://github.com/maxkoryukov
  245. .. _@pjona: https://github.com/pjona
  246. .. _@Flimm: https://github.com/Flimm
  247. .. _@ticosax: https://github.com/ticosax
  248. .. _@tillahoffmann: https://github.com/tillahoffmann
  249. .. _@hugochinchilla: https://github.com/hugochinchilla
  250. .. _@isms: https://github.com/isms
  251. .. _@iameugenejo: https://github.com/iameugenejo
  252. .. _@paulochf: https://github.com/paulochf
  253. .. _@paulochf: https://github.com/theskumar
  254. .. _#63: https://github.com/theskumar/python-dotenv/issues/63
  255. .. _#60: https://github.com/theskumar/python-dotenv/issues/60
  256. .. _#57: https://github.com/theskumar/python-dotenv/issues/57
  257. .. _#52: https://github.com/theskumar/python-dotenv/issues/52
  258. .. _#46: https://github.com/theskumar/python-dotenv/issues/46
  259. .. Saurabh Kumar: https://saurabh-kumar.com
  260. .. |Build Status| image:: https://travis-ci.org/theskumar/python-dotenv.svg?branch=master
  261. :target: https://travis-ci.org/theskumar/python-dotenv
  262. .. |Coverage Status| image:: https://coveralls.io/repos/theskumar/python-dotenv/badge.svg?branch=master
  263. :target: https://coveralls.io/r/theskumar/python-dotenv?branch=master
  264. .. |PyPI version| image:: https://badge.fury.io/py/python-dotenv.svg
  265. :target: http://badge.fury.io/py/python-dotenv
  266. .. |PyPI| image:: https://img.shields.io/pypi/dm/python-dotenv.svg
  267. :target: http://badge.fury.io/py/python-dotenv