Repository: benoitc/gunicorn

Issue:
Use extras_require in setup for optional dependencies
Gunicorn [may require extra dependencies](http://docs.gunicorn.org/en/stable/install.html#async-workers) to be installed, but they seem to be optional. It looks like it should be possible to install these using [setuptools's extra](https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies).

It looks like Gevent or Eventlet are 2 options, but the [worker option](http://docs.gunicorn.org/en/stable/run.html#commonly-used-arguments) seems to indicate there are more.

Would it make sense to add this? It has the advantage of documenting indirect dependencies.
Use extras_require in setup for optional dependencies
Gunicorn [may require extra dependencies](http://docs.gunicorn.org/en/stable/install.html#async-workers) to be installed, but they seem to be optional. It looks like it should be possible to install these using [setuptools's extra](https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies).

It looks like Gevent or Eventlet are 2 options, but the [worker option](http://docs.gunicorn.org/en/stable/run.html#commonly-used-arguments) seems to indicate there are more.

Would it make sense to add this? It has the advantage of documenting indirect dependencies.


Discussion:
Having extras for each worker type would make sense.

``` shellsession
$ pip install gunicorn[gevent]
```
Having extras for each worker type would make sense.

``` shellsession
$ pip install gunicorn[gevent]
```

Resolving patch:
diff --git a/gunicorn/config.py b/gunicorn/config.py
--- 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
--- a/setup.py
+++ b/setup.py
@@ -72,6 +72,16 @@ def run_tests(self):
         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 @@ def run_tests(self):
 
     [paste.server_runner]
     main=gunicorn.app.pasterapp:paste_server
-    """
+    """,
+    extras_require=extra_require,
 )


Test patch: