Skip to content

Commit

Permalink
Use optional package installs (#666)
Browse files Browse the repository at this point in the history
* Make dependencies optional

resolves #219

* Tweak install options and update installation instructions in readme

* update to latest conclusion

* rename default -> standard

* Incoroporate other reqs

* Added setup.py to black test, previous merge made me remove all double quotes in it

* Added setup.py to lint script to match test script

* Lint setup.py

* Removed leftover from merge that was incorrect

* Trying to be more explicit about the 2 install options

* Spelling

* Newlines

* Better wording

* Websockets vs wsproto more relevant in extras

Co-authored-by: Carl George <carl@george.computer>
Co-authored-by: Almar Klein <almar.klein@gmail.com>
  • Loading branch information
3 people authored Aug 10, 2020
1 parent 11f9a71 commit 5fa99a1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
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="tom@tomchristie.com",
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

0 comments on commit 5fa99a1

Please sign in to comment.