Skip to content

Commit 483c021

Browse files
akxofek
andauthored
Switch to PEP 517 packaging using hatchling (#2930)
* Switch to PEP 517 packaging using hatchling Refs #1316 Refs #1649 Remake of #2388 Co-authored-by: Ofek Lev <[email protected]> * Use a single source of truth for version info * Uninstall redis wheel installed as redis-entraid dep * Add build as dev_requirement * Get rid of requirements.txt * Get rid of setuptools and wheel deps * Move pytest configuration to pyproject.toml * Retain tests and dev_requirements.txt in sdist --------- Co-authored-by: Ofek Lev <[email protected]>
1 parent d867660 commit 483c021

16 files changed

+110
-127
lines changed

Diff for: .github/actions/run-tests/action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ runs:
3636
set -e
3737
3838
echo "::group::Installing dependencies"
39-
pip install -U setuptools wheel
40-
pip install -r requirements.txt
4139
pip install -r dev_requirements.txt
40+
pip uninstall -y redis # uninstall Redis package installed via redis-entraid
41+
pip install -e . # install the working copy
4242
if [ "${{inputs.parser-backend}}" == "hiredis" ]; then
4343
pip install "hiredis${{inputs.hiredis-version}}"
4444
echo "PARSER_BACKEND=$(echo "${{inputs.parser-backend}}_${{inputs.hiredis-version}}" | sed 's/[^a-zA-Z0-9]/_/g')" >> $GITHUB_ENV

Diff for: .github/workflows/docs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
sudo apt-get install -yqq pandoc make
3737
- name: run code linters
3838
run: |
39-
pip install -r requirements.txt -r dev_requirements.txt -r docs/requirements.txt
39+
pip install -r dev_requirements.txt -r docs/requirements.txt
4040
invoke build-docs
4141
4242
- name: upload docs

Diff for: .github/workflows/install_and_test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ python -m venv ${DESTENV}
2121
source ${DESTENV}/bin/activate
2222
pip install --upgrade --quiet pip
2323
pip install --quiet -r dev_requirements.txt
24+
pip uninstall -y redis # uninstall Redis package installed via redis-entraid
2425
invoke devenv --endpoints=all-stack
2526
invoke package
2627

Diff for: .github/workflows/integration.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- uses: actions/checkout@v4
3939
- uses: pypa/[email protected]
4040
with:
41-
inputs: requirements.txt dev_requirements.txt
41+
inputs: dev_requirements.txt
4242
ignore-vulns: |
4343
GHSA-w596-4wvx-j9j6 # subversion related git pull, dependency for pytest. There is no impact here.
4444
@@ -54,6 +54,7 @@ jobs:
5454
- name: run code linters
5555
run: |
5656
pip install -r dev_requirements.txt
57+
pip uninstall -y redis # uninstall Redis package installed via redis-entraid
5758
invoke linters
5859
5960
redis_version:

Diff for: .github/workflows/pypi-publish.yaml

+2-7
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@ jobs:
1818
uses: actions/setup-python@v5
1919
with:
2020
python-version: 3.9
21-
- name: Install dev tools
22-
run: |
23-
pip install -r dev_requirements.txt
24-
pip install twine wheel
21+
- run: pip install build twine
2522

2623
- name: Build package
27-
run: |
28-
python setup.py build
29-
python setup.py sdist bdist_wheel
24+
run: python -m build .
3025

3126
- name: Basic package test prior to upload
3227
run: |

Diff for: CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Here's how to get started with your code contribution:
3838
a. python -m venv .venv
3939
b. source .venv/bin/activate
4040
c. pip install -r dev_requirements.txt
41-
c. pip install -r requirements.txt
41+
c. pip install -e .
4242

4343
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/).
4444
5. While developing, make sure the tests pass by running `invoke tests`

Diff for: INSTALL

-6
This file was deleted.

Diff for: MANIFEST.in

-8
This file was deleted.

Diff for: dev_requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
build
12
black==24.3.0
23
click==8.0.4
34
flake8-isort
@@ -14,6 +15,5 @@ pytest-timeout
1415
ujson>=4.2.0
1516
uvloop
1617
vulture>=2.3.0
17-
wheel>=0.30.0
1818
numpy>=1.24.0
1919
redis-entraid==0.3.0b1

Diff for: docs/examples/opentelemetry/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ source .venv/bin/active
2424
**Step 3**. Install dependencies:
2525

2626
```shell
27-
pip install -r requirements.txt
27+
pip install -e .
2828
```
2929

3030
**Step 4**. Start the services using Docker and make sure Uptrace is running:

