Skip to content

Commit c858f8e

Browse files
authored
Single sourcing the package version (#1791)
1 parent d17ff59 commit c858f8e

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

redis/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import sys
2+
3+
if sys.version_info >= (3, 8):
4+
from importlib import metadata
5+
else:
6+
import importlib_metadata as metadata
7+
18
from redis.client import Redis, StrictRedis
29
from redis.cluster import RedisCluster
310
from redis.connection import (
@@ -38,7 +45,10 @@ def int_or_str(value):
3845
return value
3946

4047

41-
__version__ = "4.1.0rc2"
48+
try:
49+
__version__ = metadata.version("redis")
50+
except metadata.PackageNotFoundError:
51+
__version__ = "99.99.99"
4252

4353

4454
VERSION = tuple(map(int_or_str, __version__.split(".")))

setup.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
#!/usr/bin/env python
22
from setuptools import find_packages, setup
33

4-
import redis
5-
64
setup(
75
name="redis",
86
description="Python client for Redis database and key-value store",
97
long_description=open("README.md").read().strip(),
108
long_description_content_type="text/markdown",
119
keywords=["Redis", "key-value store", "database"],
1210
license="MIT",
13-
version=redis.__version__,
11+
version="4.1.0rc2",
1412
packages=find_packages(
1513
include=[
1614
"redis",
@@ -26,12 +24,10 @@
2624
author="Redis Inc.",
2725
author_email="[email protected]",
2826
python_requires=">=3.6",
29-
setup_requires=[
30-
"packaging>=21.3",
31-
],
3227
install_requires=[
3328
"deprecated>=1.2.3",
3429
"packaging>=21.3",
30+
'importlib-metadata >= 1.0; python_version < "3.8"',
3531
],
3632
classifiers=[
3733
"Development Status :: 5 - Production/Stable",

0 commit comments

Comments
 (0)