Move version config to own file

This is needed so that the version string can be extracted at build time and
hatchling had some problems if it was in __init__ where we also imported
wger.celery_configuration
This commit is contained in:
Roland Geider
2025-04-04 11:27:34 +02:00
parent 25fba55010
commit eaaf2209fb
25 changed files with 76 additions and 54 deletions

View File

@@ -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 = "roland@geider.net" },
]
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]

View File

@@ -12,25 +12,6 @@
#
# You should have received a copy of the GNU Affero General Public License
# Third Party
from packaging.version import Version
# wger
from 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)

View File

@@ -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_version
VERSION = get_version()

View File

@@ -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_version
VERSION = get_version()

View File

@@ -20,9 +20,9 @@ import requests
from packaging.version import parse
# wger
from wger import VERSION
from wger.core.api.endpoints import MIN_SERVER_VERSION_ENDPOINT
from wger.utils.url import make_uri
from wger.version import VERSION
def check_min_server_version(remote_url):

View File

@@ -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_token
from wger.utils.permissions import WgerPermission
from wger.version import (
MIN_APP_VERSION,
MIN_SERVER_VERSION,
get_version,
)
logger = logging.getLogger(__name__)

View File

@@ -26,8 +26,8 @@ from django.core.management import CommandError
from packaging.version import Version
# wger
from wger import VERSION
from wger.core.api.min_server_version import check_min_server_version
from wger.version import VERSION
class TestCheckMinServerVersion(unittest.TestCase):

View File

@@ -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_version
VERSION = get_version()

View File

@@ -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_version
VERSION = get_version()

View File

@@ -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_version
VERSION = get_version()

View File

@@ -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_version
VERSION = get_version()

View File

@@ -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_version
VERSION = get_version()

View File

@@ -127,7 +127,6 @@ class RoutineViewSet(viewsets.ModelViewSet):
out = WorkoutDayDataDisplayModeSerializer(
self.get_object().date_sequence,
# generate_sequence(self.get_object()),
many=True,
).data
cache.set(cache_key, out, settings.WGER_SETTINGS['ROUTINE_CACHE_TTL'])

View File

@@ -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_version
VERSION = get_version()

View File

@@ -33,8 +33,8 @@ from icalendar import (
from icalendar.tools import UIDGenerator
# wger
from wger import get_version
from wger.manager.models import Routine
from wger.version import get_version
logger = logging.getLogger(__name__)

View File

@@ -1,5 +1,5 @@
# wger
from wger import get_version
from wger.version import get_version
VERSION = get_version()

View File

@@ -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_version
VERSION = get_version()

View File

@@ -20,8 +20,8 @@ import sys
from datetime import timedelta
# wger
from wger import get_version
from wger.utils.constants import DOWNLOAD_INGREDIENT_WGER
from wger.version import get_version
"""

View File

@@ -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_version
VERSION = get_version()

View File

@@ -22,8 +22,8 @@ from django.views.generic import (
)
# wger
from wger import get_version
from wger.software import views
from wger.version import get_version
urlpatterns = [

View File

@@ -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_version
VERSION = get_version()

View File

@@ -38,8 +38,8 @@ from reportlab.platypus import (
)
# wger
from wger import get_version
from wger.core.models import Language
from wger.version import get_version
# ************************

View File

@@ -16,7 +16,7 @@
import requests
# wger
from wger import get_version
from wger.version import get_version
def wger_user_agent():

43
wger/version.py Normal file
View File

@@ -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)

View File

@@ -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_version
VERSION = get_version()