Self hosted FLOSS fitness/workout, nutrition and weight tracker
Move version config to own file
Roland Geidereaaf2209fb87
diff --git a/pyproject.toml b/pyproject.tomlindex 354f492f6..acea91b84 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,15 +4,13 @@ build-backend = "hatchling.build"[project]name = "wger"-version = "2.3.0b1"-# dynamic = ["version", "dependencies"]-dynamic = ["dependencies"]+dynamic = ["version", "dependencies"]authors = [{ name = "Roland Geider", email = "[email protected]" },]description = "FLOSS workout, fitness and weight manager/tracker"readme = "README.md"-requires-python = ">=3.9"+requires-python = ">=3.10"classifiers = [# http://pypi.python.org/pypi?%3Aaction=list_classifiers'Development Status :: 5 - Production/Stable',@@ -30,10 +28,11 @@ classifiers = [[project.urls]Homepage = "https://wger.de/"-Documentation = "https://wger.readthedocs.io/en/latest/"+Documentation = "https://wger.readthedocs.io"Repository = "https://github.com/wger-project/wger"Issues = "https://github.com/wger-project/wger/issues"Changelog = "https://wger.readthedocs.io/en/latest/changelog.html"+Funding = "https://buymeacoffee.com/wger"[project.scripts]wger = "wger.__main__:main"@@ -48,10 +47,10 @@ dependencies = { file = ["requirements.txt"] }[tool.distutils.bdist_wheel]universal = 1-# [tool.hatch.version]-# source = "code"-# path = "wger/__init__.py"-# expression = "get_version()"+[tool.hatch.version]+source = "code"+path = "wger/version.py"+expression = "get_version()"[tool.ruff]diff --git a/wger/__init__.py b/wger/__init__.pyindex 48483331b..c59d1532c 100644--- a/wger/__init__.py+++ b/wger/__init__.py@@ -12,25 +12,6 @@## You should have received a copy of the GNU Affero General Public License-# Third Party-from packaging.version import Version# wgerfrom wger.celery_configuration import app---MIN_APP_VERSION = Version('1.8.0')-"""Minimum version of the mobile app required to access this server"""--MIN_SERVER_VERSION = Version('2.3.0beta1')-"""Minimum version of the server required to run sync commands on this server"""--VERSION = Version('2.3.0beta1')-"""Current version of the app"""---def get_version(version: Version = None) -> str:- if version is None:- version = VERSION-- return str(version)diff --git a/wger/config/__init__.py b/wger/config/__init__.pyindex 97c167829..fda2db619 100644--- a/wger/config/__init__.py+++ b/wger/config/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/core/__init__.py b/wger/core/__init__.pyindex 2a5851ace..4627cb08d 100644--- a/wger/core/__init__.py+++ b/wger/core/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/core/api/min_server_version.py b/wger/core/api/min_server_version.pyindex 89b818536..f55d412b0 100644--- a/wger/core/api/min_server_version.py+++ b/wger/core/api/min_server_version.py@@ -20,9 +20,9 @@ import requestsfrom packaging.version import parse# wger-from wger import VERSIONfrom wger.core.api.endpoints import MIN_SERVER_VERSION_ENDPOINTfrom wger.utils.url import make_uri+from wger.version import VERSIONdef check_min_server_version(remote_url):diff --git a/wger/core/api/views.py b/wger/core/api/views.pyindex 1edc37bb7..597c3da6b 100644--- a/wger/core/api/views.py+++ b/wger/core/api/views.py@@ -49,11 +49,6 @@ from rest_framework.permissions import (from rest_framework.response import Response# wger-from wger import (- MIN_APP_VERSION,- MIN_SERVER_VERSION,- get_version,-)from wger.core.api.serializers import (LanguageSerializer,LicenseSerializer,@@ -73,6 +68,11 @@ from wger.core.models import ()from wger.utils.api_token import create_tokenfrom wger.utils.permissions import WgerPermission+from wger.version import (+ MIN_APP_VERSION,+ MIN_SERVER_VERSION,+ get_version,+)logger = logging.getLogger(__name__)diff --git a/wger/core/tests/test_check_min_server_version.py b/wger/core/tests/test_check_min_server_version.pyindex 4ab45e008..ab0e505a7 100644--- a/wger/core/tests/test_check_min_server_version.py+++ b/wger/core/tests/test_check_min_server_version.py@@ -26,8 +26,8 @@ from django.core.management import CommandErrorfrom packaging.version import Version# wger-from wger import VERSIONfrom wger.core.api.min_server_version import check_min_server_version+from wger.version import VERSIONclass TestCheckMinServerVersion(unittest.TestCase):diff --git a/wger/exercises/__init__.py b/wger/exercises/__init__.pyindex e6febe2be..4860bf45a 100644--- a/wger/exercises/__init__.py+++ b/wger/exercises/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/gallery/__init__.py b/wger/gallery/__init__.pyindex 7ad2fb243..7e312f5ed 100644--- a/wger/gallery/__init__.py+++ b/wger/gallery/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/gym/__init__.py b/wger/gym/__init__.pyindex 869912bd4..2fb5d1fba 100644--- a/wger/gym/__init__.py+++ b/wger/gym/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/mailer/__init__.py b/wger/mailer/__init__.pyindex 816f195e4..8657bdae1 100644--- a/wger/mailer/__init__.py+++ b/wger/mailer/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/manager/__init__.py b/wger/manager/__init__.pyindex b2fcf3c3f..de401f1fb 100644--- a/wger/manager/__init__.py+++ b/wger/manager/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/manager/api/views.py b/wger/manager/api/views.pyindex 4c30c40c8..022210f4c 100644--- a/wger/manager/api/views.py+++ b/wger/manager/api/views.py@@ -127,7 +127,6 @@ class RoutineViewSet(viewsets.ModelViewSet):out = WorkoutDayDataDisplayModeSerializer(self.get_object().date_sequence,- # generate_sequence(self.get_object()),many=True,).datacache.set(cache_key, out, settings.WGER_SETTINGS['ROUTINE_CACHE_TTL'])diff --git a/wger/manager/tests/__init__.py b/wger/manager/tests/__init__.pyindex 7d1f90ca0..375cec210 100644--- a/wger/manager/tests/__init__.py+++ b/wger/manager/tests/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/manager/views/ical.py b/wger/manager/views/ical.pyindex 5a94c04a0..724f9a9f0 100644--- a/wger/manager/views/ical.py+++ b/wger/manager/views/ical.py@@ -33,8 +33,8 @@ from icalendar import (from icalendar.tools import UIDGenerator# wger-from wger import get_versionfrom wger.manager.models import Routine+from wger.version import get_versionlogger = logging.getLogger(__name__)diff --git a/wger/measurements/__init__.py b/wger/measurements/__init__.pyindex d6331e676..1b3ff6ea0 100644--- a/wger/measurements/__init__.py+++ b/wger/measurements/__init__.py@@ -1,5 +1,5 @@# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/nutrition/__init__.py b/wger/nutrition/__init__.pyindex 71ac8ffd3..a631c8405 100644--- a/wger/nutrition/__init__.py+++ b/wger/nutrition/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/settings_global.py b/wger/settings_global.pyindex 9bda81f43..52b897207 100644--- a/wger/settings_global.py+++ b/wger/settings_global.py@@ -20,8 +20,8 @@ import sysfrom datetime import timedelta# wger-from wger import get_versionfrom wger.utils.constants import DOWNLOAD_INGREDIENT_WGER+from wger.version import get_version"""diff --git a/wger/software/__init__.py b/wger/software/__init__.pyindex 7d1f90ca0..375cec210 100644--- a/wger/software/__init__.py+++ b/wger/software/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/software/urls.py b/wger/software/urls.pyindex ea8e0207a..303f841c4 100644--- a/wger/software/urls.py+++ b/wger/software/urls.py@@ -22,8 +22,8 @@ from django.views.generic import ()# wger-from wger import get_versionfrom wger.software import views+from wger.version import get_versionurlpatterns = [diff --git a/wger/utils/__init__.py b/wger/utils/__init__.pyindex 7d1f90ca0..375cec210 100644--- a/wger/utils/__init__.py+++ b/wger/utils/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()diff --git a/wger/utils/pdf.py b/wger/utils/pdf.pyindex d32ce9e0e..74d6d4646 100644--- a/wger/utils/pdf.py+++ b/wger/utils/pdf.py@@ -38,8 +38,8 @@ from reportlab.platypus import ()# wger-from wger import get_versionfrom wger.core.models import Language+from wger.version import get_version# ************************diff --git a/wger/utils/requests.py b/wger/utils/requests.pyindex aec1fd6f6..11859da5d 100644--- a/wger/utils/requests.py+++ b/wger/utils/requests.py@@ -16,7 +16,7 @@import requests# wger-from wger import get_version+from wger.version import get_versiondef wger_user_agent():diff --git a/wger/version.py b/wger/version.pynew file mode 100644index 000000000..69424eb50--- /dev/null+++ b/wger/version.py@@ -0,0 +1,43 @@+# This file is part of wger Workout Manager.+#+# wger Workout Manager is free software: you can redistribute it and/or modify+# it under the terms of the GNU Affero General Public License as published by+# the Free Software Foundation, either version 3 of the License, or+# (at your option) any later version.+#+# wger Workout Manager 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 Affero General Public License++# Standard Library+import logging+import subprocess++# Third Party+from packaging.version import Version+++logger = logging.getLogger(__name__)++MIN_APP_VERSION = Version('1.8.0')+"""+Minimum version of the mobile app required to access this server.++Always use versions in the x.y.z format, without any suffixes like "beta1" or such.+"""++MIN_SERVER_VERSION = Version(f'2.3.0beta2')+"""Minimum version of the server required to run sync commands on this server"""++VERSION = Version(f'2.3.0beta2')+"""Current version of the app"""+++def get_version(version: Version = None) -> str:+ if version is None:+ version = VERSION++ return str(version)diff --git a/wger/weight/__init__.py b/wger/weight/__init__.pyindex 7d1f90ca0..375cec210 100644--- a/wger/weight/__init__.py+++ b/wger/weight/__init__.py@@ -16,7 +16,7 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.# wger-from wger import get_version+from wger.version import get_versionVERSION = get_version()