Skip to content

Commit

Permalink
Raise minimum recommended Python version to 3.9 (yt-dlp#11098)
Browse files Browse the repository at this point in the history
Authored by: bashonly
  • Loading branch information
bashonly authored Sep 27, 2024
1 parent 7509d69 commit cca534c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
5 changes: 5 additions & 0 deletions devscripts/changelog_override.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,10 @@
"action": "add",
"when": "6075a029dba70a89675ae1250e7cdfd91f0eba41",
"short": "[priority] Security: [[ie/douyutv] Do not use dangerous javascript source/URL](https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-3v33-3wmw-3785)\n - A dependency on potentially malicious third-party JavaScript code has been removed from the Douyu extractors"
},
{
"action": "add",
"when": "fb8b7f226d251e521a89b23c415e249e5b788e5c",
"short": "[priority] **The minimum *recommended* Python version has been raised to 3.9**\nSince Python 3.8 will reach end-of-life in October 2024, support for it will be dropped soon. [Read more](https://github.com/yt-dlp/yt-dlp/issues/10086)"
}
]
36 changes: 29 additions & 7 deletions yt_dlp/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,42 @@ def _get_binary_name():


def _get_system_deprecation():
MIN_SUPPORTED, MIN_RECOMMENDED = (3, 8), (3, 8)
MIN_SUPPORTED, MIN_RECOMMENDED = (3, 8), (3, 9)

if sys.version_info > MIN_RECOMMENDED:
return None

major, minor = sys.version_info[:2]
PYTHON_MSG = f'Please update to Python {".".join(map(str, MIN_RECOMMENDED))} or above'

if sys.version_info < MIN_SUPPORTED:
msg = f'Python version {major}.{minor} is no longer supported'
else:
msg = (f'Support for Python version {major}.{minor} has been deprecated. '
'\nYou may stop receiving updates on this version at any time')
return f'Python version {major}.{minor} is no longer supported! {PYTHON_MSG}'

EXE_MSG_TMPL = ('Support for {} has been deprecated. '
'See https://github.com/yt-dlp/yt-dlp/{} for details.\n{}')
STOP_MSG = 'You may stop receiving updates on this version at any time!'
variant = detect_variant()

# Temporary until Windows builds use 3.9, which will drop support for Win7 and 2008ServerR2
if variant in ('win_exe', 'win_x86_exe', 'py2exe'):
platform_name = platform.platform()
if any(platform_name.startswith(f'Windows-{name}') for name in ('7', '2008ServerR2')):
return EXE_MSG_TMPL.format('Windows 7/Server 2008 R2', 'issues/10086', STOP_MSG)
elif variant == 'py2exe':
return EXE_MSG_TMPL.format(
'py2exe builds (yt-dlp_min.exe)', 'issues/10087',
'In a future update you will be migrated to the PyInstaller-bundled executable. '
'This will be done automatically; no action is required on your part')
return None

# Temporary until aarch64/armv7l build flow is bumped to Ubuntu 20.04 and Python 3.9
elif variant in ('linux_aarch64_exe', 'linux_armv7l_exe'):
libc_ver = version_tuple(os.confstr('CS_GNU_LIBC_VERSION').partition(' ')[2])
if libc_ver < (2, 31):
return EXE_MSG_TMPL.format('system glibc version < 2.31', 'pull/8638', STOP_MSG)
return None

major, minor = MIN_RECOMMENDED
return f'{msg}! Please update to Python {major}.{minor} or above'
return f'Support for Python version {major}.{minor} has been deprecated. {PYTHON_MSG}'


def _sha256_file(path):
Expand Down

0 comments on commit cca534c

Please sign in to comment.