Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Version stored in VERSION (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakethekoenig authored Feb 14, 2024
1 parent 0b1f711 commit 9e2cd5e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 8 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@

# 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

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
Expand Down
1 change: 1 addition & 0 deletions mentat/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.9
5 changes: 2 additions & 3 deletions mentat/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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(
Expand Down
11 changes: 5 additions & 6 deletions mentat/splash_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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(
Expand All @@ -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")
4 changes: 4 additions & 0 deletions mentat/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pathlib import Path

with open(Path(__file__).parent / "VERSION", "r") as file:
__version__ = file.read().strip()
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.*"]
Expand Down

0 comments on commit 9e2cd5e

Please sign in to comment.