Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store version in one place and generate timestamp dynamically #1479

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-briefcase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: plotlyst-app
path: dist\Plotlyst-0.1.0.msi
path: dist\Plotlyst-*.msi


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ venv
profile.stats
test.docx
document.pdf
src/build/settings/base.json

generated
coverage
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "plotlyst"
version = "0.1.0"
dynamic = ["version"]
license = { text = "GNU General Public License v3 (GPLv3)" }
authors = [
{ name = "Zsolt Kovari" }
Expand Down Expand Up @@ -46,7 +46,7 @@ test = [
[tool.briefcase]
project_name = "Plotlyst"
bundle = "com.plotlyst"
version = "0.1.0"
version = "0.1.1"

[tool.briefcase.app.plotlyst]
formal_name = "Plotlyst"
Expand Down
56 changes: 56 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import json
import os
import re

from setuptools import setup


def get_briefcase_version():
with open("pyproject.toml") as f:
for line in f:
match = re.search(r'version\s*=\s*[\'"]([^\'"]+)[\'"]', line)
if match:
return match.group(1)

raise RuntimeError("Unable to find version in pyproject.toml")


def get_base_version():
with open("src/main/python/plotlyst/version.py") as f:
content = f.read()
match = re.search(r"plotlyst_product_version = ['\"]([^'\"]+)['\"]", content)
if match:
return match.group(1)
raise RuntimeError("Unable to find __version__ string in version.py")


def check_versions(base_version):
pyproject_version = get_briefcase_version()
if pyproject_version != base_version:
raise RuntimeError(
f"Version mismatch: [tool.briefcase] version is {pyproject_version}, but version.py has {base_version}")


def generate_json_file(version):
settings = {
"app_name": "Plotlyst",
"author": "Zsolt Kovari",
"main_module": "src/main/python/plotlyst/__main__.py",
"version": version,
}

os.makedirs("src/build/settings", exist_ok=True)

json_file_path = os.path.join("src", "build", "settings", "base.json")
with open(json_file_path, 'w') as json_file:
json.dump(settings, json_file, indent=4)


version = get_base_version()
check_versions(version)

generate_json_file(version)

setup(
version=version,
)
6 changes: 0 additions & 6 deletions src/build/settings/base.json

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/python/plotlyst/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

try:
import logging
import argparse
Expand All @@ -30,6 +29,7 @@
from fbs_runtime.excepthook import enable_excepthook_for_threads
from overrides import overrides

from plotlyst.version import plotlyst_display_version
from plotlyst.env import AppMode, app_env
from plotlyst.resources import resource_registry, resource_manager
from plotlyst.settings import settings
Expand Down Expand Up @@ -68,7 +68,7 @@ def run(self):
appctxt = AppContext()
app = appctxt.app
app.setApplicationName('Plotlyst')
app.setApplicationVersion('0.1.0')
app.setApplicationVersion(plotlyst_display_version)

sys.excepthook = handle_exception
enable_excepthook_for_threads()
Expand Down
22 changes: 22 additions & 0 deletions src/main/python/plotlyst/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Plotlyst
Copyright (C) 2021-2024 Zsolt Kovari

This file is part of Plotlyst.

Plotlyst is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Plotlyst is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

plotlyst_product_version = '0.1.1'
plotlyst_display_version = '2024.11'
Loading