From 744af5ba420704db16fda13af164b41355fd1098 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 5 Dec 2025 12:50:32 +1100 Subject: [PATCH] Update version checks: (#10954) * Update version checks: - Add error code for old python version - Fix min python version in docs - Various spelling fixes in docs * Fix docs link * Revert change to docs version string * Bug fix --- docs/docs/barcodes/index.md | 2 +- docs/docs/settings/MFA.md | 2 +- docs/docs/settings/email.md | 2 +- docs/docs/settings/error_codes.md | 6 ++++ docs/docs/start/backup.md | 2 +- docs/docs/start/config.md | 2 +- docs/mkdocs.yml | 2 +- src/backend/InvenTree/InvenTree/version.py | 42 ++++++++++++---------- 8 files changed, 36 insertions(+), 24 deletions(-) diff --git a/docs/docs/barcodes/index.md b/docs/docs/barcodes/index.md index 5632473594..8a8eb2ab20 100644 --- a/docs/docs/barcodes/index.md +++ b/docs/docs/barcodes/index.md @@ -76,7 +76,7 @@ Barcode scanning is a key feature of the [companion mobile app](../app/barcode.m ## Barcode History -If enabled, InvenTree can retain logs of the most recent barcode scans. This can be very useful for debugging or auditing purpopes. +If enabled, InvenTree can retain logs of the most recent barcode scans. This can be very useful for debugging or auditing purposes. Refer to the [barcode settings](../settings/global.md#barcodes) to enable barcode history logging. diff --git a/docs/docs/settings/MFA.md b/docs/docs/settings/MFA.md index 0c882443d2..cd6393f9fa 100644 --- a/docs/docs/settings/MFA.md +++ b/docs/docs/settings/MFA.md @@ -16,4 +16,4 @@ To make MFA mandatory for all users: ### Security Consideration -A user can lock themself out if they lose access to both the device with their TOTP app and their backup tokens. An admin can delete their tokens from the admin pages (they exist under the 'TOTP devices' / 'static devices' models) . This should be a last resort and only done by people knowledgeable about the [admin pages](../settings/admin.md) as changes there might circumvent InvneTrees business and security logic. +A user can lock themselves out if they lose access to both the device with their TOTP app and their backup tokens. An admin can delete their tokens from the admin pages (they exist under the 'TOTP devices' / 'static devices' models) . This should be a last resort and only done by people knowledgeable about the [admin pages](../settings/admin.md) as changes there might circumvent InvenTree's business and security logic. diff --git a/docs/docs/settings/email.md b/docs/docs/settings/email.md index a45c8b101b..7f420a2484 100644 --- a/docs/docs/settings/email.md +++ b/docs/docs/settings/email.md @@ -9,7 +9,7 @@ InvenTree can be configured to send emails to users, for various purposes. To enable this, email configuration settings must be supplied to the InvenTree [configuration options](../start/config.md#email-settings). !!! info "Functionality might be degraded" - Multiple functions of InvenTree require functioning email delivery, including *Password Reset*, *Notififications*, *Update Infos* + Multiple functions of InvenTree require functioning email delivery, including *Password Reset*, *Notifications*, *Update Infos* ### Outgoing diff --git a/docs/docs/settings/error_codes.md b/docs/docs/settings/error_codes.md index 75dc200d80..1de6491a18 100644 --- a/docs/docs/settings/error_codes.md +++ b/docs/docs/settings/error_codes.md @@ -95,6 +95,12 @@ An error occurred while reading the InvenTree configuration file. This might be Django is not installed in the current Python environment. This means that the InvenTree backend is not running within the correct [python virtual environment](../start/index.md#virtual-environment) or that the required Python packages were not installed correctly. +#### INVE-E15 + +**Python version not supported** + +This error occurs attempting to run InvenTree on a version of Python which is older than the minimum required version. We [require Python {{ config.extra.min_python_version }} or newer](../start/index.md#python-requirements) + ### INVE-W (InvenTree Warning) Warnings - These are non-critical errors which should be addressed when possible. diff --git a/docs/docs/start/backup.md b/docs/docs/start/backup.md index aee6193790..4861b7e77f 100644 --- a/docs/docs/start/backup.md +++ b/docs/docs/start/backup.md @@ -143,7 +143,7 @@ pip install django-storages[google] You will need to change the storage backend, which is set via the `INVENTREE_BACKUP_STORAGE` environment variable, or via `backup_storage` in the configuration file: ```yaml -backup_stoage: storages.backends.gcloud.GoogleCloudStorage +backup_storage: storages.backends.gcloud.GoogleCloudStorage ``` ### Configure Backend Options diff --git a/docs/docs/start/config.md b/docs/docs/start/config.md index ef4cd5ca5a..656c44e98a 100644 --- a/docs/docs/start/config.md +++ b/docs/docs/start/config.md @@ -488,7 +488,7 @@ The INVENTREE_CUSTOMIZE environment variable must contain a json object with the the wanted values. Example: ``` -INVENTREE_CUSTOMIZE={"login_message":"Hallo Michi"} +INVENTREE_CUSTOMIZE={"login_message":"Hello World"} ``` This example sets a login message. Take care of the double quotes. diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 9134d6ad04..9a1d28c4b2 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -359,7 +359,7 @@ extra: # provider: google # property: UA-143467500-1 - min_python_version: 3.10 + min_python_version: 3.11 min_invoke_version: 2.0.0 django_version: 5.2 docker_postgres_version: 17 diff --git a/src/backend/InvenTree/InvenTree/version.py b/src/backend/InvenTree/InvenTree/version.py index 81bca6570a..da1638a150 100644 --- a/src/backend/InvenTree/InvenTree/version.py +++ b/src/backend/InvenTree/InvenTree/version.py @@ -20,6 +20,8 @@ from .api_version import INVENTREE_API_TEXT, INVENTREE_API_VERSION # InvenTree software version INVENTREE_SW_VERSION = '1.2.0 dev' +# Minimum supported Python version +MIN_PYTHON_VERSION = (3, 11) logger = logging.getLogger('inventree') @@ -59,33 +61,36 @@ except Exception as exc: def checkMinPythonVersion(): - """Check that the Python version is at least 3.11.""" + """Check that the Python version meets the minimum requirements.""" + V_MIN_MAJOR, V_MIN_MINOR = MIN_PYTHON_VERSION + version = sys.version.split(' ')[0] - docs = 'https://docs.inventree.org/en/stable/start/intro/#python-requirements' + docs = 'https://docs.inventree.org/en/stable/start/#python-requirements' msg = f""" - InvenTree requires Python 3.11 or above - you are running version {version}. + INVE-E15: Python version not supported. + InvenTree requires Python {V_MIN_MAJOR}.{V_MIN_MINOR} or above - you are running version {version}. - Refer to the InvenTree documentation for more information: - {docs} """ - if sys.version_info.major < 3: # noqa: UP036 + if sys.version_info.major < V_MIN_MAJOR: raise RuntimeError(msg) - if sys.version_info.major == 3 and sys.version_info.minor < 11: + if sys.version_info.major == V_MIN_MAJOR and sys.version_info.minor < V_MIN_MINOR: raise RuntimeError(msg) - print(f'Python version {version} - {sys.executable}') + logger.info(f'Python version {version} - {sys.executable}') -def inventreeInstanceName(): +def inventreeInstanceName() -> str: """Returns the InstanceName settings for the current database.""" from common.settings import get_global_setting return get_global_setting('INVENTREE_INSTANCE') -def inventreeInstanceTitle(): +def inventreeInstanceTitle() -> str: """Returns the InstanceTitle for the current database.""" from common.settings import get_global_setting @@ -95,7 +100,7 @@ def inventreeInstanceTitle(): return 'InvenTree' -def inventreeVersion(): +def inventreeVersion() -> str: """Returns the InvenTree version string.""" return INVENTREE_SW_VERSION.lower().strip() @@ -110,12 +115,12 @@ def inventreeVersionTuple(version=None): return [int(g) for g in match.groups()] if match else [] -def isInvenTreeDevelopmentVersion(): +def isInvenTreeDevelopmentVersion() -> bool: """Return True if current InvenTree version is a "development" version.""" return inventreeVersion().endswith('dev') -def inventreeDocsVersion(): +def inventreeDocsVersion() -> str: """Return the version string matching the latest documentation. Development -> "latest" @@ -123,26 +128,27 @@ def inventreeDocsVersion(): """ if isInvenTreeDevelopmentVersion(): return 'latest' - return INVENTREE_SW_VERSION # pragma: no cover + + return INVENTREE_SW_VERSION -def inventreeDocUrl(): +def inventreeDocUrl() -> str: """Return URL for InvenTree documentation site.""" tag = inventreeDocsVersion() return f'https://docs.inventree.org/en/{tag}' -def inventreeAppUrl(): +def inventreeAppUrl() -> str: """Return URL for InvenTree app site.""" - return 'https://docs.inventree.org/app/' + return 'https://docs.inventree.org/en/stable/app/' -def inventreeGithubUrl(): +def inventreeGithubUrl() -> str: """Return URL for InvenTree github site.""" return 'https://github.com/InvenTree/InvenTree/' -def isInvenTreeUpToDate(): +def isInvenTreeUpToDate() -> bool: """Test if the InvenTree instance is "up to date" with the latest version. A background task periodically queries GitHub for latest version, and stores it to the database as "_INVENTREE_LATEST_VERSION" @@ -164,7 +170,7 @@ def isInvenTreeUpToDate(): return inventree_version >= latest_version # pragma: no cover -def inventreeApiVersion(): +def inventreeApiVersion() -> int: """Returns current API version of InvenTree.""" return INVENTREE_API_VERSION