Skip to content

Switch to PEP 517 packaging using hatchling #2930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/install_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- uses: actions/checkout@v4
- uses: pypa/[email protected]
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.

Expand All @@ -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:
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/pypi-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
6 changes: 0 additions & 6 deletions INSTALL

This file was deleted.

8 changes: 0 additions & 8 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
black==24.3.0
click==8.0.4
flake8-isort
Expand All @@ -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
2 changes: 1 addition & 1 deletion docs/examples/opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
96 changes: 96 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" },
]
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",
]
20 changes: 0 additions & 20 deletions pytest.ini

This file was deleted.

13 changes: 2 additions & 11 deletions redis/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

65 changes: 0 additions & 65 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 .")
Loading