diff --git a/.readthedocs.yaml b/.readthedocs.yaml index ef6b82d3..d613e7bc 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -26,7 +26,4 @@ formats: [] # Optionally declare the Python requirements required to build your docs python: install: - - method: pip - path: . - extra_requirements: - - docs + - requirements: docs/requirements.txt diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 423a9f17..11937478 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,34 +14,69 @@ IRC in the ## Development +### Clone the repo + If you want to work on the code and send us a [pull request](https://help.github.com/articles/using-pull-requests), -first fork the repository on github to your own account. Then clone -your new repository and run the build scripts: +first fork the repository on github to your own account, then clone your new repository. -``` +```bash git clone git@github.com:/kazoo.git cd kazoo - make ``` -You need a supported version of Python installed and available as `python` -in your shell. To run Zookeeper you also need a Java runtime (JRE or JDK). -Please refer to the Zookeeper documentation for compatible Java versions for -each Zookeeper version. To run tests, you need to have `tox`, the Python -testing tool, installed in your shell. +### Install required utilities, zookeeper and support libraries + +You'll also need some other libraries and utilities installed in order to run tests. + +1. A supported version of python and its -dev package (again, apt install should work). +2. Zookeeper. +3. In order to run Zookeeper, you'll need a Java runtime (JRE or JDK). Please refer to the Zookeeper documentation for compatible Java versions for each Zookeeper version. +4. libkrb5-dev for kerberos authentication if you're connecting to Zookeeper with sasl (apt install should work for this) +5. Optionally pypy3. This is a little more complex to install. Something like the following should work + - `add-apt-repository ppa:pypy/ppa && sudo apt update && sudo apt install pypy3 pypy3-dev` +6. tox + +### Create a virtual env and populate it -You can run all the tests by calling: +```bash +python -m venv venv +source venv/bin/activate +pip install --upgrade pip setuptools wheel tox +pip install -e . +``` + +If you want to support eventlet, gevent, or sasl replace the last with (or an appropriate variant) +```bash +pip install -e ".[eventlet,gevent,sasl]" ``` - make test + +If you want to install the tools used by tox so you can use them yourself, also run (for python 3.9 and above only). For python 3.8, sadly, you'll have to read the pyproject.toml file and manually install. + +```bash +pip install --group ``` -Or to run individual tests: +### Running validations +To run all the validations (tests, formatting checks and so on), run + +```bash +tox ``` - export ZOOKEEPER_PATH=//bin/zookeeper/ - bin/pytest -v kazoo/tests/test_client.py::TestClient::test_create + +To run all the tests, use + +```bash +tox -e py +``` + +Or to run individual tests: + +```bash +export ZOOKEEPER_PATH=//bin/zookeeper/ +bin/pytest -v kazoo/tests/test_client.py::TestClient::test_create ``` The pytest test runner allows you to filter by test module, class or @@ -49,14 +84,13 @@ individual test method. If you made changes to the documentation, you can build it locally: -``` - make html +```bash +tox -e docs ``` -And then open `./docs/_build/html/index.html` in a web browser to +And then open `.tox//docs/_build/html/index.html` in a web browser to verify the correct rendering. - ## Bug Reports You can file issues here on GitHub. Please try to include as much information as @@ -94,7 +128,6 @@ When submitting a PR: - Please do not include merge commits in pull requests; include only commits with the new relevant code. - ## Code Review This project is production Mozilla code and subject to our [engineering practices and quality standards](https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Committing_Rules_and_Responsibilities). Every patch must be peer reviewed. diff --git a/MANIFEST.in b/MANIFEST.in index 1cdaf5e6..18a5371f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,21 +1,4 @@ -global-exclude *pyc *pyo __pycache__ -# Git files -exclude .gitignore -# CI/CD files -exclude .travis.yml.bak -exclude .clog.toml -prune .github - -exclude Makefile -exclude run_failure.py - include CHANGES.md include CONTRIBUTING.md include README.md include LICENSE -include MANIFEST.in - -include tox.ini - -recursive-include kazoo * -recursive-include docs * diff --git a/Makefile b/Makefile deleted file mode 100644 index f49c3c93..00000000 --- a/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -HERE = $(shell pwd) -BIN = $(HERE)/bin -PYTHON = $(BIN)/python -INSTALL = $(BIN)/pip install -TOX_VENV ?= py37 -BUILD_DIRS = bin build include lib lib64 man share - -PYTHON_EXE = $(shell [ -f $(PYTHON) ] && echo $(PYTHON) || echo python) -PYPY = $(shell $(PYTHON_EXE) -c "import sys; print(getattr(sys, 'pypy_version_info', False) and 'yes' or 'no')") -CI ?= false -CI_PYTHON_VERSION ?= $(shell $(PYTHON_EXE) -c "import sys; print('.'.join([str(s) for s in sys.version_info][:2]))") - -GREENLET_SUPPORTED = yes -ifeq ($(findstring 3.,$(CI_PYTHON_VERSION)), 3.) - GREENLET_SUPPORTED = no - VENV_CMD = $(PYTHON_EXE) -m venv . -else - VENV_CMD = $(PYTHON_EXE) -m virtualenv . -endif -ifeq ($(PYPY),yes) - GREENLET_SUPPORTED = no -endif - -.PHONY: all build clean test - -all: build - -$(PYTHON): - $(VENV_CMD) - -build: $(PYTHON) -ifeq ($(GREENLET_SUPPORTED),yes) - $(INSTALL) -U -r requirements_eventlet.txt - $(INSTALL) -U -r requirements_gevent.txt -endif -ifneq ($(CI), true) - $(INSTALL) -U -r requirements_sphinx.txt -endif - $(INSTALL) -U -r requirements.txt - $(PYTHON) setup.py develop - $(INSTALL) kazoo[test] - -clean: - rm -rf $(BUILD_DIRS) - -test: - tox -e$(TOX_VENV) - -html: - cd docs && \ - make html diff --git a/constraints.txt b/constraints.txt deleted file mode 100644 index 58be5adb..00000000 --- a/constraints.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Consistent testing environment. -# requirements.txt -eventlet>=0.17.1 ; implementation_name!='pypy' -gevent>=1.2 ; implementation_name!='pypy' - -# requirements-dev.txt -black==22.10.0 -coverage==6.3.2; python_version=="3.8" -coverage==7.10.7; python_version > "3.8" -flake8==5.0.2 -mypy==1.14.1 -objgraph==3.5.0 -pytest==6.2.5; python_version=="3.8" -pytest==8.4.2; python_version > "3.8" -pytest-cov==3.0.0; python_version=="3.8" -pytest-cov==7.0.0; python_version > "3.8" -pytest-timeout==2.2.0; python_version=="3.8" -pytest-timeout==2.4.0; python_version > "3.8" -pyOpenSSL<26.2.0 diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 00000000..86410a8f --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +Sphinx>=1.2.2 +sphinx-autodoc-typehints>=1 diff --git a/pyproject.toml b/pyproject.toml index 869ed27c..11717953 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,99 @@ [build-system] build-backend = 'setuptools.build_meta' requires = [ - 'setuptools >= 46.4.0', + 'setuptools >= 61.0.0', ] +[project] +name = "kazoo" +dynamic = ["version", "readme"] +description = "Higher Level Zookeeper Client" +requires-python = ">=3.8" +license = {text = "Apache 2.0"} +authors = [ + {name = "Kazoo team", email = "python-zk@googlegroups.com"}, +] +keywords = ["zookeeper", "lock", "leader", "configuration"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: Apache Software License", + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Communications", + "Topic :: System :: Distributed Computing", + "Topic :: System :: Networking", +] +dependencies = ["typing-extensions>=4.13.2"] + +[project.urls] +Homepage = "https://kazoo.readthedocs.io" +Documentation = "https://kazoo.readthedocs.io" +Changelog = "https://github.com/python-zk/kazoo/releases" +Source = "https://github.com/python-zk/kazoo" +"Bug Tracker" = "https://github.com/python-zk/kazoo/issues" + +[project.optional-dependencies] +eventlet = ["eventlet>=0.17.1; implementation_name != 'pypy'"] +gevent = ["gevent>=1.2; implementation_name != 'pypy'"] +sasl = ["pure_sasl>=0.5.1"] + +[dependency-groups] +black = ["black==22.10.0"] +pep8 = ["flake8==5.0.2"] +test-extras = [ + "objgraph==3.5.0", + "pyOpenSSL<26.2.0", + "pyjks", + "unittest-parametrize", +] +pytest = [ + "pytest==7.4.4; python_version == '3.8'", + "pytest==8.4.2; python_version > '3.8'", +] +test = [ + "coverage==6.3.2; python_version == '3.8'", + "coverage==7.10.7; python_version > '3.8'", + {include-group = "pytest"}, + "pytest-cov==3.0.0; python_version == '3.8'", + "pytest-cov==7.0.0; python_version > '3.8'", + "pytest-timeout==2.2.0; python_version == '3.8'", + "pytest-timeout==2.4.0; python_version > '3.8'", + {include-group = "test-extras"}, +] +mypy = [ + "mypy==1.14.1", + {include-group = "test-extras"}, + {include-group = "pytest"}, + "types-gevent", + "types-mock", + "types-objgraph", + "types-pyjks", +] + +[tool.setuptools] +zip-safe = false +include-package-data = true +packages = {find = {}} +license-files = ["LICENSE"] + +[tool.setuptools.package-data] +kazoo = ["py.typed"] + +[tool.setuptools.dynamic] +version = {attr = "kazoo.version.__version__"} +readme = {file = ["README.md", "CHANGES.md", "CONTRIBUTING.md"], content-type = "text/markdown"} + [tool.black] line-length = 79 # We need a later version of black for 312-314 diff --git a/setup.cfg b/setup.cfg index 5ef8ffb2..3c2fdf51 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,106 +1,2 @@ -[metadata] -name = kazoo -version = attr: kazoo.version.__version__ -author = Kazoo team -author_email = python-zk@googlegroups.com -url = https://kazoo.readthedocs.io -description = "Higher Level Zookeeper Client" -long_description = file: README.md, CHANGES.md -long_description_content_type = text/markdown -license = Apache 2.0 -license_files = - LICENSE -platform = any -keywords = zookeeper, lock, leader, configuration -classifiers = - Development Status :: 5 - Production/Stable - License :: OSI Approved :: Apache Software License - Intended Audience :: Developers - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Programming Language :: Python :: 3.13 - Programming Language :: Python :: 3.14 - Programming Language :: Python :: Implementation :: CPython - Programming Language :: Python :: Implementation :: PyPy - Topic :: Communications - Topic :: System :: Distributed Computing - Topic :: System :: Networking -project_urls = - Documentation = https://kazoo.readthedocs.io - Changelog = https://github.com/python-zk/kazoo/releases - Source = https://github.com/python-zk/kazoo - Bug Tracker = https://github.com/python-zk/kazoo/issues - - -[options] -zip_safe = false -include_package_data = true -packages = find: -install_requires = - typing-extensions - -[options.package_data] -kazoo = py.typed - -[aliases] -release = sdist bdist_wheel - [egg_info] tag_build = dev - -[options.extras_require] -dev = - black - flake8 - -# I have to pin this HERE because I can't persuade vscode to -# look in constraints.txt -other = - pyOpenSSL<26.2.0 - typing-extensions - -test = - objgraph - pytest - pytest-cov - pytest-timeout - gevent>=1.2 ; implementation_name!='pypy' - eventlet>=0.17.1 ; implementation_name!='pypy' - pyjks - unittest-parametrize - %(other)s - -eventlet = - eventlet>=0.17.1 - -gevent = - gevent>=1.2 - -sasl = - pure_sasl>=0.5.1 - -docs = - Sphinx>=1.2.2 - sphinx-autodoc-typehints>=1 - -typing = - mypy==1.14.1 - types-gevent - types-mock - types-objgraph - types-pyjks - -alldeps = - %(dev)s - %(eventlet)s - %(gevent)s - %(sasl)s - %(docs)s - %(other)s - %(typing)s diff --git a/tox.ini b/tox.ini index ab62ae26..c6bf0073 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] -minversion = 4.3.4 requires= + tox>=4.22 virtualenv>=20.7.2 skip_missing_interpreters=True envlist = @@ -13,7 +13,7 @@ isolated_build = true [testenv] wheel = True wheel_build_env = build -install_command = pip install -c{toxinidir}/constraints.txt {opts} {packages} +install_command = pip install {opts} {packages} passenv = CI TOX_* @@ -21,9 +21,9 @@ passenv = ZOOKEEPER_* setenv = pypy3: PYPY=1 -extras = +dependency_groups = test - docs: docs +extras = gevent: gevent eventlet: eventlet sasl: sasl @@ -41,27 +41,32 @@ commands = [testenv:build] -[testenv:pep8] -extras = alldeps +[testenv:docs] +dependency_groups = + test-extras +extras = + eventlet + gevent + sasl deps = - flake8 + -r{toxinidir}/docs/requirements.txt +commands = sphinx-build -b html docs {toxworkdir}/docs/html + +[testenv:pep8] +dependency_groups = pep8 usedevelop = True commands = flake8 {posargs} {toxinidir}/kazoo [testenv:black] -extras = -deps = - black +dependency_groups = black usedevelop = True -commands = black --check {posargs: {toxinidir}/kazoo {toxinidir}/kazoo} +commands = black --check {posargs: {toxinidir}/kazoo} [testenv:mypy] -extras = alldeps -deps = - mypy - types-mock - pyopenssl - pytest - unittest-parametrize +dependency_groups = mypy +extras = + eventlet + gevent + sasl usedevelop = True commands = mypy --config-file {toxinidir}/pyproject.toml {toxinidir}/kazoo