Skip to content

Use optional package installs #666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ Install using `pip`:
$ pip install uvicorn
```

This will install uvicorn with minimal (pure Python) dependencies.

```shell
$ pip install uvicorn[standard]
```

This will install uvicorn with "Cython-based" dependencies (where possible) and other "optional extras".

In this context, "Cython-based" means the following:

- the event loop `uvloop` will be installed and used if possible.
- the http protocol will be handled by `httptools` if possible.

Moreover, "optional extras" means that:

- the websocket protocol will be handled by `websockets` (should you want to use `wsproto` you'd need to install it manually) if possible.
- the `--reloader` flag in development mode will use `watchgod`.
- windows users will have `colorama` installed for the colored logs.
- `python-dotenv` will be install should you want to use the `--env-file` option.

Create an application, in `example.py`:

```python
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Minimal
click
h11

Expand All @@ -6,6 +7,8 @@ httptools; sys_platform != 'win32'
uvloop>=0.14.0; sys_platform != 'win32'
websockets==8.*
wsproto==0.13.*
watchgod>=0.6,<0.7
python_dotenv==0.13.*

# Packaging
twine
Expand All @@ -26,5 +29,3 @@ seed-isort-config
mkdocs
mkdocs-material

# Efficient debug reload
watchgod>=0.6,<0.7
23 changes: 15 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,28 @@ def get_packages(package):
]


env_marker = (
env_marker_cpython = (
"sys_platform != 'win32'"
" and sys_platform != 'cygwin'"
" and platform_python_implementation != 'PyPy'"
)

requirements = [
env_marker_win = "sys_platform == 'win32'"


minimal_requirements = [
"click==7.*",
"h11>=0.8,<0.10",
"websockets==8.*",
"httptools==0.1.* ;" + env_marker,
"uvloop>=0.14.0 ;" + env_marker,
]

extras_require = {"watchgodreload": ["watchgod>=0.6,<0.7"]}
extra_requirements = [
"websockets==8.*",
"httptools==0.1.* ;" + env_marker_cpython,
"uvloop>=0.14.0 ;" + env_marker_cpython,
"colorama>=0.4.*;" + env_marker_win,
"watchgod>=0.6,<0.7",
"python-dotenv==0.13.*",
]


setup(
Expand All @@ -62,8 +69,8 @@ def get_packages(package):
author="Tom Christie",
author_email="[email protected]",
packages=get_packages("uvicorn"),
install_requires=requirements,
extras_require=extras_require,
install_requires=minimal_requirements,
extras_require={"standard": extra_requirements},
include_package_data=True,
classifiers=[
"Development Status :: 4 - Beta",
Expand Down