diff --git a/MANIFEST.in b/MANIFEST.in index b13eb725e..8b364913c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,5 +2,6 @@ include requirements.txt include dev-requirements.txt include README.md include LICENSE +include mentat/VERSION graft mentat/resources graft benchmarks/resources diff --git a/docs/source/conf.py b/docs/source/conf.py index fe1049d07..f2a2e53f7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -8,7 +8,13 @@ # AXJ, Version sys.path.insert(0, os.path.abspath("../..")) -from mentat import __version__ # noqa: E402 + +with open( + os.path.join(os.path.dirname(__file__), "..", "..", "mentat/VERSION"), + "r", + encoding="utf-8", +) as f: + VERSION = f.read().strip() # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information @@ -16,7 +22,7 @@ project = "Mentat" copyright = "2024, Abante AI" author = "Multiple Authors" -release = __version__ +release = VERSION # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/mentat/VERSION b/mentat/VERSION new file mode 100644 index 000000000..66c4c2263 --- /dev/null +++ b/mentat/VERSION @@ -0,0 +1 @@ +1.0.9 diff --git a/mentat/sentry.py b/mentat/sentry.py index 00df86866..b142aa53e 100644 --- a/mentat/sentry.py +++ b/mentat/sentry.py @@ -2,11 +2,11 @@ import platform from uuid import UUID, uuid4 -import pkg_resources import sentry_sdk from mentat.app_conf import IS_DEV from mentat.utils import mentat_dir_path +from mentat.version import __version__ user_id_path = mentat_dir_path / ".user" @@ -41,8 +41,7 @@ def sentry_init(): enable_tracing=True, traces_sample_rate=1.0, ) - version = pkg_resources.require("mentat")[0].version - sentry_sdk.set_tag("version", version) + sentry_sdk.set_tag("version", __version__) sentry_sdk.set_user({"id": _get_user()}) uname = platform.uname() sentry_sdk.set_context( diff --git a/mentat/splash_messages.py b/mentat/splash_messages.py index 573720b97..933af9787 100644 --- a/mentat/splash_messages.py +++ b/mentat/splash_messages.py @@ -2,11 +2,11 @@ from typing import Optional import packaging.version -import pkg_resources import requests from mentat.session_context import SESSION_CONTEXT from mentat.utils import mentat_dir_path +from mentat.version import __version__ def get_changelog() -> Optional[str]: @@ -41,9 +41,8 @@ def check_version(): response = requests.get("https://pypi.org/pypi/mentat/json") data = response.json() latest_version = data["info"]["version"] - current_version = pkg_resources.require("mentat")[0].version - if packaging.version.parse(current_version) < packaging.version.parse( + if packaging.version.parse(__version__) < packaging.version.parse( latest_version ): ctx.stream.send( @@ -66,15 +65,15 @@ def check_version(): last_version_check = f.read() if packaging.version.parse( last_version_check - ) < packaging.version.parse(current_version): + ) < packaging.version.parse(__version__): changelog = get_latest_changelog() if changelog: ctx.stream.send( - f"Thanks for upgrading to v{current_version}.", style="info" + f"Thanks for upgrading to v{__version__}.", style="info" ) ctx.stream.send("Changes in this version:", style="info") ctx.stream.send(changelog, style="info") with open(last_version_check_file, "w") as f: - f.write(current_version) + f.write(__version__) except Exception as err: ctx.stream.send(f"Error checking for most recent version: {err}", style="error") diff --git a/mentat/version.py b/mentat/version.py new file mode 100644 index 000000000..dec0935b1 --- /dev/null +++ b/mentat/version.py @@ -0,0 +1,4 @@ +from pathlib import Path + +with open(Path(__file__).parent / "VERSION", "r") as file: + __version__ = file.read().strip() diff --git a/setup.py b/setup.py index 1cbd18632..a905b630a 100644 --- a/setup.py +++ b/setup.py @@ -9,9 +9,13 @@ long_description = f.read() +version_path = os.path.join(Path(__file__).parent, "mentat/VERSION") +with open(version_path, "r", encoding="utf-8") as f: + VERSION = f.read().strip() + setup( name="mentat", - version="1.0.9", + version=VERSION, python_requires=">=3.10", packages=find_packages( include=["mentat", "mentat.*", "benchmarks", "benchmarks.*"]