Fix __version__ handling (#6765)

This commit is contained in:
Silvano Cerza 2024-01-18 11:11:08 +01:00 committed by GitHub
parent 5d66d040cc
commit 1c76aa07bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 8 deletions

View File

@ -1,13 +1,6 @@
from importlib import metadata
# haystack is distributed as a separate package called `haystack-ai`.
# We want to keep all preview dependencies separate from the current Haystack version,
# so imports in haystack must only import from haystack.
# Since we need to access __version__ in haystack without importing from
# haystack we must set it here too.
# When installing `haystack-ai` we want to use that package version though
# as `farm-haystack` might not be installed and cause this to fail.
try:
__version__ = str(metadata.version("haystack-ai"))
except metadata.PackageNotFoundError:
__version__ = str(metadata.version("farm-haystack"))
__version__ = "main"

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Fix Haystack imports failing when using local development environment that doesn't have `haystack-ai` installed.