Diff for: pyproject.toml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "redis"
7+
dynamic = ["version"]
8+
description = "Python client for Redis database and key-value store"
9+
readme = "README.md"
10+
license = "MIT"
11+
requires-python = ">=3.8"
12+
authors = [
13+
{ name = "Redis Inc.", email = "[email protected]" },
14+
]
15+
keywords = [
16+
"Redis",
17+
"database",
18+
"key-value-store",
19+
]
20+
classifiers = [
21+
"Development Status :: 5 - Production/Stable",
22+
"Environment :: Console",
23+
"Intended Audience :: Developers",
24+
"License :: OSI Approved :: MIT License",
25+
"Operating System :: OS Independent",
26+
"Programming Language :: Python",
27+
"Programming Language :: Python :: 3",
28+
"Programming Language :: Python :: 3 :: Only",
29+
"Programming Language :: Python :: 3.8",
30+
"Programming Language :: Python :: 3.9",
31+
"Programming Language :: Python :: 3.10",
32+
"Programming Language :: Python :: 3.11",
33+
"Programming Language :: Python :: 3.12",
34+
"Programming Language :: Python :: 3.13",
35+
"Programming Language :: Python :: Implementation :: CPython",
36+
"Programming Language :: Python :: Implementation :: PyPy",
37+
]
38+
dependencies = [
39+
'async-timeout>=4.0.3; python_full_version<"3.11.3"',
40+
"PyJWT~=2.9.0",
41+
]
42+
43+
[project.optional-dependencies]
44+
hiredis = [
45+
"hiredis>=3.0.0",
46+
]
47+
ocsp = [
48+
"cryptography>=36.0.1",
49+
"pyopenssl==20.0.1",
50+
"requests>=2.31.0",
51+
]
52+
53+
[project.urls]
54+
Changes = "https://github.com/redis/redis-py/releases"
55+
Code = "https://github.com/redis/redis-py"
56+
Documentation = "https://redis.readthedocs.io/en/latest/"
57+
Homepage = "https://github.com/redis/redis-py"
58+
"Issue tracker" = "https://github.com/redis/redis-py/issues"
59+
60+
[tool.hatch.version]
61+
path = "redis/__init__.py"
62+
63+
[tool.hatch.build.targets.sdist]
64+
include = [
65+
"/redis",
66+
"/tests",
67+
"dev_requirements.txt",
68+
]
69+
70+
[tool.hatch.build.targets.wheel]
71+
include = [
72+
"/redis",
73+
]
74+
75+
[tool.pytest.ini_options]
76+
addopts = "-s"
77+
markers = [
78+
"redismod: run only the redis module tests",
79+
"graph: run only the redisgraph tests",
80+
"pipeline: pipeline tests",
81+
"onlycluster: marks tests to be run only with cluster mode redis",
82+
"onlynoncluster: marks tests to be run only with standalone redis",
83+
"ssl: marker for only the ssl tests",
84+
"asyncio: marker for async tests",
85+
"replica: replica tests",
86+
"experimental: run only experimental tests",
87+
"cp_integration: credential provider integration tests",
88+
]
89+
asyncio_mode = "auto"
90+
timeout = 30
91+
filterwarnings = [
92+
"always",
93+
"ignore:RedisGraph support is deprecated as of Redis Stack 7.2:DeprecationWarning",
94+
# Ignore a coverage warning when COVERAGE_CORE=sysmon for Pythons < 3.12.
95+
"ignore:sys.monitoring isn't available:coverage.exceptions.CoverageWarning",
96+
]

Diff for: pytest.ini

-20
This file was deleted.

Diff for: redis/__init__.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from importlib import metadata
2-
31
from redis import asyncio # noqa
42
from redis.backoff import default_backoff
53
from redis.client import Redis, StrictRedis
@@ -44,16 +42,9 @@ def int_or_str(value):
4442
return value
4543

4644

47-
try:
48-
__version__ = metadata.version("redis")
49-
except metadata.PackageNotFoundError:
50-
__version__ = "99.99.99"
51-
45+
__version__ = "5.2.1"
46+
VERSION = tuple(map(int_or_str, __version__.split(".")))
5247

53-
try:
54-
VERSION = tuple(map(int_or_str, __version__.split(".")))
55-
except AttributeError:
56-
VERSION = tuple([99, 99, 99])
5748

5849
__all__ = [
5950
"AuthenticationError",

Diff for: requirements.txt

-2
This file was deleted.

Diff for: setup.py

-65
This file was deleted.

Diff for: tasks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ def clean(c):
9797
@task
9898
def package(c):
9999
"""Create the python packages"""
100-
run("python setup.py sdist bdist_wheel")
100+
run("python -m build .")

0 commit comments

Comments
 (0)