mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
730d84217d
* allow use of a `.env`-style files in BaseSettings (#607) * address various issues with initial implementation - allow specifying `_env_file` kwarg in instantiation * overrides any `env_file` specified in the `Config` class - cast `os.environ` as a dict for better consistenty of behavior - `env_path` should be a `Path` type - replace `with open()` with `read_text` - use regex for parsing the dotenv files and throw error on invalid line - factor out `read_env_file` into separate file for easier testing * move back into a single file; revert typing changes; use regex better * pass `_env_file` argument around instead of setting a class attribute * add dotenv docs * add dotenv tests * Add changes file * Flesh out the docs a bit * Apply suggestions from @samuelcolvin's code review Co-Authored-By: Samuel Colvin <samcolvin@gmail.com> * wrap docs * add not about priority * fix tests and imports * fix tests * switch to python-dotenv * cleanup, test example * more docs tweaks * typo * fix tests for dotenv Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
56 lines
2.1 KiB
Markdown
56 lines
2.1 KiB
Markdown
Installation is as simple as:
|
|
|
|
```py
|
|
pip install pydantic
|
|
```
|
|
|
|
*pydantic* has no required dependencies except python 3.6, 3.7, or 3.8 (and the dataclasses package in python 3.6).
|
|
If you've got python 3.6+ and `pip` installed, you're good to go.
|
|
|
|
Pydantic is also available on [conda](https://www.anaconda.com) under the [conda-forge](https://conda-forge.org)
|
|
channel:
|
|
|
|
```bash
|
|
conda install pydantic -c conda-forge
|
|
```
|
|
|
|
*pydantic* can optionally be compiled with [cython](https://cython.org/) which should give a 30-50% performance
|
|
improvement. `manylinux` binaries exist for python 3.6, 3.7, and 3.8, so if you're installing from PyPI on linux, you
|
|
should get a compiled version of *pydantic* with no extra work. If you're installing manually, install `cython`
|
|
before installing *pydantic* and compilation should happen automatically. Compilation with cython
|
|
[is not tested](https://github.com/samuelcolvin/pydantic/issues/555) on windows or mac.
|
|
|
|
To test if *pydantic* is compiled run:
|
|
|
|
```py
|
|
import pydantic
|
|
print('compiled:', pydantic.compiled)
|
|
```
|
|
|
|
*pydantic* has three optional dependencies:
|
|
|
|
* If you require email validation you can add [email-validator](https://github.com/JoshData/python-email-validator)
|
|
* use of `Literal` prior to python 3.8 relies on [typing-extensions](https://pypi.org/project/typing-extensions/)
|
|
* [dotenv file support](usage/settings.md#dotenv-env-support) with `Settings` requires
|
|
[python-dotenv](https://pypi.org/project/python-dotenv)
|
|
|
|
To install these along with *pydantic*:
|
|
```bash
|
|
pip install pydantic[email]
|
|
# or
|
|
pip install pydantic[typing_extensions]
|
|
# or
|
|
pip install pydantic[dotenv]
|
|
# or just
|
|
pip install pydantic[email,typing_extensions,dotenv]
|
|
```
|
|
|
|
Of course, you can also install these requirements manually with `pip install email-validator` and/or `pip install typing_extensions`.
|
|
|
|
And if you prefer to install *pydantic* directly from the repository:
|
|
```bash
|
|
pip install git+git://github.com/samuelcolvin/pydantic@master#egg=pydantic
|
|
# or with extras
|
|
pip install git+git://github.com/samuelcolvin/pydantic@master#egg=pydantic[email,typing_extensions]
|
|
```
|