You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use of importlib.metadata breaks import when metadata is stripped #15
Expected Behavior: Importing the module works without bundling Package Metadata in application
Actual Behavior: Stripping Package Metadata breaks imports
Cause:
The pattern of directly using importlib.metadata to set the version assumes that package metadata is included in the location where the package is being used. As a result, this breaks when using slimmed down deployment artifacts, as package metadata is not bundled. I have seen a standard approach to this to be to wrap this self-referential version within a try/except block, e.g.
We are also facing this issue. Especially, we are using FastAPI in AWS Lambda and since FastAPI is depending on this package, our application isnt starting anymore as of this Import Error.
There is a workaround available, which is to modify your Lambda Zip artifact generation to include the **/*.dist-info* glob pattern. This will slightly increase the artifact size, but does temporarily resolve the issue.
Activity
DBS-ST-VIT commentedon Nov 4, 2025
We are also facing this issue. Especially, we are using FastAPI in AWS Lambda and since FastAPI is depending on this package, our application isnt starting anymore as of this Import Error.
@tiangolo May you can have a look on this?
raghavankarthick commentedon Nov 5, 2025
Hi @tiangolo, We are also facing this issue with FastAPI in AWS Lambda, can you take a look on this?
JP-Dhabolt commentedon Nov 5, 2025
There is a workaround available, which is to modify your Lambda Zip artifact generation to include the
**/*.dist-info*glob pattern. This will slightly increase the artifact size, but does temporarily resolve the issue.svlandeg commentedon Nov 10, 2025
Thanks all for the report! We'll look into how best to resolve this 🙏
tiangolo commentedon Nov 10, 2025
Thanks for the report! This should be solved by #19, available in version 0.0.4, released in the next few minutes. 🎉