Commit 41e8420
authored
When installing CLIP via pip on Python 3.10+ systems with setuptools 71+, the installation fails with:
## Problem
When installing CLIP via pip on Python 3.10+ systems with setuptools 71+, the installation fails with:
```
ModuleNotFoundError: No module named 'pkg_resources'
```
pip creates an **isolated build environment** in a temporary directory when building packages from source. In this isolated environment, setuptools is installed fresh — and in newer versions (71+), `pkg_resources` is no longer automatically available as a top-level importable module within that subprocess context, even though setuptools itself is present.
The original `setup.py` imported `pkg_resources` at the module level and used `pkg_resources.parse_requirements()` to read `requirements.txt`. Since this code runs inside pip's isolated build subprocess, it fails before the wheel can even be built — making CLIP completely uninstallable from source on modern systems without workarounds.
Closes #532
## What Changed
**Before:**
```python
import pkg_resources
install_requires=[
str(r)
for r in pkg_resources.parse_requirements(
open(os.path.join(os.path.dirname(__file__), "requirements.txt"))
)
]
```
**After:**
```python
install_requires=[
stripped
for line in open(os.path.join(os.path.dirname(__file__), "requirements.txt"))
for stripped in [line.strip()]
if stripped and not stripped.startswith("#")
],
```
- Removed the `pkg_resources` import entirely
- Replaced `parse_requirements()` with plain Python file I/O
- Strips each line before checking for blank/comment — so lines like `" # comment"` are correctly excluded (previous version missed these)
- Properly indented inside `install_requires`
## Impact
- Fixes installation on any system running setuptools 71+
- Tested on Python 3.10.19, setuptools 82.0.1
- No behavior change for existing users
- Removes the only legacy `pkg_resources` dependency from `setup.py`
- Makes the build process more robust and future-proof ModuleNotFoundError: No module named 'pkg_resources'
1 parent ded190a commit 41e8420
1 file changed
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | 2 | | |
5 | 3 | | |
6 | 4 | | |
| |||
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | | - | |
| 12 | + | |
15 | 13 | | |
16 | | - | |
| 14 | + | |
| 15 | + | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
0 commit comments