From b3c69a3fd2ee403ff7a55ef01e675187f71763f0 Mon Sep 17 00:00:00 2001 From: woutdenolf Date: Mon, 23 Dec 2024 13:49:27 +0100 Subject: [PATCH] convert to pyproject.toml --- .github/workflows/docs.yaml | 2 +- .github/workflows/integration.yaml | 13 +--- .github/workflows/pypi-publish.yaml | 7 +- CONTRIBUTING.md | 5 +- INSTALL | 6 -- MANIFEST.in | 6 -- dev_requirements.txt | 19 ------ doctests/README.md | 6 +- doctests/requirements.txt | 5 -- pyproject.toml | 91 +++++++++++++++++++++++++ requirements.txt | 2 - setup.py | 64 ----------------- tasks.py | 4 +- tests/test_asyncio/testdata/__init__.py | 0 tests/test_parsers/__init__.py | 0 tests/testdata/__init__.py | 0 16 files changed, 102 insertions(+), 128 deletions(-) delete mode 100644 INSTALL delete mode 100644 MANIFEST.in delete mode 100644 dev_requirements.txt delete mode 100644 doctests/requirements.txt create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py create mode 100644 tests/test_asyncio/testdata/__init__.py create mode 100644 tests/test_parsers/__init__.py create mode 100644 tests/testdata/__init__.py diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index a3512b46dc..7fcd94b5f3 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -36,7 +36,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,docbuild] invoke build-docs - name: upload docs diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 7c74de5290..4f53669780 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -32,17 +32,6 @@ env: CURRENT_REDIS_VERSION: '7.4.1' jobs: - dependency-audit: - name: Dependency audit - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: pypa/gh-action-pip-audit@v1.0.8 - 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. - lint: name: Code linters runs-on: ubuntu-latest @@ -54,7 +43,7 @@ jobs: cache: 'pip' - name: run code linters run: | - pip install -r dev_requirements.txt + pip install .[dev] invoke linters redis_version: diff --git a/.github/workflows/pypi-publish.yaml b/.github/workflows/pypi-publish.yaml index e4815aa1b5..a4de6288e1 100644 --- a/.github/workflows/pypi-publish.yaml +++ b/.github/workflows/pypi-publish.yaml @@ -20,13 +20,12 @@ jobs: python-version: 3.9 - name: Install dev tools run: | - pip install -r dev_requirements.txt - pip install twine wheel + pip install .[dev] + pip install twine wheel build - name: Build package run: | - python setup.py build - python setup.py sdist bdist_wheel + python -m build - name: Basic package test prior to upload run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d87e6ba1c3..43fb799db2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,12 +33,11 @@ Here's how to get started with your code contribution: 1. Create your own fork of redis-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 project with 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 -e . 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` diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 951f7dea8a..0000000000 --- a/INSTALL +++ /dev/null @@ -1,6 +0,0 @@ - -Please use - python setup.py install - -and report errors to Andy McCurdy (sedrik@gmail.com) - diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 97fa305889..0000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include INSTALL -include LICENSE -include README.md -exclude __pycache__ -recursive-include tests * -recursive-exclude tests *.pyc diff --git a/dev_requirements.txt b/dev_requirements.txt deleted file mode 100644 index be74470ec2..0000000000 --- a/dev_requirements.txt +++ /dev/null @@ -1,19 +0,0 @@ -black==24.3.0 -click==8.0.4 -flake8-isort -flake8 -flynt~=0.69.0 -invoke==2.2.0 -mock -packaging>=20.4 -pytest -pytest-asyncio>=0.23.0,<0.24.0 -pytest-cov -pytest-profiling==1.7.0 -pytest-timeout -ujson>=4.2.0 -uvloop -vulture>=2.3.0 -wheel>=0.30.0 -numpy>=1.24.0 -redis-entraid==0.1.0b1 diff --git a/doctests/README.md b/doctests/README.md index 9dd6eaeb5d..a3905b5afe 100644 --- a/doctests/README.md +++ b/doctests/README.md @@ -13,12 +13,10 @@ See https://github.com/redis-stack/redis-stack-website#readme for more details. ## How to test examples Examples are standalone python scripts, committed to the *doctests* directory. These scripts assume that the -```requirements.txt``` and ```dev_requirements.txt``` from this repository have been installed, as per below. +dependencies from this repository have been installed, as per below. ```bash -pip install -r requirements.txt -pip install -r dev_requirements.txt -pip install -r doctests/requirements.txt +pip install .[dev,doctest] ``` Note - the CI process, runs the basic ```black``` and ```isort``` linters against the examples. Assuming diff --git a/doctests/requirements.txt b/doctests/requirements.txt deleted file mode 100644 index 209d87b9c8..0000000000 --- a/doctests/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -numpy -pandas -requests -sentence_transformers -tabulate diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..27fa23c2e4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,91 @@ +[build-system] +requires = ["setuptools>=42"] +build-backend = "setuptools.build_meta" + +[project] +name = "redis" +version = "5.3.0b4" +description = "Python client for Redis database and key-value store" +readme = "README.md" +keywords = ["Redis", "key-value store", "database"] +license = {text = "MIT"} +authors = [ + {name = "Redis Inc.", email = "oss@redis.com"} +] +requires-python = ">=3.8" +dependencies = [ + "async-timeout>=4.0.3; python_full_version < \"3.11.3\"", + "PyJWT~=2.9.0" +] +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.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy" +] + +[project.urls] +Homepage = "https://github.com/redis/redis-py" +Documentation = "https://redis.readthedocs.io/en/latest/" +Repository = "https://github.com/redis/redis-py" +Issues = "https://github.com/redis/redis-py/issues" +Changes = "https://github.com/redis/redis-py/releases" + +[project.optional-dependencies] +hiredis = ["hiredis>=3.0.0"] +ocsp = ["cryptography>=36.0.1", "pyopenssl==23.2.1", "requests>=2.31.0"] +dev = [ + "black==24.3.0", + "click==8.0.4", + "flake8-isort", + "flake8", + "flynt~=0.69.0", + "invoke==2.2.0", + "mock", + "packaging>=20.4", + "pytest", + "pytest-asyncio>=0.23.0,<0.24.0", + "pytest-cov", + "pytest-profiling==1.7.0", + "pytest-timeout", + "ujson>=4.2.0", + "uvloop", + "vulture>=2.3.0", + "wheel>=0.30.0", + "numpy>=1.24.0", + "redis-entraid>=0.1.0b1" +] +docbuild = [ + "sphinx>=5.0,<7.0", + "docutils<0.18", + "nbsphinx", + "sphinx_gallery", + "ipython", + "sphinx-autodoc-typehints", + "furo", + "pandoc" +] +doctest = [ + "numpy", + "pandas", + "requests", + "sentence_transformers", + "tabulate" +] + +[tool.setuptools.packages.find] +where = ["redis", "tests"] + +[tool.setuptools.package-data] +redis = ["py.typed"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9760e5bb13..0000000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -async-timeout>=4.0.3 -PyJWT~=2.9.0 \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 02853251b2..0000000000 --- a/setup.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -from setuptools import find_packages, setup - -setup( - name="redis", - description="Python client for Redis database and key-value store", - long_description=open("README.md").read().strip(), - long_description_content_type="text/markdown", - keywords=["Redis", "key-value store", "database"], - license="MIT", - version="5.1.1", - packages=find_packages( - include=[ - "redis", - "redis._parsers", - "redis.asyncio", - "redis.auth", - "redis.commands", - "redis.commands.bf", - "redis.commands.json", - "redis.commands.search", - "redis.commands.timeseries", - "redis.commands.graph", - "redis.parsers", - ] - ), - package_data={"redis": ["py.typed"]}, - include_package_data=True, - url="https://github.com/redis/redis-py", - project_urls={ - "Documentation": "https://redis.readthedocs.io/en/latest/", - "Changes": "https://github.com/redis/redis-py/releases", - "Code": "https://github.com/redis/redis-py", - "Issue tracker": "https://github.com/redis/redis-py/issues", - }, - author="Redis Inc.", - author_email="oss@redis.com", - python_requires=">=3.8", - install_requires=[ - 'async-timeout>=4.0.3; python_full_version<"3.11.3"', - "PyJWT~=2.9.0", - ], - 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.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - ], - extras_require={ - "hiredis": ["hiredis>=3.0.0"], - "ocsp": ["cryptography>=36.0.1", "pyopenssl==23.2.1", "requests>=2.31.0"], - }, -) diff --git a/tasks.py b/tasks.py index f7b728aed4..c76a399fef 100644 --- a/tasks.py +++ b/tasks.py @@ -20,7 +20,7 @@ def devenv(c, endpoints="all"): @task def build_docs(c): """Generates the sphinx documentation.""" - run("pip install -r docs/requirements.txt") + run("pip install .[doc]") run("make -C docs html") @@ -97,4 +97,4 @@ def clean(c): @task def package(c): """Create the python packages""" - run("python setup.py sdist bdist_wheel") + run("python -m build") diff --git a/tests/test_asyncio/testdata/__init__.py b/tests/test_asyncio/testdata/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_parsers/__init__.py b/tests/test_parsers/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/testdata/__init__.py b/tests/testdata/__init__.py new file mode 100644 index 0000000000..e69de29bb2