Repository: redis/redis-py

Issue:
Module installation fails due to missing dependency
https://github.com/redis/redis-py/blob/039488d97ec545b37e903d1b791a88bac8f77973/redis/connection.py#L1
the deprecated distutils was replaced with the packaging module as part of release v4.0.0b1
packaging is not a builtin python module but was not added to setup.py as a dependency which causes applications that require redis-py to fail if packaging isn't already installed on the machine.
the packaging module should probably be added as a dependency in setup.py to resolve this


Discussion:
Thanks for pointing this out. This definitely snuck in, as it's a package that's default distutils-ed on several OSes (including all 3 of mine), so I didn't notice. 
Fixed in #1626 . Closing.
Happy to help :)

However the merged fix seems counter productive since distutils is considered deprecated and is scheduled for removal from the python standard library in python 3.12 (which i think was the reason for the original change)
Please re-open, pull request #1626 did _not_ fix this issue (and is indeed a step backwards), `pip install .` is still broken on `master`. To reproduce:

```console
# cd "$(mktemp -d)"
# git clone --depth 1 https://github.com/andymccurdy/redis-py
# cd redis-py/
# virtualenv --python=python3.9 venv
# source venv/bin/activate
# pip install .
Processing /tmp/tmp.YtqtDgr1Ry/redis-py
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /tmp/tmp.YtqtDgr1Ry/redis-py/venv/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/tmp.YtqtDgr1Ry/redis-py/setup.py'"'"'; __file__='"'"'/tmp/tmp.YtqtDgr1Ry/redis-py/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-9ygcp0w4
       cwd: /tmp/tmp.YtqtDgr1Ry/redis-py/
  Complete output (11 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/tmp.YtqtDgr1Ry/redis-py/setup.py", line 4, in <module>
      import redis
    File "/tmp/tmp.YtqtDgr1Ry/redis-py/redis/__init__.py", line 1, in <module>
      from redis.client import Redis, StrictRedis
    File "/tmp/tmp.YtqtDgr1Ry/redis-py/redis/client.py", line 15, in <module>
      from redis.connection import ConnectionPool, SSLConnection, UnixDomainSocketConnection
    File "/tmp/tmp.YtqtDgr1Ry/redis-py/redis/connection.py", line 13, in <module>
      from packaging.version import Version
  ModuleNotFoundError: No module named 'packaging'
  ----------------------------------------
WARNING: Discarding file:///tmp/tmp.YtqtDgr1Ry/redis-py. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
```

I believe the issue is that `packaging` is not in `setup_requires` (aka "build dependencies") in `setup.py` but only in `install_requires` (aka runtime dependencies).

The `==` pinning in `setup.py` also blocks users from updating, so I believe we need something like this here, for a full fix:

```diff
# git --no-pager diff
diff --git a/setup.py b/setup.py
index 58d753f..b9c2e3e 100644
--- a/setup.py
+++ b/setup.py
@@ -26,9 +26,12 @@ setup(
     author="Redis Inc.",
     author_email="oss@redis.com",
     python_requires=">=3.6",
+    setup_requires=[
+        "packaging>=21.3",
+    ],
     install_requires=[
-        "deprecated==1.2.3",
-        "packaging==21.3",
+        "deprecated>=1.2.3",
+        "packaging>=21.3",
     ],
     classifiers=[
         "Development Status :: 5 - Production/Stable",
```

I will try turn that into a pull request in a minute.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -26,9 +26,12 @@
     author="Redis Inc.",
     author_email="oss@redis.com",
     python_requires=">=3.6",
+    setup_requires=[
+        "packaging>=21.3",
+    ],
     install_requires=[
-        "deprecated==1.2.3",
-        "packaging==21.3",
+        "deprecated>=1.2.3",
+        "packaging>=21.3",
     ],
     classifiers=[
         "Development Status :: 5 - Production/Stable",


Test patch: