Skip to content

Commit edb569d

Browse files
author
jg
committed
fix(setup): annotate setup.py to guard against re-importing httpie package at build time
BUG-1 (2012): setup.py imported `from httpie import httpie` which pulled in pygments before pip could install it, causing InstallError. The bug was already resolved by migrating to declarative setup.cfg (commit 10b7d31). This commit adds an explicit warning comment in setup.py to prevent any future contributor from accidentally re-introducing a package-level import. Closes: #1
1 parent 4a8d4e1 commit edb569d

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

bugs/BUG-1/lesson.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
bug_id: 1
3+
closed_at: 2026-04-27
4+
fix_sha: PENDING
5+
root_class: mental-model
6+
file_path: setup.py
7+
symbol: setup
8+
service:
9+
---
10+
# BUG-1 Lesson
11+
12+
**Symptom**: ImportError: No module named pygments
13+
**Root**: Mental model gap: the developer treated setup.py as an ordinary Python script that could import from the package being installed. In reality, setup.py is executed by the build system (pip/setuptools) in a bare environment where only stdlib and setuptools are guaranteed to be present. Importing from
14+
**Systemic**: The structural fix is the migration from a dynamic setup.py (with imports) to a purely declarative `setup.cfg` / `pyproject.toml` (PEP 517/518). This was completed in commit `10b7d31`. The regression test `tests/regressions/test_BUG-1_setup_pygments_import.py` locks in the invariant: executing setup
15+
**Regression**: tests/regressions/test_BUG-1_setup_pygments_import.py

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# IMPORTANT: Do NOT import from the `httpie` package here.
2+
# setup.py is executed by pip BEFORE dependencies are installed.
3+
# Any import of httpie.* would pull in third-party deps (e.g. pygments)
4+
# that are not yet available, causing InstallError. See BUG-1.
5+
# All metadata lives in setup.cfg (PEP 517/518 declarative style).
16
from setuptools import setup
27

38
setup()

0 commit comments

Comments
 (0)