Skip to content

Add chdb/__init__.py to prevent broken module after upgrade#543

Merged
auxten merged 1 commit into
mainfrom
fix/chdb-init-missing
Mar 18, 2026
Merged

Add chdb/__init__.py to prevent broken module after upgrade#543
auxten merged 1 commit into
mainfrom
fix/chdb-init-missing

Conversation

@auxten

@auxten auxten commented Mar 18, 2026

Copy link
Copy Markdown
Member

Summary

  • After upgrading chdb, users get AttributeError: module 'chdb' has no attribute 'connect' because the wrapper package was a namespace package without __init__.py. During upgrade, pip removes the old chdb/__init__.py (from chdb-core) as collateral damage, and the new wrapper doesn't replace it.
  • Adds chdb/__init__.py that bootstraps chdb-core's engine, working for both regular pip install, editable install, and upgrade paths.
  • Excludes .dylib/.so from package-data so the wrapper wheel no longer ships broken symlinks that overwrite chdb-core's binaries.

Root Cause

Two packages (chdb wrapper and chdb-core) both install files into site-packages/chdb/. When the wrapper is upgraded:

  1. pip uninstalls old wrapper → removes files in its RECORD (including chdb/__init__.py if it was there)
  2. pip installs new wrapper → namespace package, no __init__.py included
  3. chdb-core's __init__.py may have been removed in step 1 → module is empty

Test Plan

Verified in isolated venvs:

  • Upgrade path: PyPI chdb-4.1.3 → local chdb-3.7.0 wheel — chdb.connect(), chdb.query(), from chdb import datastore all work
  • Fresh install: local chdb-3.7.0 wheel from scratch — all work
  • Editable install: pip install -e . in dev environment — all work
  • Wheel contents: only chdb/__init__.py + chdb/datastore.py (no .dylib/.so)

When users upgrade from an older chdb version, pip removes the old
package's files (including chdb/__init__.py from chdb-core) before
installing the new wrapper package. Since the wrapper was configured
as a namespace package without its own __init__.py, the chdb module
became empty — causing `AttributeError: module 'chdb' has no attribute
'connect'`.

This commit:
- Adds chdb/__init__.py that bootstraps chdb-core's engine, working
  for both regular and editable installs
- Excludes .dylib/.so from package-data to prevent the wrapper wheel
  from shipping broken symlinks that overwrite chdb-core's binaries
@auxten auxten changed the title fix: add chdb/__init__.py to prevent broken module after upgrade Add chdb/__init__.py to prevent broken module after upgrade Mar 18, 2026
@auxten auxten merged commit 17c0dee into main Mar 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant