[PR #535] [CLOSED] fix: remove pkg_resources dependency in setup.py (breaks on setuptools 71+) #529

Closed
opened 2026-10-31 21:15:45 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openai/CLIP/pull/535
Author: @Aadi775
Created: 3/22/2026
Status: ❌ Closed

Base: main ← Head: patch-1


📝 Commits (2)

📊 Changes

1 file changed (+4 additions, -3 deletions)

View changed files

📝 setup.py (+4 -3)

📄 Description

Problem

When installing CLIP via pip on systems with setuptools 71+, the installation fails with:

ModuleNotFoundError: No module named 'pkg_resources'

This happens because 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.

What Changed

Before:

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:

install_requires=[
    line.strip()
    for line in open(os.path.join(os.path.dirname(__file__), "requirements.txt"))
    if line.strip() and not line.startswith("#")
]

Replaced pkg_resources.parse_requirements() with plain Python file I/O. No external dependencies, same result. Also adds explicit filtering of blank lines and comment lines (#), which the original did not handle.

Impact

  • Fixes installation on any system running setuptools 71+
  • 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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openai/CLIP/pull/535 **Author:** [@Aadi775](https://github.com/Aadi775) **Created:** 3/22/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (2) - [`aac299a`](https://github.com/openai/CLIP/commit/aac299a7ec23eca87f76c7e2ec82f1efaba98816) Update setup.py - [`47aaee3`](https://github.com/openai/CLIP/commit/47aaee3574a61d660094a8cb654fd7bf84edc4db) Apply suggestion from @Copilot ### 📊 Changes **1 file changed** (+4 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `setup.py` (+4 -3) </details> ### 📄 Description ## Problem When installing CLIP via pip on systems with setuptools 71+, the installation fails with: ``` ModuleNotFoundError: No module named 'pkg_resources' ``` This happens because 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. ## 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=[ line.strip() for line in open(os.path.join(os.path.dirname(__file__), "requirements.txt")) if line.strip() and not line.startswith("#") ] ``` Replaced `pkg_resources.parse_requirements()` with plain Python file I/O. No external dependencies, same result. Also adds explicit filtering of blank lines and comment lines (`#`), which the original did not handle. ## Impact - Fixes installation on any system running setuptools 71+ - 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 21:15:45 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#529
No description provided.