Skip to content

Commit

Permalink
PYTHON-4373 Use requirements files for deps (#1605)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Apr 17, 2024
1 parent aa8322e commit a421c66
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ python:
# Install pymongo itself.
- method: pip
path: .
- requirements: doc/docs-requirements.txt
- requirements: requirements/docs.txt

build:
os: ubuntu-22.04
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include README.md
include LICENSE
include THIRD-PARTY-NOTICES
include *.ini
include requirements.txt
exclude .coveragerc
exclude .git-blame-ignore-revs
exclude .pre-commit-config.yaml
Expand All @@ -16,9 +17,9 @@ recursive-include doc *.js
recursive-include doc *.png
include doc/Makefile
include doc/_templates/layout.html
include doc/docs-requirements.txt
include doc/make.bat
include doc/static/periodic-executor-refs.dot
recursive-include requirements *.txt
recursive-include tools *.py
include tools/README.rst
include green_framework_test.py
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dnspython>=1.16.0,<3.0.0
1 change: 1 addition & 0 deletions requirements/aws.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pymongo-auth-aws>=1.1.0,<2.0.0
File renamed without changes.
3 changes: 3 additions & 0 deletions requirements/encryption.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pymongo-auth-aws>=1.1.0,<2.0.0
pymongocrypt>=1.6.0,<2.0.0
certifi;os.name=='nt' or sys_platform=='darwin'
2 changes: 2 additions & 0 deletions requirements/gssapi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pykerberos;os.name!='nt'
winkerberos>=0.5.0;os.name=='nt'
12 changes: 12 additions & 0 deletions requirements/ocsp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# PyOpenSSL 17.0.0 introduced support for OCSP. 17.1.0 introduced
# a related feature we need. 17.2.0 fixes a bug
# in set_default_verify_paths we should really avoid.
# service_identity 18.1.0 introduced support for IP addr matching.
# Fallback to certifi on Windows if we can't load CA certs from the system
# store and just use certifi on macOS.
# https://www.pyopenssl.org/en/stable/api/ssl.html#OpenSSL.SSL.Context.set_default_verify_paths
certifi;os.name=='nt' or sys_platform=='darwin'
pyopenssl>=17.2.0
requests<3.0.0
cryptography>=2.5
service_identity>=18.1.0
1 change: 1 addition & 0 deletions requirements/snappy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-snappy
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest>=7
1 change: 1 addition & 0 deletions requirements/zstd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zstandard
45 changes: 14 additions & 31 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,43 +137,26 @@ def build_extension(self, ext):
ext_modules = []


dependencies = [
"dnspython>=1.16.0,<3.0.0",
]
def parse_reqs_file(fname):
with open(fname) as fid:
lines = [li.strip() for li in fid.readlines()]
return [li for li in lines if li and not li.startswith("#")]


dependencies = parse_reqs_file("requirements.txt")

extras_require = dict(
aws=[
"pymongo-auth-aws>=1.1.0,<2.0.0",
],
encryption=[
"pymongo[aws]",
"pymongocrypt>=1.6.0,<2.0.0",
"certifi;os.name=='nt' or sys_platform=='darwin'",
],
gssapi=["pykerberos;os.name!='nt'", "winkerberos>=0.5.0;os.name=='nt'"],
# PyOpenSSL 17.0.0 introduced support for OCSP. 17.1.0 introduced
# a related feature we need. 17.2.0 fixes a bug
# in set_default_verify_paths we should really avoid.
# service_identity 18.1.0 introduced support for IP addr matching.
# Fallback to certifi on Windows if we can't load CA certs from the system
# store and just use certifi on macOS.
# https://www.pyopenssl.org/en/stable/api/ssl.html#OpenSSL.SSL.Context.set_default_verify_paths
ocsp=[
"certifi;os.name=='nt' or sys_platform=='darwin'",
"pyopenssl>=17.2.0",
"requests<3.0.0",
"cryptography>=2.5",
"service_identity>=18.1.0",
],
snappy=["python-snappy"],
aws=parse_reqs_file("requirements/aws.txt"),
encryption=parse_reqs_file("requirements/encryption.txt"),
gssapi=parse_reqs_file("requirements/gssapi.txt"),
ocsp=parse_reqs_file("requirements/ocsp.txt"),
snappy=parse_reqs_file("requirements/snappy.txt"),
# PYTHON-3423 Removed in 4.3 but kept here to avoid pip warnings.
srv=[],
tls=[],
# PYTHON-2133 Removed in 4.0 but kept here to avoid pip warnings.
zstd=[
"zstandard",
],
test=["pytest>=7"],
zstd=parse_reqs_file("requirements/zstd.txt"),
test=parse_reqs_file("requirements/test.txt"),
)

setup(
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ commands =
[testenv:doc]
description = build sphinx docs
deps =
-rdoc/docs-requirements.txt
-rrequirements/docs.txt
commands =
sphinx-build -W -b html doc ./doc/_build/html

Expand Down

0 comments on commit a421c66

Please sign in to comment.