From a886cf3e900f4a2ec00af705f883539269545609 Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Tue, 22 Oct 2024 04:20:20 +0000 Subject: [PATCH] [build] Migrate `py2exe` builds to `win_exe` (#11256) This commit removes py2exe support Closes #10087 Authored by: bashonly --- .github/workflows/build.yml | 12 ++------ README.md | 15 +--------- bundle/py2exe.py | 59 ------------------------------------- pyproject.toml | 3 -- yt_dlp/update.py | 11 ++----- 5 files changed, 7 insertions(+), 93 deletions(-) delete mode 100755 bundle/py2exe.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 495d3c630..64227d974 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -419,22 +419,16 @@ jobs: run: | python -m bundle.pyinstaller python -m bundle.pyinstaller --onedir - Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_real.exe Compress-Archive -Path ./dist/yt-dlp/* -DestinationPath ./dist/yt-dlp_win.zip - - name: Install Requirements (py2exe) + - name: Add migration executable for py2exe run: | - python devscripts/install_deps.py --include py2exe - - name: Build (py2exe) - run: | - python -m bundle.py2exe - Move-Item ./dist/yt-dlp.exe ./dist/yt-dlp_min.exe - Move-Item ./dist/yt-dlp_real.exe ./dist/yt-dlp.exe + Copy-Item ./dist/yt-dlp.exe ./dist/yt-dlp_min.exe - name: Verify --update-to if: vars.UPDATE_TO_VERIFICATION run: | - foreach ($name in @("yt-dlp","yt-dlp_min")) { + foreach ($name in @("yt-dlp")) { Copy-Item "./dist/${name}.exe" "./dist/${name}_downgraded.exe" $version = & "./dist/${name}.exe" --version & "./dist/${name}_downgraded.exe" -v --update-to yt-dlp/yt-dlp@2023.03.04 diff --git a/README.md b/README.md index fc38a529a..6bd632dd7 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,6 @@ File|Description File|Description :---|:--- [yt-dlp_x86.exe](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_x86.exe)|Windows (Win7 SP1+) standalone x86 (32-bit) binary -[yt-dlp_min.exe](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_min.exe)|Windows (Win7 SP1+) standalone x64 binary built with `py2exe`
([Not recommended](#standalone-py2exe-builds-windows)) [yt-dlp_linux](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux)|Linux standalone x64 binary [yt-dlp_linux_armv7l](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_armv7l)|Linux standalone armv7l (32-bit) binary [yt-dlp_linux_aarch64](https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_aarch64)|Linux standalone aarch64 (64-bit) binary @@ -260,18 +259,6 @@ After installing these, simply run `make`. You can also run `make yt-dlp` instead to compile only the binary without updating any of the additional files. (The build tools marked with **\*** are not needed for this) -### Standalone Py2Exe Builds (Windows) - -While we provide the option to build with [py2exe](https://www.py2exe.org), it is recommended to build [using PyInstaller](#standalone-pyinstaller-builds) instead since the py2exe builds **cannot contain `pycryptodomex`/`certifi`/`requests` and need VC++14** on the target computer to run. - -If you wish to build it anyway, install Python (if it is not already installed) and you can run the following commands: - -``` -py devscripts/install_deps.py --include py2exe -py devscripts/make_lazy_extractors.py -py -m bundle.py2exe -``` - ### Related scripts * **`devscripts/install_deps.py`** - Install dependencies for yt-dlp. @@ -1933,7 +1920,7 @@ Plugins can be installed using various methods and locations. * Plugin packages can be installed and managed using `pip`. See [yt-dlp-sample-plugins](https://github.com/yt-dlp/yt-dlp-sample-plugins) for an example. * Note: plugin files between plugin packages installed with pip must have unique filenames. * Any path in `PYTHONPATH` is searched in for the `yt_dlp_plugins` namespace folder. - * Note: This does not apply for Pyinstaller/py2exe builds. + * Note: This does not apply for Pyinstaller builds. `.zip`, `.egg` and `.whl` archives containing a `yt_dlp_plugins` namespace folder in their root are also supported as plugin packages. diff --git a/bundle/py2exe.py b/bundle/py2exe.py deleted file mode 100755 index 5b7f4883b..000000000 --- a/bundle/py2exe.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python3 - -# Allow execution from anywhere -import os -import sys - -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - -import warnings - -from py2exe import freeze - -from devscripts.utils import read_version - -VERSION = read_version() - - -def main(): - warnings.warn( - 'py2exe builds do not support pycryptodomex and needs VC++14 to run. ' - 'It is recommended to run "pyinst.py" to build using pyinstaller instead') - - freeze( - console=[{ - 'script': './yt_dlp/__main__.py', - 'dest_base': 'yt-dlp', - 'icon_resources': [(1, 'devscripts/logo.ico')], - }], - version_info={ - 'version': VERSION, - 'description': 'A feature-rich command-line audio/video downloader', - 'comments': 'Official repository: ', - 'product_name': 'yt-dlp', - 'product_version': VERSION, - }, - options={ - 'bundle_files': 0, - 'compressed': 1, - 'optimize': 2, - 'dist_dir': './dist', - 'excludes': [ - # py2exe cannot import Crypto - 'Crypto', - 'Cryptodome', - # requests >=2.32.0 breaks py2exe builds due to certifi dependency - 'requests', - 'urllib3', - ], - 'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'], - # Modules that are only imported dynamically must be added here - 'includes': ['yt_dlp.compat._legacy', 'yt_dlp.compat._deprecated', - 'yt_dlp.utils._legacy', 'yt_dlp.utils._deprecated'], - }, - zipfile=None, - ) - - -if __name__ == '__main__': - main() diff --git a/pyproject.toml b/pyproject.toml index 200a9c99a..be81c265c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,9 +85,6 @@ test = [ pyinstaller = [ "pyinstaller>=6.10.0", # Windows temp cleanup fixed in 6.10.0 ] -py2exe = [ - "py2exe>=0.12", -] [project.urls] Documentation = "https://github.com/yt-dlp/yt-dlp#readme" diff --git a/yt_dlp/update.py b/yt_dlp/update.py index 4cf3bdc32..0172acfd6 100644 --- a/yt_dlp/update.py +++ b/yt_dlp/update.py @@ -103,7 +103,6 @@ def current_git_head(): _FILE_SUFFIXES = { 'zip': '', - 'py2exe': '_min.exe', 'win_exe': '.exe', 'win_x86_exe': '_x86.exe', 'darwin_exe': '_macos', @@ -117,6 +116,7 @@ _NON_UPDATEABLE_REASONS = { **{variant: None for variant in _FILE_SUFFIXES}, # Updatable **{variant: f'Auto-update is not supported for unpackaged {name} executable; Re-download the latest release' for variant, name in {'win32_dir': 'Windows', 'darwin_dir': 'MacOS', 'linux_dir': 'Linux'}.items()}, + 'py2exe': 'py2exe is no longer supported by yt-dlp; This executable cannot be updated', 'source': 'You cannot update when running from source code; Use git to pull the latest changes', 'unknown': 'You installed yt-dlp from a manual build or with a package manager; Use that to update', 'other': 'You are using an unofficial build of yt-dlp; Build the executable again', @@ -152,15 +152,10 @@ def _get_system_deprecation(): 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'): + if variant in ('win_exe', 'win_x86_exe'): 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 @@ -525,7 +520,7 @@ class Updater: return os.rename(old_filename, self.filename) variant = detect_variant() - if variant.startswith('win') or variant == 'py2exe': + if variant.startswith('win'): atexit.register(Popen, f'ping 127.0.0.1 -n 5 -w 1000 & del /F "{old_filename}"', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) elif old_filename: