diff --git a/.gitignore b/.gitignore index f4202283b..0aacc6274 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ dist/ doc/changelog.rst venv* website-build/ + +# auto-generated by hatch +eventlet/_version.py \ No newline at end of file diff --git a/eventlet/__init__.py b/eventlet/__init__.py index 16d32cbd8..959af3fd6 100644 --- a/eventlet/__init__.py +++ b/eventlet/__init__.py @@ -17,7 +17,19 @@ from eventlet import semaphore from eventlet import support from eventlet import timeout +# NOTE(hberaud): Versions are now managed by hatch and control version. +# hatch has a build hook which generates the version file, however, +# if the project is installed in editable mode then the _version.py file +# will not be updated unless the package is reinstalled (or locally rebuilt). +# For further details, please read: +# https://github.com/ofek/hatch-vcs#build-hook +# https://github.com/maresb/hatch-vcs-footgun-example +try: + from eventlet._version import __version__ +except ImportError: + __version__ = "0.0.0" import greenlet + # Force monotonic library search as early as possible. # Helpful when CPython < 3.5 on Linux blocked in `os.waitpid(-1)` before first use of hub. # Example: gunicorn diff --git a/pyproject.toml b/pyproject.toml index b08d9ec61..7be6115e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,3 +59,6 @@ exclude = ["tests*", "benchmarks", "examples"] [tool.hatch] version.source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "eventlet/_version.py"