Add setuptools to requirements for Python 3.12+ compatibility

Python 3.12 no longer bundles setuptools in virtual environments.
Pyramid imports pkg_resources from setuptools, causing CI to fail with
ModuleNotFoundError: No module named 'pkg_resources'.
This commit is contained in:
russell@unturf.com 2026-02-08 11:47:52 -05:00
parent c5f3b2915f
commit 117227a901
2 changed files with 30 additions and 0 deletions

View file

@ -127,6 +127,32 @@ alembic -c data/development.ini history
### Important Migration Notes
**Idempotent Migrations**: `make init-db` creates all tables from models, so migrations that run afterward must not fail if tables/columns already exist. Always guard `create_table` with `_table_exists` and `add_column` with `_column_exists`:
```python
def _table_exists(name):
conn = op.get_bind()
result = conn.execute(
sa.text("SELECT name FROM sqlite_master WHERE type='table' AND name=:name"),
{"name": name},
)
return result.fetchone() is not None
def _column_exists(table, column):
conn = op.get_bind()
result = conn.execute(sa.text(f"PRAGMA table_info({table})"))
return any(row[1] == column for row in result.fetchall())
def upgrade():
if not _table_exists("mps_new_table"):
op.create_table(...)
if not _column_exists("mps_shop", "new_column"):
op.add_column(...)
```
**SQLite Column Defaults**: When adding NOT NULL columns with defaults to existing tables in SQLite, use `server_default` with raw SQL values:
```python

View file

@ -1,6 +1,10 @@
# python 2 -> 3 compat.
six
# Python 3.12+ no longer bundles setuptools in venvs.
# Pyramid imports pkg_resources which lives in setuptools.
setuptools
# Pyramid with SQLAlchemy.
plaster_pastedeploy
pyramid