diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index ca775f5a5b..d822e1d499 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -36,9 +36,9 @@ runs: set -e echo "::group::Installing dependencies" - pip install -U setuptools wheel - pip install -r requirements.txt pip install -r dev_requirements.txt + pip uninstall -y redis # uninstall Redis package installed via redis-entraid + pip install -e . # install the working copy if [ "${{inputs.parser-backend}}" == "hiredis" ]; then pip install "hiredis${{inputs.hiredis-version}}" echo "PARSER_BACKEND=$(echo "${{inputs.parser-backend}}_${{inputs.hiredis-version}}" | sed 's/[^a-zA-Z0-9]/_/g')" >> $GITHUB_ENV diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index a3512b46dc..747b3b6d76 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 -r dev_requirements.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 5c879c1b3a..778dbe0b20 100755 --- a/.github/workflows/install_and_test.sh +++ b/.github/workflows/install_and_test.sh @@ -21,6 +21,7 @@ python -m venv ${DESTENV} source ${DESTENV}/bin/activate pip install --upgrade --quiet pip pip install --quiet -r dev_requirements.txt +pip uninstall -y redis # uninstall Redis package installed via redis-entraid invoke devenv --endpoints=all-stack invoke package diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 45e0d5bf8e..bb56e8a024 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -38,7 +38,7 @@ jobs: - uses: actions/checkout@v4 - uses: pypa/gh-action-pip-audit@v1.0.8 with: - inputs: requirements.txt dev_requirements.txt + inputs: dev_requirements.txt ignore-vulns: | GHSA-w596-4wvx-j9j6 # subversion related git pull, dependency for pytest. There is no impact here. @@ -54,6 +54,7 @@ jobs: - name: run code linters run: | pip install -r dev_requirements.txt + pip uninstall -y redis # uninstall Redis package installed via redis-entraid invoke linters redis_version: diff --git a/.github/workflows/pypi-publish.yaml b/.github/workflows/pypi-publish.yaml index e4815aa1b5..048d06c53c 100644 --- a/.github/workflows/pypi-publish.yaml +++ b/.github/workflows/pypi-publish.yaml @@ -18,15 +18,10 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.9 - - name: Install dev tools - run: | - pip install -r dev_requirements.txt - pip install twine wheel + - run: pip install build twine - name: Build package - run: | - python setup.py build - python setup.py sdist bdist_wheel + run: python -m build . - name: Basic package test prior to upload run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d87e6ba1c3..79983e4cb5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,7 +38,7 @@ Here's how to get started with your code contribution: 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 80afb437ff..0000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,8 +0,0 @@ -include INSTALL -include LICENSE -include README.md -include dev_requirements.txt -include pytest.ini -exclude __pycache__ -recursive-include tests * -recursive-exclude tests *.pyc diff --git a/dev_requirements.txt b/dev_requirements.txt index 619fbf479c..7ee7ac2b75 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,3 +1,4 @@ +build black==24.3.0 click==8.0.4 flake8-isort @@ -14,6 +15,5 @@ pytest-timeout ujson>=4.2.0 uvloop vulture>=2.3.0 -wheel>=0.30.0 numpy>=1.24.0 redis-entraid==0.3.0b1 diff --git a/docs/examples/opentelemetry/README.md b/docs/examples/opentelemetry/README.md index a1d1c04eda..58085c9637 100644 --- a/docs/examples/opentelemetry/README.md +++ b/docs/examples/opentelemetry/README.md @@ -24,7 +24,7 @@ source .venv/bin/active **Step 3**. Install dependencies: ```shell -pip install -r requirements.txt +pip install -e . ``` **Step 4**. Start the services using Docker and make sure Uptrace is running: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..7becde948e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,96 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "redis" +dynamic = ["version"] +description = "Python client for Redis database and key-value store" +readme = "README.md" +license = "MIT" +requires-python = ">=3.8" +authors = [ + { name = "Redis Inc.", email = "oss@redis.com" }, +] +keywords = [ + "Redis", + "database", + "key-value-store", +] +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 :: 3.13", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +dependencies = [ + 'async-timeout>=4.0.3; python_full_version<"3.11.3"', + "PyJWT~=2.9.0", +] + +[project.optional-dependencies] +hiredis = [ + "hiredis>=3.0.0", +] +ocsp = [ + "cryptography>=36.0.1", + "pyopenssl==20.0.1", + "requests>=2.31.0", +] + +[project.urls] +Changes = "https://github.com/redis/redis-py/releases" +Code = "https://github.com/redis/redis-py" +Documentation = "https://redis.readthedocs.io/en/latest/" +Homepage = "https://github.com/redis/redis-py" +"Issue tracker" = "https://github.com/redis/redis-py/issues" + +[tool.hatch.version] +path = "redis/__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/redis", + "/tests", + "dev_requirements.txt", +] + +[tool.hatch.build.targets.wheel] +include = [ + "/redis", +] + +[tool.pytest.ini_options] +addopts = "-s" +markers = [ + "redismod: run only the redis module tests", + "graph: run only the redisgraph tests", + "pipeline: pipeline tests", + "onlycluster: marks tests to be run only with cluster mode redis", + "onlynoncluster: marks tests to be run only with standalone redis", + "ssl: marker for only the ssl tests", + "asyncio: marker for async tests", + "replica: replica tests", + "experimental: run only experimental tests", + "cp_integration: credential provider integration tests", +] +asyncio_mode = "auto" +timeout = 30 +filterwarnings = [ + "always", + "ignore:RedisGraph support is deprecated as of Redis Stack 7.2:DeprecationWarning", + # Ignore a coverage warning when COVERAGE_CORE=sysmon for Pythons < 3.12. + "ignore:sys.monitoring isn't available:coverage.exceptions.CoverageWarning", +] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 68fee2b603..0000000000 --- a/pytest.ini +++ /dev/null @@ -1,20 +0,0 @@ -[pytest] -addopts = -s -markers = - redismod: run only the redis module tests - graph: run only the redisgraph tests - pipeline: pipeline tests - onlycluster: marks tests to be run only with cluster mode redis - onlynoncluster: marks tests to be run only with standalone redis - ssl: marker for only the ssl tests - asyncio: marker for async tests - replica: replica tests - experimental: run only experimental tests - cp_integration: credential provider integration tests -asyncio_mode = auto -timeout = 30 -filterwarnings = - always - ignore:RedisGraph support is deprecated as of Redis Stack 7.2:DeprecationWarning - # Ignore a coverage warning when COVERAGE_CORE=sysmon for Pythons < 3.12. - ignore:sys.monitoring isn't available:coverage.exceptions.CoverageWarning diff --git a/redis/__init__.py b/redis/__init__.py index 94324a0de8..f82a876b2d 100644 --- a/redis/__init__.py +++ b/redis/__init__.py @@ -1,5 +1,3 @@ -from importlib import metadata - from redis import asyncio # noqa from redis.backoff import default_backoff from redis.client import Redis, StrictRedis @@ -44,16 +42,9 @@ def int_or_str(value): return value -try: - __version__ = metadata.version("redis") -except metadata.PackageNotFoundError: - __version__ = "99.99.99" - +__version__ = "5.2.1" +VERSION = tuple(map(int_or_str, __version__.split("."))) -try: - VERSION = tuple(map(int_or_str, __version__.split("."))) -except AttributeError: - VERSION = tuple([99, 99, 99]) __all__ = [ "AuthenticationError", 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 2cde3fb51b..0000000000 --- a/setup.py +++ /dev/null @@ -1,65 +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.2.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 :: 3.13", - "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..8a5cae97b2 100644 --- a/tasks.py +++ b/tasks.py @@ -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 .")