A feature-rich command-line audio/video downloader
[build] Optional dependencies cleanup (#9550)
bashonly58dd0f8d1eee
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex da5f262575..d773d5a1c5 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -125,11 +125,12 @@ jobs:sudo apt -y install zip pandoc man sedcat > ./requirements.txt << EOFpython=3.10.*+ pyinstallerbrotli-pythonEOFpython devscripts/install_deps.py --print \--exclude brotli --exclude brotlicffi \- --include secretstorage --include pyinstaller >> ./requirements.txt+ --include secretstorage >> ./requirements.txtmamba create -n build --file ./requirements.txt- name: Prepare@@ -247,7 +248,7 @@ jobs:run: |brew install coreutilspython3 devscripts/install_deps.py --user -o --include build- python3 devscripts/install_deps.py --print --include pyinstaller_macos > requirements.txt+ python3 devscripts/install_deps.py --print --include pyinstaller > requirements.txt# We need to ignore wheels otherwise we break universal2 buildspython3 -m pip install -U --user --no-binary :all: -r requirements.txt# We need to fuse our own universal2 wheels for curl_cffi@@ -319,7 +320,7 @@ jobs:run: |brew install coreutilspython3 devscripts/install_deps.py --user -o --include build- python3 devscripts/install_deps.py --user --include pyinstaller_macos --include curl_cffi+ python3 devscripts/install_deps.py --user --include pyinstaller --include curl_cffi- name: Preparerun: |diff --git a/devscripts/install_deps.py b/devscripts/install_deps.pyindex 889d9abeb7..d33fc637c6 100755--- a/devscripts/install_deps.py+++ b/devscripts/install_deps.py@@ -10,6 +10,8 @@ import argparseimport reimport subprocess+from pathlib import Path+from devscripts.tomlparse import parse_tomlfrom devscripts.utils import read_file@@ -17,17 +19,23 @@ from devscripts.utils import read_filedef parse_args():parser = argparse.ArgumentParser(description='Install dependencies for yt-dlp')parser.add_argument(- 'input', nargs='?', metavar='TOMLFILE', default='pyproject.toml', help='Input file (default: %(default)s)')+ 'input', nargs='?', metavar='TOMLFILE', default=Path(__file__).parent.parent / 'pyproject.toml',+ help='input file (default: %(default)s)')parser.add_argument(- '-e', '--exclude', metavar='DEPENDENCY', action='append', help='Exclude a dependency')+ '-e', '--exclude', metavar='DEPENDENCY', action='append',+ help='exclude a dependency')parser.add_argument(- '-i', '--include', metavar='GROUP', action='append', help='Include an optional dependency group')+ '-i', '--include', metavar='GROUP', action='append',+ help='include an optional dependency group')parser.add_argument(- '-o', '--only-optional', action='store_true', help='Only install optional dependencies')+ '-o', '--only-optional', action='store_true',+ help='only install optional dependencies')parser.add_argument(- '-p', '--print', action='store_true', help='Only print a requirements.txt to stdout')+ '-p', '--print', action='store_true',+ help='only print requirements to stdout')parser.add_argument(- '-u', '--user', action='store_true', help='Install with pip as --user')+ '-u', '--user', action='store_true',+ help='install with pip as --user')return parser.parse_args()@@ -37,24 +45,16 @@ def main():optional_groups = project_table['optional-dependencies']excludes = args.exclude or []- deps = []+ targets = []if not args.only_optional: # `-o` should exclude 'dependencies' and the 'default' group- deps.extend(project_table['dependencies'])+ targets.extend(project_table['dependencies'])if 'default' not in excludes: # `--exclude default` should exclude entire 'default' group- deps.extend(optional_groups['default'])-- def name(dependency):- return re.match(r'[\w-]+', dependency)[0].lower()-- target_map = {name(dep): dep for dep in deps}+ targets.extend(optional_groups['default'])for include in filter(None, map(optional_groups.get, args.include or [])):- target_map.update(zip(map(name, include), include))-- for exclude in map(name, excludes):- target_map.pop(exclude, None)+ targets.extend(include)- targets = list(target_map.values())+ targets = [t for t in targets if re.match(r'[\w-]+', t).group(0).lower() not in excludes]if args.print:for target in targets:diff --git a/pyproject.toml b/pyproject.tomlindex c57cac7574..9faf53b9c8 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -69,8 +69,10 @@ dev = ["isort","pytest",]-pyinstaller = ["pyinstaller>=6.3"]-pyinstaller_macos = ["pyinstaller==5.13.2"] # needed for curl_cffi builds+pyinstaller = [+ "pyinstaller>=6.3; sys_platform!='darwin'",+ "pyinstaller==5.13.2; sys_platform=='darwin'", # needed for curl_cffi+]py2exe = ["py2exe>=0.12"][project.urls]