MOTOR-1327 Use Hatch as Build Backend (#286)
This commit is contained in:
parent
aa6876aa4d
commit
96297ac947
@ -63,7 +63,7 @@ createvirtualenv () {
|
||||
fi
|
||||
|
||||
python -m pip install -q --upgrade pip
|
||||
python -m pip install -q --upgrade setuptools wheel tox
|
||||
python -m pip install -q --upgrade tox
|
||||
}
|
||||
|
||||
|
||||
|
||||
1
.github/workflows/test-python.yml
vendored
1
.github/workflows/test-python.yml
vendored
@ -58,7 +58,6 @@ jobs:
|
||||
- name: Run linters
|
||||
run: |
|
||||
tox -m lint-manual
|
||||
tox -m manifest
|
||||
|
||||
docs:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
@ -15,7 +15,7 @@ python:
|
||||
# Install motor itself.
|
||||
- method: pip
|
||||
path: .
|
||||
- requirements: requirements/docs-requirements.txt
|
||||
- requirements: requirements/docs.txt
|
||||
|
||||
build:
|
||||
os: ubuntu-22.04
|
||||
|
||||
31
MANIFEST.in
31
MANIFEST.in
@ -1,31 +0,0 @@
|
||||
include README.md
|
||||
include LICENSE
|
||||
include tox.ini
|
||||
include sbom.json
|
||||
include pyproject.toml
|
||||
include requirements.txt
|
||||
include doc/Makefile
|
||||
include doc/examples/tornado_change_stream_templates/index.html
|
||||
recursive-include doc *.rst
|
||||
recursive-include doc *.py
|
||||
recursive-include doc *.png
|
||||
recursive-include test *.py
|
||||
recursive-include test *.pem
|
||||
recursive-include doc *.conf
|
||||
recursive-include doc *.css
|
||||
recursive-include doc *.js
|
||||
recursive-include doc *.txt
|
||||
recursive-include doc *.bat
|
||||
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
|
||||
exclude .pre-commit-config.yaml
|
||||
exclude release.sh
|
||||
exclude RELEASE.md
|
||||
exclude CONTRIBUTING.md
|
||||
exclude .evergreen/*
|
||||
@ -13,13 +13,29 @@
|
||||
# limitations under the License.
|
||||
|
||||
"""Version-related data for motor."""
|
||||
version_tuple = (3, 5, 0, ".dev0")
|
||||
import re
|
||||
from typing import List, Tuple, Union
|
||||
|
||||
__version__ = "3.5.0.dev0"
|
||||
|
||||
|
||||
def get_version_tuple(version: str) -> Tuple[Union[int, str], ...]:
|
||||
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
|
||||
match = re.match(pattern, version)
|
||||
if match:
|
||||
parts: List[Union[int, str]] = [int(match[part]) for part in ["major", "minor", "patch"]]
|
||||
if match["rest"]:
|
||||
parts.append(match["rest"])
|
||||
elif re.match(r"\d+.\d+", version):
|
||||
parts = [int(part) for part in version.split(".")]
|
||||
else:
|
||||
raise ValueError("Could not parse version")
|
||||
return tuple(parts)
|
||||
|
||||
|
||||
version_tuple = get_version_tuple(__version__)
|
||||
version = __version__
|
||||
|
||||
|
||||
def get_version_string() -> str:
|
||||
if isinstance(version_tuple[-1], str):
|
||||
return ".".join(map(str, version_tuple[:-1])) + version_tuple[-1]
|
||||
return ".".join(map(str, version_tuple)) # type:ignore[unreachable]
|
||||
|
||||
|
||||
version = get_version_string()
|
||||
return __version__
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>61.0"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
requires = ["hatchling>1.24","hatch-requirements-txt>=0.4.1"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "motor"
|
||||
@ -48,11 +48,21 @@ Documentation = "https://motor.readthedocs.io"
|
||||
Source = "https://github.com/mongodb/motor"
|
||||
Tracker = "https://jira.mongodb.org/projects/MOTOR/issues"
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
version = {attr = "motor._version.version"}
|
||||
[tool.hatch.version]
|
||||
path = "motor/_version.py"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
include = ["motor"]
|
||||
[tool.hatch.metadata.hooks.requirements_txt]
|
||||
files = ["requirements.txt"]
|
||||
|
||||
[tool.hatch.metadata.hooks.requirements_txt.optional-dependencies]
|
||||
aws = ["requirements/aws.txt"]
|
||||
docs = ["requirements/docs.txt"]
|
||||
encryption = ["requirements/encryption.txt"]
|
||||
gssapi = ["requirements/gssapi.txt"]
|
||||
ocsp = ["requirements/ocsp.txt"]
|
||||
snappy = ["requirements/snappy.txt"]
|
||||
test = ["requirements/test.txt"]
|
||||
zstd = ["requirements/zstd.txt"]
|
||||
|
||||
[tool.mypy]
|
||||
python_version = "3.8"
|
||||
|
||||
21
setup.py
21
setup.py
@ -1,21 +0,0 @@
|
||||
from setuptools import 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-requirements.txt"),
|
||||
encryption=parse_reqs_file("requirements/encryption-requirements.txt"),
|
||||
gssapi=parse_reqs_file("requirements/gssapi-requirements.txt"),
|
||||
ocsp=parse_reqs_file("requirements/ocsp-requirements.txt"),
|
||||
snappy=parse_reqs_file("requirements/snappy-requirements.txt"),
|
||||
srv=parse_reqs_file("requirements/srv-requirements.txt"),
|
||||
test=parse_reqs_file("requirements/test-requirements.txt"),
|
||||
zstd=parse_reqs_file("requirements/zstd-requirements.txt"),
|
||||
)
|
||||
|
||||
setup(install_requires=parse_reqs_file("requirements.txt"), extras_require=extras_require)
|
||||
14
tox.ini
14
tox.ini
@ -43,7 +43,6 @@ labels = # Use labels and -m instead of -e so that tox -m <label> fails instantl
|
||||
lint = lint
|
||||
lint-manual = lint-manual
|
||||
linkcheck = linkcheck
|
||||
manifest = manifest
|
||||
typecheck-mypy = typecheck-mypy
|
||||
|
||||
[testenv]
|
||||
@ -76,7 +75,7 @@ extras =
|
||||
[testenv:docs]
|
||||
setenv = PYTHONWARNINGS=
|
||||
deps =
|
||||
-rrequirements/docs-requirements.txt
|
||||
-rrequirements/docs.txt
|
||||
changedir = doc
|
||||
commands =
|
||||
python -m sphinx -q -E -W -b html . {envtmpdir}/html {posargs}
|
||||
@ -84,7 +83,7 @@ commands =
|
||||
[testenv:doctest]
|
||||
setenv = PYTHONHASHSEED=0
|
||||
deps =
|
||||
-rrequirements/docs-requirements.txt
|
||||
-rrequirements/docs.txt
|
||||
changedir = doc
|
||||
commands =
|
||||
python -m sphinx -q -E -b doctest . {envtmpdir}/doctest {posargs}
|
||||
@ -92,7 +91,7 @@ commands =
|
||||
[testenv:linkcheck]
|
||||
setenv = PYTHONHASHSEED=0
|
||||
deps =
|
||||
-rrequirements/docs-requirements.txt
|
||||
-rrequirements/docs.txt
|
||||
changedir = doc
|
||||
commands =
|
||||
python -m sphinx -q -E -b linkcheck . {envtmpdir}/linkcheck {posargs}
|
||||
@ -147,19 +146,12 @@ deps =
|
||||
commands =
|
||||
python -m pre_commit run --all-files --hook-stage=manual
|
||||
|
||||
[testenv:manifest]
|
||||
deps =
|
||||
check-manifest
|
||||
commands =
|
||||
python -m check_manifest -v
|
||||
|
||||
[testenv:typecheck-mypy]
|
||||
description = run mypy to typecheck
|
||||
extras =
|
||||
test
|
||||
deps =
|
||||
mypy==1.7.0
|
||||
setuptools==68.0.0
|
||||
setenv =
|
||||
SKIP_ENV_SETUP=1
|
||||
commands =
|
||||
|
||||
Loading…
Reference in New Issue
Block a user