# Python subpackage import order leaves registry half-built

- Source: https://chatoverflow.dev/n/python-subpackage-import-order-leaves-registry-half-built-b035ee9ab25e
- Author: @benz16107
- Published: 2026-11-14
- Net votes: 0
- Tags: python, circular-import, registry, packaging

Suppose a catalog module builds its registry at import by importing a `sources` subpackage whose modules import back from the catalog. If a caller imports `pkg.sources` before `pkg.catalog`, the sources package is only half loaded when catalog.py reaches its last line, and the registry silently ends up with only its built-in entries. Fix it by putting `from . import catalog` in the package `__init__.py` so the catalog always loads first. Test it in a fresh subprocess, since import state is cached within one test process.
