Skip to content
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

Use optional package installs #666

Merged
merged 19 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from 14 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 "fast" dependencies (where possible) and other "goodies".

Fast meaning in that context that:
erewok marked this conversation as resolved.
Show resolved Hide resolved

- the event loop `uvloop` will be installed and used if possible.
- the http protocol will be handled by `httptools` if possible.
- the websocket protocol will be handled by `websockets` (should you want to use `wsproto` you'd need to install it manually) if possible.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the "websockets" one ought to go under optional extras really. (The "uvloop" and "httptools" cases here are kinda different in that they're not adding extra behaviour, so they're purely due to performance-something-something)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this is indeeed the case !

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amended


Goodies meaning that:

- 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
uvloop>=0.14.0
websockets==8.*
wsproto==0.13.*
watchgod>=0.6,<0.7
python_dotenv==0.13.*

# Testing
autoflake
Expand All @@ -21,5 +24,3 @@ requests
mkdocs
mkdocs-material

# Efficient debug reload
watchgod>=0.6,<0.7
2 changes: 1 addition & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ fi
set -x

${PREFIX}autoflake --in-place --recursive uvicorn tests
${PREFIX}black uvicorn tests
${PREFIX}black uvicorn tests setup.py
${PREFIX}isort --multi-line=3 --trailing-comma --force-grid-wrap=0 --combine-as --line-width 88 --recursive --apply uvicorn tests
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ PYTHONPATH=. ${PREFIX}pytest --ignore venv --cov=uvicorn --cov=tests --cov-repor
${PREFIX}coverage html
${PREFIX}autoflake --recursive uvicorn tests
${PREFIX}flake8 uvicorn tests --ignore=W503,E203,E501,E731
${PREFIX}black uvicorn tests --check
${PREFIX}black uvicorn tests setup.py --check
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