From d1f5268b150aec65067e4766a61eab2bd25526ea Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Thu, 8 Mar 2018 14:19:44 +0000 Subject: [PATCH] Add extras_require for various worker types (#1718) Fixes #1717 --- docs/source/install.rst | 11 +++++++---- docs/source/settings.rst | 13 +++++++++---- gunicorn/config.py | 13 +++++++++---- setup.py | 13 ++++++++++++- 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index b6d84f1e..2d312773 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -33,12 +33,15 @@ want to consider one of the alternate worker types. :: - $ pip install greenlet # Required for both - $ pip install eventlet # For eventlet workers - $ pip install gevent # For gevent workers + $ pip install greenlet # Required for both + $ pip install eventlet # For eventlet workers + $ pip install gunicorn[eventlet] # Or, using extra + $ pip install gevent # For gevent workers + $ pip install gunicorn[gevent] # Or, using extra .. note:: - If installing ``greenlet`` fails you probably need to install + Both require ``greenlet``, which should get installed automatically, + If its installation fails, you probably need to install the Python headers. These headers are available in most package managers. On Ubuntu the package name for ``apt-get`` is ``python-dev``. diff --git a/docs/source/settings.rst b/docs/source/settings.rst index dafa9869..8ca995e0 100644 --- a/docs/source/settings.rst +++ b/docs/source/settings.rst @@ -114,15 +114,20 @@ The type of workers to use. The default class (``sync``) should handle most "normal" types of workloads. You'll want to read :doc:`design` for information on when -you might want to choose one of the other worker classes. +you might want to choose one of the other worker classes. Required +libraries may be installed using setuptools' ``extra_require`` feature. A string referring to one of the following bundled classes: * ``sync`` -* ``eventlet`` - Requires eventlet >= 0.9.7 -* ``gevent`` - Requires gevent >= 0.13 -* ``tornado`` - Requires tornado >= 0.2 +* ``eventlet`` - Requires eventlet >= 0.9.7 (or install it via + ``pip install gunicorn[eventlet]``) +* ``gevent`` - Requires gevent >= 0.13 (or install it via + ``pip install gunicorn[gevent]``) +* ``tornado`` - Requires tornado >= 0.2 (or install it via + ``pip install gunicorn[tornado]``) * ``gthread`` - Python 2 requires the futures package to be installed + (or install it via ``pip install gunicorn[gthread]``) * ``gaiohttp`` - Deprecated. Optionally, you can provide your own worker by giving Gunicorn a diff --git a/gunicorn/config.py b/gunicorn/config.py index dfba8a45..23abe498 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -605,15 +605,20 @@ class WorkerClass(Setting): The default class (``sync``) should handle most "normal" types of workloads. You'll want to read :doc:`design` for information on when - you might want to choose one of the other worker classes. + you might want to choose one of the other worker classes. Required + libraries may be installed using setuptools' ``extra_require`` feature. A string referring to one of the following bundled classes: * ``sync`` - * ``eventlet`` - Requires eventlet >= 0.9.7 - * ``gevent`` - Requires gevent >= 0.13 - * ``tornado`` - Requires tornado >= 0.2 + * ``eventlet`` - Requires eventlet >= 0.9.7 (or install it via + ``pip install gunicorn[eventlet]``) + * ``gevent`` - Requires gevent >= 0.13 (or install it via + ``pip install gunicorn[gevent]``) + * ``tornado`` - Requires tornado >= 0.2 (or install it via + ``pip install gunicorn[tornado]``) * ``gthread`` - Python 2 requires the futures package to be installed + (or install it via ``pip install gunicorn[gthread]``) * ``gaiohttp`` - Deprecated. Optionally, you can provide your own worker by giving Gunicorn a diff --git a/setup.py b/setup.py index 52656f24..398709f1 100644 --- a/setup.py +++ b/setup.py @@ -72,6 +72,16 @@ class PyTestCommand(TestCommand): errno = pytest.main(self.test_args) sys.exit(errno) + +extra_require = { + 'gevent': ['gevent>=0.13'], + 'eventlet': ['eventlet>=0.9.7'], + 'tornado': ['tornado>=0.2'], + 'gthread': [], +} +if sys.version_info[0] < 3: + extra_require['gthread'] = ['futures'] + setup( name='gunicorn', version=__version__, @@ -98,5 +108,6 @@ setup( [paste.server_runner] main=gunicorn.app.pasterapp:paste_server - """ + """, + extras_require=extra_require, )