Skip to content

Commit

Permalink
Core: rework python version check (#4294)
Browse files Browse the repository at this point in the history
* Docs: update min required version

and add comment about security.

* Core: rework python version check

* CI: set min micro update for build and release
  • Loading branch information
black-sliver authored Nov 30, 2024
1 parent ca6792a commit b83b486
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:
- name: Install python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '~3.12.7'
check-latest: true
- name: Download run-time dependencies
run: |
Invoke-WebRequest -Uri https://github.com/Ijwu/Enemizer/releases/download/${Env:ENEMIZER_VERSION}/win-x64.zip -OutFile enemizer.zip
Expand Down Expand Up @@ -111,7 +112,8 @@ jobs:
- name: Get a recent python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '~3.12.7'
check-latest: true
- name: Install build-time dependencies
run: |
echo "PYTHON=python3.12" >> $GITHUB_ENV
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ jobs:
- name: Get a recent python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '~3.12.7'
check-latest: true
- name: Install build-time dependencies
run: |
echo "PYTHON=python3.12" >> $GITHUB_ENV
Expand Down
11 changes: 9 additions & 2 deletions ModuleUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
import warnings


if sys.version_info < (3, 10, 11):
raise RuntimeError(f"Incompatible Python Version found: {sys.version_info}. 3.10.11+ is supported.")
if sys.platform in ("win32", "darwin") and sys.version_info < (3, 10, 11):
# Official micro version updates. This should match the number in docs/running from source.md.
raise RuntimeError(f"Incompatible Python Version found: {sys.version_info}. Official 3.10.15+ is supported.")
elif sys.platform in ("win32", "darwin") and sys.version_info < (3, 10, 15):
# There are known security issues, but no easy way to install fixed versions on Windows for testing.
warnings.warn(f"Python Version {sys.version_info} has security issues. Don't use in production.")
elif sys.version_info < (3, 10, 1):
# Other platforms may get security backports instead of micro updates, so the number is unreliable.
raise RuntimeError(f"Incompatible Python Version found: {sys.version_info}. 3.10.1+ is supported.")

# don't run update if environment is frozen/compiled or if not the parent process (skip in subprocess)
_skip_update = bool(getattr(sys, "frozen", False) or multiprocessing.parent_process())
Expand Down
4 changes: 3 additions & 1 deletion docs/running from source.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use that version. These steps are for developers or platforms without compiled r
## General

What you'll need:
* [Python 3.10.15 or newer](https://www.python.org/downloads/), not the Windows Store version
* [Python 3.10.11 or newer](https://www.python.org/downloads/), not the Windows Store version
* On Windows, please consider only using the latest supported version in production environments since security
updates for older versions are not easily available.
* Python 3.12.x is currently the newest supported version
* pip: included in downloads from python.org, separate in many Linux distributions
* Matching C compiler
Expand Down

0 comments on commit b83b486

Please sign in to comment.