[core] Raise minimum recommended Python version to 3.8 (#8183)
Authored by: Grub4K
This commit is contained in:
parent
1eaca74bc2
commit
61bdf15fc7
4 changed files with 37 additions and 12 deletions
|
@ -88,5 +88,10 @@
|
||||||
"when": "59e92b1f1833440bb2190f847eb735cf0f90bc85",
|
"when": "59e92b1f1833440bb2190f847eb735cf0f90bc85",
|
||||||
"short": "[rh:urllib] Simplify gzip decoding (#7611)",
|
"short": "[rh:urllib] Simplify gzip decoding (#7611)",
|
||||||
"authors": ["Grub4K"]
|
"authors": ["Grub4K"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "add",
|
||||||
|
"when": "c1d71d0d9f41db5e4306c86af232f5f6220a130b",
|
||||||
|
"short": "[priority] **The minimum *recommended* Python version has been raised to 3.8**\nSince Python 3.7 has reached end-of-life, support for it will be dropped soon. [Read more](https://github.com/yt-dlp/yt-dlp/issues/7803)"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -45,6 +45,9 @@ class TestExecution(unittest.TestCase):
|
||||||
self.assertTrue(os.path.exists(LAZY_EXTRACTORS))
|
self.assertTrue(os.path.exists(LAZY_EXTRACTORS))
|
||||||
|
|
||||||
_, stderr = self.run_yt_dlp(opts=('-s', 'test:'))
|
_, stderr = self.run_yt_dlp(opts=('-s', 'test:'))
|
||||||
|
# `MIN_RECOMMENDED` emits a deprecated feature warning for deprecated python versions
|
||||||
|
if stderr and stderr.startswith('Deprecated Feature: Support for Python'):
|
||||||
|
stderr = ''
|
||||||
self.assertFalse(stderr)
|
self.assertFalse(stderr)
|
||||||
|
|
||||||
subprocess.check_call([sys.executable, 'test/test_all_urls.py'], cwd=rootDir, stdout=subprocess.DEVNULL)
|
subprocess.check_call([sys.executable, 'test/test_all_urls.py'], cwd=rootDir, stdout=subprocess.DEVNULL)
|
||||||
|
|
|
@ -60,7 +60,7 @@ from .postprocessor import (
|
||||||
get_postprocessor,
|
get_postprocessor,
|
||||||
)
|
)
|
||||||
from .postprocessor.ffmpeg import resolve_mapping as resolve_recode_mapping
|
from .postprocessor.ffmpeg import resolve_mapping as resolve_recode_mapping
|
||||||
from .update import REPOSITORY, current_git_head, detect_variant
|
from .update import REPOSITORY, _get_system_deprecation, current_git_head, detect_variant
|
||||||
from .utils import (
|
from .utils import (
|
||||||
DEFAULT_OUTTMPL,
|
DEFAULT_OUTTMPL,
|
||||||
IDENTITY,
|
IDENTITY,
|
||||||
|
@ -640,17 +640,9 @@ class YoutubeDL:
|
||||||
for name, stream in self._out_files.items_ if name != 'console'
|
for name, stream in self._out_files.items_ if name != 'console'
|
||||||
})
|
})
|
||||||
|
|
||||||
# The code is left like this to be reused for future deprecations
|
system_deprecation = _get_system_deprecation()
|
||||||
MIN_SUPPORTED, MIN_RECOMMENDED = (3, 7), (3, 7)
|
if system_deprecation:
|
||||||
current_version = sys.version_info[:2]
|
self.deprecated_feature(system_deprecation.replace('\n', '\n '))
|
||||||
if current_version < MIN_RECOMMENDED:
|
|
||||||
msg = ('Support for Python version %d.%d has been deprecated. '
|
|
||||||
'See https://github.com/yt-dlp/yt-dlp/issues/3764 for more details.'
|
|
||||||
'\n You will no longer receive updates on this version')
|
|
||||||
if current_version < MIN_SUPPORTED:
|
|
||||||
msg = 'Python version %d.%d is no longer supported'
|
|
||||||
self.deprecated_feature(
|
|
||||||
f'{msg}! Please update to Python %d.%d or above' % (*current_version, *MIN_RECOMMENDED))
|
|
||||||
|
|
||||||
if self.params.get('allow_unplayable_formats'):
|
if self.params.get('allow_unplayable_formats'):
|
||||||
self.report_warning(
|
self.report_warning(
|
||||||
|
|
|
@ -112,6 +112,31 @@ def is_non_updateable():
|
||||||
detect_variant(), _NON_UPDATEABLE_REASONS['unknown' if VARIANT else 'other'])
|
detect_variant(), _NON_UPDATEABLE_REASONS['unknown' if VARIANT else 'other'])
|
||||||
|
|
||||||
|
|
||||||
|
def _get_system_deprecation():
|
||||||
|
MIN_SUPPORTED, MIN_RECOMMENDED = (3, 7), (3, 8)
|
||||||
|
|
||||||
|
if sys.version_info > MIN_RECOMMENDED:
|
||||||
|
return None
|
||||||
|
|
||||||
|
major, minor = sys.version_info[:2]
|
||||||
|
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. '
|
||||||
|
# Temporary until `win_x86_exe` uses 3.8, which will deprecate Vista and Server 2008
|
||||||
|
if detect_variant() == 'win_x86_exe':
|
||||||
|
platform_name = platform.platform()
|
||||||
|
if any(platform_name.startswith(f'Windows-{name}') for name in ('Vista', '2008Server')):
|
||||||
|
msg = 'Support for Windows Vista/Server 2008 has been deprecated. '
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
msg += ('See https://github.com/yt-dlp/yt-dlp/issues/7803 for details.'
|
||||||
|
'\nYou may stop receiving updates on this version at any time')
|
||||||
|
|
||||||
|
major, minor = MIN_RECOMMENDED
|
||||||
|
return f'{msg}! Please update to Python {major}.{minor} or above'
|
||||||
|
|
||||||
|
|
||||||
def _sha256_file(path):
|
def _sha256_file(path):
|
||||||
h = hashlib.sha256()
|
h = hashlib.sha256()
|
||||||
mv = memoryview(bytearray(128 * 1024))
|
mv = memoryview(bytearray(128 * 1024))
|
||||||
|
|
Loading…
Reference in a new issue