Skip to content

Commit 3025d68

Browse files
committed
PYTHON-1093 - Use extras_require to install optional dependencies
1 parent 80fc55a commit 3025d68

File tree

3 files changed

+90
-49
lines changed

3 files changed

+90
-49
lines changed

README.rst

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,18 @@ MongoDB project, please report it according to the `instructions here
6666
Installation
6767
============
6868

69-
If you have `setuptools
70-
<http://pythonhosted.org/setuptools/>`_ installed you
71-
should be able to do **easy_install pymongo** to install
72-
PyMongo. Otherwise you can download the project source and do **python
73-
setup.py install** to install.
69+
PyMongo can be installed with `pip <http://pypi.python.org/pypi/pip>`_::
70+
71+
$ python -m pip install pymongo
72+
73+
Or ``easy_install`` from
74+
`setuptools <http://pypi.python.org/pypi/setuptools>`_::
75+
76+
$ python -m easy_install pymongo
77+
78+
You can also download the project source and do::
79+
80+
$ python setup.py install
7481

7582
Do **not** install the "bson" package. PyMongo comes with its own bson package;
7683
doing "easy_install bson" installs a third-party package that is incompatible
@@ -79,32 +86,39 @@ with PyMongo.
7986
Dependencies
8087
============
8188

82-
The PyMongo distribution is supported and tested on Python 2.x (where
83-
x >= 6) and Python 3.x (where x >= 2). PyMongo versions before 3.0 also
84-
support Python 2.4, 2.5, and 3.1.
89+
PyMongo supports Python 2.6, 2.7, and 3.2+.
90+
91+
Optional dependencies for GSSAPI and TLS:
92+
93+
GSSAPI authentication requires `pykerberos
94+
<https://pypi.python.org/pypi/pykerberos>`_ on Unix or `WinKerberos
95+
<https://pypi.python.org/pypi/winkerberos>`_ on Windows. The correct
96+
dependency can be installed automatically along with PyMongo::
97+
98+
$ python -m pip install pymongo[gssapi]
99+
100+
TLS / SSL support may require `certifi
101+
<https://pypi.python.org/pypi/certifi>`_ or `wincertstore
102+
<https://pypi.python.org/pypi/wincertstore>`_ depending on the Python
103+
version in use. The necessary dependencies can be installed along with
104+
PyMongo::
105+
106+
$ python -m pip install pymongo[tls]
107+
108+
You can install both dependencies automatically with the following
109+
command::
110+
111+
$ python -m pip install pymongo[gssapi,tls]
85112

86-
Optional packages:
113+
Other optional packages:
87114

88115
- `backports.pbkdf2 <https://pypi.python.org/pypi/backports.pbkdf2/>`_,
89116
improves authentication performance with SCRAM-SHA-1, the default
90117
authentication mechanism for MongoDB 3.0+. It especially improves
91118
performance on Python older than 2.7.8, or on Python 3 before Python 3.4.
92-
- `pykerberos <https://pypi.python.org/pypi/pykerberos>`_ is required for
93-
the GSSAPI authentication mechanism.
94119
- `monotonic <https://pypi.python.org/pypi/monotonic>`_ adds support for
95120
a monotonic clock, which improves reliability in environments
96121
where clock adjustments are frequent. Not needed in Python 3.3+.
97-
- `wincertstore <https://pypi.python.org/pypi/wincertstore>`_ adds support
98-
for verifying server SSL certificates using Windows provided CA
99-
certificates on older versions of python. Not needed or used with versions
100-
of Python 2 beginning with 2.7.9, or versions of Python 3 beginning with
101-
3.4.0.
102-
- `certifi <https://pypi.python.org/pypi/certifi>`_ adds support for
103-
using the Mozilla CA bundle with SSL to verify server certificates. Not
104-
needed or used with versions of Python 2 beginning with 2.7.9 on any OS,
105-
versions of Python 3 beginning with Python 3.4.0 on Windows, or versions
106-
of Python 3 beginning with Python 3.2.0 on operating systems other than
107-
Windows.
108122

109123

110124
Additional dependencies are:

doc/installation.rst

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,6 @@ Installing / Upgrading
99
bson package; doing "pip install bson" or "easy_install bson" installs a
1010
third-party package that is incompatible with PyMongo.
1111

