Skip to content

Export optimum.__version__ without breaking the namespace package - #2480

Open
adi-IL wants to merge 1 commit into
huggingface:mainfrom
adi-IL:fix/export-dunder-version
Open

Export optimum.__version__ without breaking the namespace package#2480
adi-IL wants to merge 1 commit into
huggingface:mainfrom
adi-IL:fix/export-dunder-version

Conversation

@adi-IL

@adi-IL adi-IL commented Aug 18, 2026

Copy link
Copy Markdown

Fixes #2188

import optimum; print(optimum.__version__) currently raises AttributeError. The version string already lives in optimum/version.py. It was never re-exported at the package root because this tree is a namespace package (no __init__.py), which is how optimum-onnx and optimum-intel attach themselves.

#2406 added a bare __init__.py and went stale. A bare init would turn optimum into a regular package and drop other install paths from __path__.

This PR adds a thin __init__.py that:

  1. Re-exports __version__ from optimum.version.
  2. Calls pkgutil.extend_path so split installs still resolve.

Check

PYTHONPATH=. python3 -c "import optimum; print(optimum.__version__)"

prints 2.4.0.dev0. Existing from optimum.version import __version__ is unchanged.

Added tests/common/test_version.py for the attribute and that __path__ stays searchable.

Claimed with #take on #2188: #2188 (comment)

import optimum currently has no __version__ because the top-level
package is a namespace (no __init__.py). Add a thin __init__ that
re-exports version and uses pkgutil.extend_path so split installs
like optimum-onnx still resolve.
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.

no __version__ attribute

1 participant