From a25b269711f329fd0f1cbed7701d6fbf8588819a Mon Sep 17 00:00:00 2001 From: Mikhail Koviazin Date: Tue, 7 Oct 2025 22:27:19 +0200 Subject: [PATCH 1/6] Switch from setup.py to pyproject.toml Signed-off-by: Mikhail Koviazin --- .github/wordlist.txt | 2 + .github/workflows/docs.yaml | 2 +- .github/workflows/install_and_test.sh | 2 +- .github/workflows/integration.yaml | 6 +- .github/workflows/pypi-publish.yaml | 5 +- CONTRIBUTING.md | 7 +- INSTALL | 5 +- dev_requirements.txt | 17 ----- docs/requirements.txt | 8 --- pyproject.toml | 96 +++++++++++++++++++++++++++ requirements.txt | 1 - setup.py | 62 ----------------- tasks.py | 4 +- 13 files changed, 111 insertions(+), 106 deletions(-) delete mode 100644 dev_requirements.txt delete mode 100644 docs/requirements.txt create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/.github/wordlist.txt b/.github/wordlist.txt index a62df860..bfefe897 100644 --- a/.github/wordlist.txt +++ b/.github/wordlist.txt @@ -128,6 +128,7 @@ pubsub punsubscribe py pypi +pyproject quickstart readonly readwrite @@ -149,6 +150,7 @@ subcommands thevalueofmykey timeseries toctree +toml topk triaging txt diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index a2a280dd..2b8daf1f 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -38,7 +38,7 @@ jobs: sudo apt-get install -yqq pandoc make - name: run code linters run: | - pip install -r requirements.txt -r dev_requirements.txt -r docs/requirements.txt + pip install '.[dev,docs]' invoke build-docs - name: upload docs diff --git a/.github/workflows/install_and_test.sh b/.github/workflows/install_and_test.sh index edb2e7fe..13b386a0 100755 --- a/.github/workflows/install_and_test.sh +++ b/.github/workflows/install_and_test.sh @@ -20,7 +20,7 @@ fi python -m venv ${DESTENV} source ${DESTENV}/bin/activate pip install --upgrade --quiet pip setuptools wheel -pip install --quiet -r dev_requirements.txt +pip install --quiet '.[dev]' invoke devenv invoke package diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 80a90734..82d6dc9a 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -32,7 +32,6 @@ jobs: - uses: actions/checkout@v5 - uses: pypa/gh-action-pip-audit@v1.1.0 with: - inputs: requirements.txt dev_requirements.txt ignore-vulns: | GHSA-w596-4wvx-j9j6 # subversion related git pull, dependency for pytest. There is no impact here. @@ -47,7 +46,7 @@ jobs: cache: 'pip' - name: run code linters run: | - pip install -r dev_requirements.txt + pip install '.[dev]' invoke linters get-date: @@ -116,8 +115,7 @@ jobs: - name: run tests run: | pip install -U setuptools wheel - pip install -r requirements.txt - pip install -r dev_requirements.txt + pip install '.[dev]' if [ "${{matrix.connection-type}}" == "libvalkey" ]; then pip install "libvalkey>=4.0.1" fi diff --git a/.github/workflows/pypi-publish.yaml b/.github/workflows/pypi-publish.yaml index 940115fd..fd56ad0a 100644 --- a/.github/workflows/pypi-publish.yaml +++ b/.github/workflows/pypi-publish.yaml @@ -22,13 +22,12 @@ jobs: python-version: 3.9 - name: Install dev tools run: | - pip install -r dev_requirements.txt + pip install '.[dev]' pip install twine wheel - name: Build package run: | - python setup.py build - python setup.py sdist bdist_wheel + python -m build -sw - name: Basic package test prior to upload run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 30880dec..812b79b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,12 +89,11 @@ Here's how to get started with your code contribution: 1. Create your own fork of valkey-py 2. Do the changes in your fork 3. - *Create a virtualenv and install the development dependencies from the dev_requirements.txt file:* + *Create a virtualenv and install the development dependencies:* a. python -m venv .venv b. source .venv/bin/activate - c. pip install -r dev_requirements.txt - c. pip install -r requirements.txt + c. pip install '.[dev]' 4. If you need a development environment, run `invoke devenv`. Note: this relies on docker compose to build environments, and assumes that you have a version supporting [docker profiles](https://docs.docker.com/compose/profiles/). 5. While developing, make sure the tests pass by running `invoke tests` @@ -106,7 +105,7 @@ To see what else is part of the automation, run `invoke -l` ## The Development Environment Running `invoke devenv` installs the development dependencies specified -in the dev_requirements.txt. It starts all of the dockers used by this +in `pyproject.toml`. It starts all of the dockers used by this project, and leaves them running. These can be easily cleaned up with `invoke clean`. NOTE: it is assumed that the user running these tests, can execute docker and its various commands. diff --git a/INSTALL b/INSTALL index c72fbe11..a7aa4e74 100644 --- a/INSTALL +++ b/INSTALL @@ -1,6 +1,5 @@ Please use - python setup.py install - -and report errors to via https://github.com/valkey-io/valkey-py/issues/new + pip install . +and report errors to us via https://github.com/valkey-io/valkey-py/issues/new diff --git a/dev_requirements.txt b/dev_requirements.txt deleted file mode 100644 index a015cd46..00000000 --- a/dev_requirements.txt +++ /dev/null @@ -1,17 +0,0 @@ -black -cachetools -click -flake8-isort -flake8 -flynt -invoke -mock -packaging>=20.4 -pytest -pytest-asyncio -pytest-cov -pytest-timeout -ujson>=4.2.0 -uvloop; implementation_name != "pypy" -vulture>=2.3.0 -wheel>=0.30.0 diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 5b15c092..00000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -sphinx>=5.0,<7.0 -docutils<0.18 -nbsphinx -sphinx_gallery -ipython -sphinx-autodoc-typehints -furo -pandoc diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..67ef69bc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,96 @@ +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "valkey" +version = "6.1.1" +description = "Python client for Valkey forked from redis-py" +readme = "README.md" +license = { file = "LICENSE" } +keywords = ["Valkey", "key-value store", "database"] + +authors = [ + { name = "valkey-py authors", email = "valkey-py@lists.valkey.io" } +] + +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "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", +] + +requires-python = ">=3.10" + +dependencies = [ + 'async-timeout>=4.0.3; python_full_version<"3.11.3"', +] + +[project.optional-dependencies] +libvalkey = ["libvalkey>=4.0.1"] +ocsp = ["cryptography>=36.0.1", "pyopenssl==23.2.1", "requests>=2.31.0"] +dev = [ + "black", + "build", + "cachetools", + "click", + "flake8-isort", + "flake8", + "flynt", + "invoke", + "mock", + "packaging>=20.4", + "pytest", + "pytest-asyncio", + "pytest-cov", + "pytest-timeout", + "ujson>=4.2.0", + "uvloop; implementation_name != 'pypy'", + "vulture>=2.3.0", + "wheel>=0.30.0", +] +docs = [ + "sphinx>=5.0,<7.0", + "docutils<0.18", + "nbsphinx", + "sphinx_gallery", + "ipython", + "sphinx-autodoc-typehints", + "furo", + "pandoc", +] + +[project.urls] +Homepage = "https://github.com/valkey-io/valkey-py" +Documentation = "https://valkey-py.readthedocs.io/en/latest/" +Changes = "https://github.com/valkey-io/valkey-py/releases" +Code = "https://github.com/valkey-io/valkey-py" +"Issue tracker" = "https://github.com/valkey-io/valkey-py/issues" + +[tool.setuptools.packages.find] +include = [ + "valkey", + "valkey._parsers", + "valkey.asyncio", + "valkey.commands", + "valkey.commands.bf", + "valkey.commands.json", + "valkey.commands.search", + "valkey.commands.timeseries", + "valkey.commands.graph", +] + +[tool.setuptools.package-data] +valkey = ["py.typed"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 7b5745c8..00000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -async-timeout>=4.0.3; python_full_version<"3.11.3" diff --git a/setup.py b/setup.py deleted file mode 100644 index 11b1dcd1..00000000 --- a/setup.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -from setuptools import find_packages, setup - -setup( - name="valkey", - description="Python client for Valkey forked from redis-py", - long_description=open("README.md").read().strip(), - long_description_content_type="text/markdown", - keywords=["Valkey", "key-value store", "database"], - license="MIT", - version="6.1.1", - packages=find_packages( - include=[ - "valkey", - "valkey._parsers", - "valkey.asyncio", - "valkey.commands", - "valkey.commands.bf", - "valkey.commands.json", - "valkey.commands.search", - "valkey.commands.timeseries", - "valkey.commands.graph", - "valkey.parsers", - ] - ), - package_data={"valkey": ["py.typed"]}, - include_package_data=True, - url="https://github.com/valkey-io/valkey-py", - project_urls={ - "Documentation": "https://valkey-py.readthedocs.io/en/latest/", - "Changes": "https://github.com/valkey-io/valkey-py/releases", - "Code": "https://github.com/valkey-io/valkey-py", - "Issue tracker": "https://github.com/valkey-io/valkey-py/issues", - }, - author="valkey-py authors", - author_email="valkey-py@lists.valkey.io", - python_requires=">=3.10", - install_requires=[ - 'async-timeout>=4.0.3; python_full_version<"3.11.3"', - ], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "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", - ], - extras_require={ - "libvalkey": ["libvalkey>=4.0.1"], - "ocsp": ["cryptography>=36.0.1", "pyopenssl==23.2.1", "requests>=2.31.0"], - }, -) diff --git a/tasks.py b/tasks.py index 457f605d..e3624e61 100644 --- a/tasks.py +++ b/tasks.py @@ -20,7 +20,7 @@ def devenv(c): @task def build_docs(c): """Generates the sphinx documentation.""" - run("pip install -r docs/requirements.txt") + run("pip install '.[docs]'") run("make -C docs html") @@ -91,4 +91,4 @@ def clean(c): @task def package(c): """Create the python packages""" - run("python setup.py sdist bdist_wheel") + run("python -m build -sw") From 7315ba6fda6c9effe333c775c8aa0be0a3bde821 Mon Sep 17 00:00:00 2001 From: Mikhail Koviazin Date: Tue, 7 Oct 2025 22:32:53 +0200 Subject: [PATCH 2/6] github: try to fix pip-audit Signed-off-by: Mikhail Koviazin --- .github/workflows/integration.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 82d6dc9a..27609624 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -32,6 +32,7 @@ jobs: - uses: actions/checkout@v5 - uses: pypa/gh-action-pip-audit@v1.1.0 with: + inputs: . ignore-vulns: | GHSA-w596-4wvx-j9j6 # subversion related git pull, dependency for pytest. There is no impact here. From c34b03dda67b570b5b22e9bf517993368ca5d85b Mon Sep 17 00:00:00 2001 From: Mikhail Koviazin Date: Sat, 11 Oct 2025 11:15:20 +0200 Subject: [PATCH 3/6] Switch to hatchling packaging backend Signed-off-by: Mikhail Koviazin --- .github/wordlist.txt | 1 + .github/workflows/docs.yaml | 2 +- .github/workflows/install_and_test.sh | 4 +-- .github/workflows/integration.yaml | 7 ++-- .github/workflows/pypi-publish.yaml | 6 ++-- CONTRIBUTING.md | 6 ++-- dev_requirements.txt | 17 +++++++++ docs/requirements.txt | 8 +++++ pyproject.toml | 52 ++++----------------------- tasks.py | 2 +- 10 files changed, 46 insertions(+), 59 deletions(-) create mode 100644 dev_requirements.txt create mode 100644 docs/requirements.txt diff --git a/.github/wordlist.txt b/.github/wordlist.txt index bfefe897..3d5a7490 100644 --- a/.github/wordlist.txt +++ b/.github/wordlist.txt @@ -90,6 +90,7 @@ firsttimersonly fo genindex gmail +hatchling html http https diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 2b8daf1f..67310aad 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -38,7 +38,7 @@ jobs: sudo apt-get install -yqq pandoc make - name: run code linters run: | - pip install '.[dev,docs]' + pip install -r dev_requrements.txt -r docs/requirements.txt invoke build-docs - name: upload docs diff --git a/.github/workflows/install_and_test.sh b/.github/workflows/install_and_test.sh index 13b386a0..63a9a7c8 100755 --- a/.github/workflows/install_and_test.sh +++ b/.github/workflows/install_and_test.sh @@ -19,8 +19,8 @@ if [ -d ${DESTENV} ]; then fi python -m venv ${DESTENV} source ${DESTENV}/bin/activate -pip install --upgrade --quiet pip setuptools wheel -pip install --quiet '.[dev]' +pip install --upgrade --quiet pip +pip install --quiet -r dev_requrements.txt invoke devenv invoke package diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 27609624..83b99e49 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -32,7 +32,7 @@ jobs: - uses: actions/checkout@v5 - uses: pypa/gh-action-pip-audit@v1.1.0 with: - inputs: . + inputs: . dev_requirements.txt ignore-vulns: | GHSA-w596-4wvx-j9j6 # subversion related git pull, dependency for pytest. There is no impact here. @@ -47,7 +47,7 @@ jobs: cache: 'pip' - name: run code linters run: | - pip install '.[dev]' + pip install -r dev_requirements.txt invoke linters get-date: @@ -115,8 +115,7 @@ jobs: - name: run tests run: | - pip install -U setuptools wheel - pip install '.[dev]' + pip install -r dev_requirements.txt if [ "${{matrix.connection-type}}" == "libvalkey" ]; then pip install "libvalkey>=4.0.1" fi diff --git a/.github/workflows/pypi-publish.yaml b/.github/workflows/pypi-publish.yaml index fd56ad0a..bba25301 100644 --- a/.github/workflows/pypi-publish.yaml +++ b/.github/workflows/pypi-publish.yaml @@ -22,12 +22,12 @@ jobs: python-version: 3.9 - name: Install dev tools run: | - pip install '.[dev]' - pip install twine wheel + pip install -r dev_requirements.txt + pip install twine - name: Build package run: | - python -m build -sw + hatchling build - name: Basic package test prior to upload run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 812b79b3..356fb595 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,11 +89,11 @@ Here's how to get started with your code contribution: 1. Create your own fork of valkey-py 2. Do the changes in your fork 3. - *Create a virtualenv and install the development dependencies:* + *Create a virtualenv and install the development dependencies from the dev_requirements.txt file:* a. python -m venv .venv b. source .venv/bin/activate - c. pip install '.[dev]' + c. pip install -r dev_requirements.txt 4. If you need a development environment, run `invoke devenv`. Note: this relies on docker compose to build environments, and assumes that you have a version supporting [docker profiles](https://docs.docker.com/compose/profiles/). 5. While developing, make sure the tests pass by running `invoke tests` @@ -105,7 +105,7 @@ To see what else is part of the automation, run `invoke -l` ## The Development Environment Running `invoke devenv` installs the development dependencies specified -in `pyproject.toml`. It starts all of the dockers used by this +in the dev_requirements.txt. It starts all of the dockers used by this project, and leaves them running. These can be easily cleaned up with `invoke clean`. NOTE: it is assumed that the user running these tests, can execute docker and its various commands. diff --git a/dev_requirements.txt b/dev_requirements.txt new file mode 100644 index 00000000..72783105 --- /dev/null +++ b/dev_requirements.txt @@ -0,0 +1,17 @@ +black +cachetools +click +flake8-isort +flake8 +flynt +hatchling +invoke +mock +packaging>=20.4 +pytest +pytest-asyncio +pytest-cov +pytest-timeout +ujson>=4.2.0 +uvloop; implementation_name != "pypy" +vulture>=2.3.0 diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 00000000..5b15c092 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,8 @@ +sphinx>=5.0,<7.0 +docutils<0.18 +nbsphinx +sphinx_gallery +ipython +sphinx-autodoc-typehints +furo +pandoc diff --git a/pyproject.toml b/pyproject.toml index 67ef69bc..08d9bdd4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["setuptools>=61.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "valkey" @@ -41,36 +41,7 @@ dependencies = [ [project.optional-dependencies] libvalkey = ["libvalkey>=4.0.1"] ocsp = ["cryptography>=36.0.1", "pyopenssl==23.2.1", "requests>=2.31.0"] -dev = [ - "black", - "build", - "cachetools", - "click", - "flake8-isort", - "flake8", - "flynt", - "invoke", - "mock", - "packaging>=20.4", - "pytest", - "pytest-asyncio", - "pytest-cov", - "pytest-timeout", - "ujson>=4.2.0", - "uvloop; implementation_name != 'pypy'", - "vulture>=2.3.0", - "wheel>=0.30.0", -] -docs = [ - "sphinx>=5.0,<7.0", - "docutils<0.18", - "nbsphinx", - "sphinx_gallery", - "ipython", - "sphinx-autodoc-typehints", - "furo", - "pandoc", -] + [project.urls] Homepage = "https://github.com/valkey-io/valkey-py" @@ -79,18 +50,9 @@ Changes = "https://github.com/valkey-io/valkey-py/releases" Code = "https://github.com/valkey-io/valkey-py" "Issue tracker" = "https://github.com/valkey-io/valkey-py/issues" -[tool.setuptools.packages.find] +[tool.hatch.build.targets.sdist] include = [ - "valkey", - "valkey._parsers", - "valkey.asyncio", - "valkey.commands", - "valkey.commands.bf", - "valkey.commands.json", - "valkey.commands.search", - "valkey.commands.timeseries", - "valkey.commands.graph", + "/tests", + "/valkey", + "dev_requirements.txt", ] - -[tool.setuptools.package-data] -valkey = ["py.typed"] diff --git a/tasks.py b/tasks.py index e3624e61..38beeb70 100644 --- a/tasks.py +++ b/tasks.py @@ -91,4 +91,4 @@ def clean(c): @task def package(c): """Create the python packages""" - run("python -m build -sw") + run("hatchling build") From 7a8a291f1844a7cd7e66b0871248c46ab38542e5 Mon Sep 17 00:00:00 2001 From: Mikhail Koviazin Date: Sat, 11 Oct 2025 11:20:48 +0200 Subject: [PATCH 4/6] github: try to fix pip-audit again Signed-off-by: Mikhail Koviazin --- .github/workflows/integration.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 83b99e49..36212c16 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -32,7 +32,6 @@ jobs: - uses: actions/checkout@v5 - uses: pypa/gh-action-pip-audit@v1.1.0 with: - inputs: . dev_requirements.txt ignore-vulns: | GHSA-w596-4wvx-j9j6 # subversion related git pull, dependency for pytest. There is no impact here. From 6edebae73a35920e82c3af4dc282bf73c6988b94 Mon Sep 17 00:00:00 2001 From: Mikhail Koviazin Date: Sat, 11 Oct 2025 11:22:45 +0200 Subject: [PATCH 5/6] github: more fixes to pip-audit Signed-off-by: Mikhail Koviazin --- .github/workflows/integration.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 36212c16..68463654 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -32,6 +32,12 @@ jobs: - uses: actions/checkout@v5 - uses: pypa/gh-action-pip-audit@v1.1.0 with: + inputs: . + ignore-vulns: | + GHSA-w596-4wvx-j9j6 # subversion related git pull, dependency for pytest. There is no impact here. + - uses: pypa/gh-action-pip-audit@v1.1.0 + with: + inputs: dev_requirements.txt ignore-vulns: | GHSA-w596-4wvx-j9j6 # subversion related git pull, dependency for pytest. There is no impact here. @@ -115,6 +121,7 @@ jobs: - name: run tests run: | pip install -r dev_requirements.txt + pip install . if [ "${{matrix.connection-type}}" == "libvalkey" ]; then pip install "libvalkey>=4.0.1" fi From e5c3a3684a8b323c685bfc7ea43b8b578dd32240 Mon Sep 17 00:00:00 2001 From: Mikhail Koviazin Date: Sat, 11 Oct 2025 11:39:19 +0200 Subject: [PATCH 6/6] fix typo Signed-off-by: Mikhail Koviazin --- .github/workflows/docs.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 67310aad..b27f4531 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -38,7 +38,8 @@ jobs: sudo apt-get install -yqq pandoc make - name: run code linters run: | - pip install -r dev_requrements.txt -r docs/requirements.txt + pip install -r dev_requirements.txt -r docs/requirements.txt + pip install . invoke build-docs - name: upload docs