12-
Optional packages
13-
-----------------
14-
15-
PyMongo has no required dependencies, but it can take advantage of these
16-
packages:
17-
18-
- `backports.pbkdf2 <https://pypi.python.org/pypi/backports.pbkdf2/>`_,
19-
improves authentication performance with SCRAM-SHA-1, the default
20-
authentication mechanism for MongoDB 3.0+. It especially improves
21-
performance on Python older than 2.7.8, or on Python 3 before Python 3.4.
22-
- `pykerberos <https://pypi.python.org/pypi/pykerberos>`_ is required for
23-
the GSSAPI authentication mechanism.
24-
- `monotonic <https://pypi.python.org/pypi/monotonic>`_ adds support for
25-
a monotonic clock, which improves reliability in environments
26-
where clock adjustments are frequent. Not needed in Python 3.3+.
27-
- `wincertstore <https://pypi.python.org/pypi/wincertstore>`_ adds support
28-
for verifying server SSL certificates using Windows provided CA
29-
certificates on older versions of python. Not needed or used with versions
30-
of Python 2 beginning with 2.7.9, or versions of Python 3 beginning with
31-
3.4.0.
32-
- `certifi <https://pypi.python.org/pypi/certifi>`_ adds support for
33-
using the Mozilla CA bundle with SSL to verify server certificates. Not
34-
needed or used with versions of Python 2 beginning with 2.7.9 on any OS,
35-
versions of Python 3 beginning with Python 3.4.0 on Windows, or versions
36-
of Python 3 beginning with Python 3.2.0 on operating systems other than
37-
Windows.
38-
3912
Installing with pip
4013
-------------------
4114

@@ -69,6 +42,44 @@ To upgrade do::
6942

7043
$ python -m easy_install -U pymongo
7144

45+
Dependencies
46+
------------
47+
48+
PyMongo supports Python 2.6, 2.7, and 3.2+.
49+
50+
Optional dependencies for GSSAPI and TLS:
51+
52+
GSSAPI authentication requires `pykerberos
53+
<https://pypi.python.org/pypi/pykerberos>`_ on Unix or `WinKerberos
54+
<https://pypi.python.org/pypi/winkerberos>`_ on Windows. The correct
55+
dependency can be installed automatically along with PyMongo::
56+
57+
$ python -m pip install pymongo[gssapi]
58+
59+
TLS / SSL support may require `certifi
60+
<https://pypi.python.org/pypi/certifi>`_ or `wincertstore
61+
<https://pypi.python.org/pypi/wincertstore>`_ depending on the Python
62+
version in use. The necessary dependencies can be installed along with
63+
PyMongo::
64+
65+
$ python -m pip install pymongo[tls]
66+
67+
You can install both dependencies automatically with the following
68+
command::
69+
70+
$ python -m pip install pymongo[gssapi,tls]
71+
72+
Other optional packages:
73+
74+
- `backports.pbkdf2 <https://pypi.python.org/pypi/backports.pbkdf2/>`_,
75+
improves authentication performance with SCRAM-SHA-1, the default
76+
authentication mechanism for MongoDB 3.0+. It especially improves
77+
performance on Python older than 2.7.8, or on Python 3 before Python 3.4.
78+
- `monotonic <https://pypi.python.org/pypi/monotonic>`_ adds support for
79+
a monotonic clock, which improves reliability in environments
80+
where clock adjustments are frequent. Not needed in Python 3.3+.
81+
82+
7283
Dependencies for installing C Extensions on Unix
7384
------------------------------------------------
7485

setup.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,21 @@ def build_extension(self, ext):
244244
sources=['pymongo/_cmessagemodule.c',
245245
'bson/buffer.c'])]
246246

247+
extras_require = {}
248+
vi = sys.version_info
249+
if sys.platform == 'win32':
250+
extras_require['gssapi'] = ["winkerberos>=0.3.0"]
251+
if vi[0] == 2 and vi < (2, 7, 9) or vi[0] == 3 and vi < (3, 4):
252+
extras_require['tls'] = ["wincertstore>=0.2"]
253+
else:
254+
extras_require['tls'] = []
255+
else:
256+
extras_require['gssapi'] = ["pykerberos"]
257+
if vi[0] == 2 and vi < (2, 7, 9):
258+
extras_require['tls'] = ["certifi"]
259+
else:
260+
extras_require['tls'] = []
261+
247262
extra_opts = {
248263
"packages": ["bson", "pymongo", "gridfs"]
249264
}
@@ -306,5 +321,6 @@ def build_extension(self, ext):
306321
cmdclass={"build_ext": custom_build_ext,
307322
"doc": doc,
308323
"test": test},
324+
extras_require=extras_require,
309325
**extra_opts
310326
)

0 commit comments

Comments
 (0)