openai / CLIP

CLIP (Contrastive Language-Image Pretraining), Predict the most relevant text snippet given an image
MIT License
24.55k stars 3.2k forks source link

import packaging to be compatible with setuptools==70.0.0 #449

Closed JamieMartin closed 3 months ago

JamieMartin commented 3 months ago

As described in Issue #446 (https://github.com/openai/CLIP/issues/446), there is a change from setuptools 70.0.0 which causes breaking behaviour. This change fixes this. However, it will force the usage of setuptools 70.0.0.

In another PR, I've offered a solution which checks the version, which provides backward compatibility - #450

File ~/python3.12/site-packages/clip/clip.py:6
      5 from typing import Any, Union, List
----> 6 from pkg_resources import packaging
      8 import torch

ImportError: cannot import name 'packaging' from 'pkg_resources' (~/python3.12/site-packages/pkg_resources/__init__.py)
JamieMartin commented 3 months ago

The above run failed because it's using setuptools version setuptools-69.5.1, yet the comment states that this approach REQUIRES setuptools 70.0.0 to be used. https://github.com/openai/CLIP/actions/runs/9352249182/job/25742406920?pr=449#step:3:78

It may be better to use #450 instead if backward compatibility is desired. If so, please feel free to close this PR.

jongwook commented 3 months ago

Thanks again for your contribution -- I prefer this PR because it's simpler, and it appears that with from packaging import version and the added dependency, it works okay with python 3.7, i.e. not losing backwards compatibility.