Skip to content

1.4.0 installs a top-level tools package into site-packages #438

Description

@Ravi2k3

Summary

Mako 1.4.0 installs a top-level tools package (site-packages/tools/ containing toxnox.py and warn_tox.py) alongside mako/. This appears unintentional: tools/ looks like an internal repo directory that got picked up by package discovery. 1.3.x does not install it.

Because tools is an extremely common name, this shadows project-local tools packages for anyone who installs Mako, including the very large number of projects that get it transitively via Alembic. It is especially disruptive for projects whose tools is a namespace package (no __init__.py), since a regular package always wins over a namespace package regardless of sys.path order, so the usual "put your project first on the path" workaround does not help.

Reproduction

docker run --rm python:3.12-slim bash -c '
  python -m venv /tmp/v
  /tmp/v/bin/pip install -q "Mako==1.4.0"
  ls /tmp/v/lib/python3.12/site-packages/tools/
'

Output:

__init__.py
toxnox.py
warn_tox.py

The files are recorded in mako-1.4.0.dist-info/RECORD under tools/.

With Mako==1.3.12 the same commands produce no site-packages/tools/.

Impact example

A project with its own tools/ namespace package started failing at import as soon as 1.4.0 was published, via alembic -> Mako:

ImportError: cannot import name 'cell_image_cleanup' from 'tools'
  (/…/site-packages/tools/__init__.py)
ModuleNotFoundError: No module named 'tools.agent_report'

No code or dependency declaration changed on our side; only the upstream resolve did.

Suggested fix

Exclude tools* from package discovery (or move those helpers outside the packaged tree) and release a 1.4.1. As a workaround, downstream projects can pin Mako<1.4.0.

Versions

  • Mako 1.4.0 (installed by pip 25.0.1, Python 3.12.13, linux/amd64, python:3.12-slim)
  • Mako 1.3.12: unaffected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions