Add conditional version retrieval from setup. (#12853)
When airflow is not installed as package (for example for local development from sources) there is no package metadata. Many of our unit tests use the version field and they fail if they are run within virtual environment where airflow is not installed as package (for example in IntelliJ this is default setting. This PR adds fall-back to read airflow version from setup in case it cannot be read from package metadata.
This commit is contained in:
Родитель
82dfa5f74b
Коммит
537aba738c
|
@ -24,6 +24,13 @@ try:
|
|||
except ImportError:
|
||||
import importlib_metadata as metadata
|
||||
|
||||
version = metadata.version('apache-airflow')
|
||||
try:
|
||||
version = metadata.version('apache-airflow')
|
||||
except metadata.PackageNotFoundError:
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
log.warning("Package metadata could not be found. Overriding it with version found in setup.py")
|
||||
from setup import version
|
||||
|
||||
del metadata
|
||||
|
|
Загрузка…
Ссылка в новой задаче