diff --git a/.readthedocs.yaml b/.readthedocs.yaml index f4c7c2cd..7d1d696e 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -15,7 +15,7 @@ python: # Install motor itself. - method: pip path: . - - requirements: doc/docs-requirements.txt + - requirements: requirements/docs.txt build: os: ubuntu-22.04 diff --git a/MANIFEST.in b/MANIFEST.in index 5eb26eb7..68b01644 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,6 +2,7 @@ include README.md include LICENSE include tox.ini include pyproject.toml +include requirements.txt include doc/Makefile include doc/examples/tornado_change_stream_templates/index.html recursive-include doc *.rst @@ -18,6 +19,7 @@ recursive-include synchro *.py recursive-include motor *.pyi recursive-include motor *.typed recursive-include motor *.py +recursive-include requirements *.txt exclude .readthedocs.yaml exclude .git-blame-ignore-revs diff --git a/pyproject.toml b/pyproject.toml index 19346c7f..130f8728 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "motor" -dynamic = ["version"] +dynamic = ["version", "dependencies", "optional-dependencies"] description = "Non-blocking MongoDB driver for Tornado or asyncio" readme = "README.md" license = { file = "LICENSE" } @@ -42,35 +42,6 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", ] -dependencies = [ - "pymongo>=4.5,<5", -] - -[project.optional-dependencies] -aws = [ - "pymongo[aws]>=4.5,<5", -] -encryption = [ - "pymongo[encryption]>=4.5,<5", -] -gssapi = [ - "pymongo[gssapi]>=4.5,<5", -] -ocsp = [ - "pymongo[ocsp]>=4.5,<5", -] -snappy = [ - "pymongo[snappy]>=4.5,<5", -] -srv = [ - "pymongo[srv]>=4.5,<5", -] -test = [ - "pytest>=7", "mockupdb", "tornado>=5", "aiohttp!=3.8.6", "motor[encryption]" -] -zstd = [ - "pymongo[zstd]>=4.5,<5", -] [project.urls] Homepage = "https://www.mongodb.org" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..45c42ede --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pymongo>=4.5,<5 diff --git a/requirements/aws.txt b/requirements/aws.txt new file mode 100644 index 00000000..fd7ff757 --- /dev/null +++ b/requirements/aws.txt @@ -0,0 +1 @@ +pymongo[aws]>=4.5,<5 diff --git a/doc/docs-requirements.txt b/requirements/docs.txt similarity index 100% rename from doc/docs-requirements.txt rename to requirements/docs.txt diff --git a/requirements/encryption.txt b/requirements/encryption.txt new file mode 100644 index 00000000..e20a56f2 --- /dev/null +++ b/requirements/encryption.txt @@ -0,0 +1 @@ +pymongo[encryption]>=4.5,<5 diff --git a/requirements/gssapi.txt b/requirements/gssapi.txt new file mode 100644 index 00000000..7196be8e --- /dev/null +++ b/requirements/gssapi.txt @@ -0,0 +1 @@ +pymongo[gssapi]>=4.5,<5 diff --git a/requirements/ocsp.txt b/requirements/ocsp.txt new file mode 100644 index 00000000..9dac3fab --- /dev/null +++ b/requirements/ocsp.txt @@ -0,0 +1 @@ +pymongo[ocsp]>=4.5,<5 diff --git a/requirements/snappy.txt b/requirements/snappy.txt new file mode 100644 index 00000000..cdc841c8 --- /dev/null +++ b/requirements/snappy.txt @@ -0,0 +1 @@ +pymongo[snappy]>=4.5,<5 diff --git a/requirements/srv.txt b/requirements/srv.txt new file mode 100644 index 00000000..e776b35a --- /dev/null +++ b/requirements/srv.txt @@ -0,0 +1 @@ +pymongo[srv]>=4.5,<5 diff --git a/requirements/test.txt b/requirements/test.txt new file mode 100644 index 00000000..2c98ae4c --- /dev/null +++ b/requirements/test.txt @@ -0,0 +1,5 @@ +pytest>=7 +mockupdb +tornado>=5 +aiohttp!=3.8.6 +motor[encryption] diff --git a/requirements/zstd.txt b/requirements/zstd.txt new file mode 100644 index 00000000..a35b52fd --- /dev/null +++ b/requirements/zstd.txt @@ -0,0 +1 @@ +pymongo[zstd]>=4.5,<5 diff --git a/setup.py b/setup.py index 60684932..8d01935d 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,21 @@ from setuptools import setup -setup() + +def parse_reqs_file(fname): + with open(fname) as fid: # noqa:PTH123 + lines = [li.strip() for li in fid.readlines()] + return [li for li in lines if li and not li.startswith("#")] + + +extras_require = dict( # noqa:C408 + 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"), + srv=parse_reqs_file("requirements/srv.txt"), + test=parse_reqs_file("requirements/test.txt"), + zstd=parse_reqs_file("requirements/zstd.txt"), +) + +setup(install_requires=parse_reqs_file("requirements.txt"), extras_require=extras_require) diff --git a/tox.ini b/tox.ini index 61a6e5b0..755cc26d 100644 --- a/tox.ini +++ b/tox.ini @@ -76,7 +76,7 @@ extras = [testenv:docs] setenv = PYTHONWARNINGS= deps = - -rdoc/docs-requirements.txt + -rrequirements/docs.txt changedir = doc commands = python -m sphinx -q -E -W -b html . {envtmpdir}/html {posargs} @@ -84,7 +84,7 @@ commands = [testenv:doctest] setenv = PYTHONHASHSEED=0 deps = - -rdoc/docs-requirements.txt + -rrequirements/docs.txt changedir = doc commands = python -m sphinx -q -E -b doctest . {envtmpdir}/doctest {posargs} @@ -92,7 +92,7 @@ commands = [testenv:linkcheck] setenv = PYTHONHASHSEED=0 deps = - -rdoc/docs-requirements.txt + -rrequirements/docs.txt changedir = doc commands = python -m sphinx -q -E -b linkcheck . {envtmpdir}/linkcheck {posargs}