A feature-rich command-line audio/video downloader
[devscripts] `install_deps`: Align options/terms with PEP 735 (#15200)
bashonly29fe515d8d33
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 8f5df4ce4d..9a861bb4fd 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -343,14 +343,14 @@ jobs:brew uninstall --ignore-dependencies python3python3 -m venv ~/yt-dlp-build-venvsource ~/yt-dlp-build-venv/bin/activate- python3 devscripts/install_deps.py --only-optional-groups --include-group build- python3 devscripts/install_deps.py --print --include-group pyinstaller > requirements.txt+ python3 devscripts/install_deps.py --omit-default --include-extra build+ python3 devscripts/install_deps.py --print --include-extra pyinstaller > requirements.txt# We need to ignore wheels otherwise we break universal2 buildspython3 -m pip install -U --no-binary :all: -r requirements.txt# We need to fuse our own universal2 wheels for curl_cffipython3 -m pip install -U 'delocate==0.11.0'mkdir curl_cffi_whls curl_cffi_universal2- python3 devscripts/install_deps.py --print --only-optional-groups --include-group curl-cffi > requirements.txt+ python3 devscripts/install_deps.py --print --omit-default --include-extra curl-cffi > requirements.txtfor platform in "macosx_11_0_arm64" "macosx_11_0_x86_64"; dopython3 -m pip download \--only-binary=:all: \@@ -484,11 +484,11 @@ jobs:mkdir /pyi-wheelspython -m pip download -d /pyi-wheels --no-deps --require-hashes "pyinstaller@${Env:PYI_URL}#sha256=${Env:PYI_HASH}"python -m pip install --force-reinstall -U "/pyi-wheels/${Env:PYI_WHEEL}"- python devscripts/install_deps.py --only-optional-groups --include-group build+ python devscripts/install_deps.py --omit-default --include-extra buildif ("${Env:ARCH}" -eq "x86") {python devscripts/install_deps.py} else {- python devscripts/install_deps.py --include-group curl-cffi+ python devscripts/install_deps.py --include-extra curl-cffi}- name: Preparediff --git a/.github/workflows/challenge-tests.yml b/.github/workflows/challenge-tests.ymlindex 89895eb07b..7f1bcfb5b1 100644--- a/.github/workflows/challenge-tests.yml+++ b/.github/workflows/challenge-tests.yml@@ -67,7 +67,7 @@ jobs:unzip quickjs.zip- name: Install test requirementsrun: |- python ./devscripts/install_deps.py --print --only-optional-groups --include-group test > requirements.txt+ python ./devscripts/install_deps.py --print --omit-default --include-extra test > requirements.txtpython ./devscripts/install_deps.py --print -c certifi -c requests -c urllib3 -c yt-dlp-ejs >> requirements.txtpython -m pip install -U -r requirements.txt- name: Run testsdiff --git a/.github/workflows/core.yml b/.github/workflows/core.ymlindex 3cb17f2b7d..f2d595ef73 100644--- a/.github/workflows/core.yml+++ b/.github/workflows/core.yml@@ -63,7 +63,7 @@ jobs:with:python-version: ${{ matrix.python-version }}- name: Install test requirements- run: python ./devscripts/install_deps.py --include-group test --include-group curl-cffi+ run: python ./devscripts/install_deps.py --include-extra test --include-extra curl-cffi- name: Run teststimeout-minutes: 15continue-on-error: Falsediff --git a/.github/workflows/download.yml b/.github/workflows/download.ymlindex d075270d7b..343c720c5e 100644--- a/.github/workflows/download.yml+++ b/.github/workflows/download.yml@@ -15,7 +15,7 @@ jobs:with:python-version: '3.10'- name: Install test requirements- run: python ./devscripts/install_deps.py --include-group dev+ run: python ./devscripts/install_deps.py --include-extra dev- name: Run testscontinue-on-error: truerun: python ./devscripts/run_tests.py download@@ -42,7 +42,7 @@ jobs:with:python-version: ${{ matrix.python-version }}- name: Install test requirements- run: python ./devscripts/install_deps.py --include-group dev+ run: python ./devscripts/install_deps.py --include-extra dev- name: Run testscontinue-on-error: truerun: python ./devscripts/run_tests.py downloaddiff --git a/.github/workflows/quick-test.yml b/.github/workflows/quick-test.ymlindex a6e84b1d80..4476d018b7 100644--- a/.github/workflows/quick-test.yml+++ b/.github/workflows/quick-test.yml@@ -15,7 +15,7 @@ jobs:with:python-version: '3.10'- name: Install test requirements- run: python ./devscripts/install_deps.py --only-optional-groups --include-group test+ run: python ./devscripts/install_deps.py --omit-default --include-extra test- name: Run teststimeout-minutes: 15run: |@@ -31,7 +31,7 @@ jobs:with:python-version: '3.10'- name: Install dev dependencies- run: python ./devscripts/install_deps.py --only-optional-groups --include-group static-analysis+ run: python ./devscripts/install_deps.py --omit-default --include-extra static-analysis- name: Make lazy extractorsrun: python ./devscripts/make_lazy_extractors.py- name: Run ruffdiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex afe1d384b4..2dfc7f2aa7 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -180,7 +180,7 @@ jobs:- name: Install Requirementsrun: |sudo apt -y install pandoc man- python devscripts/install_deps.py --only-optional-groups --include-group build+ python devscripts/install_deps.py --omit-default --include-extra build- name: Prepareenv:diff --git a/.github/workflows/test-workflows.yml b/.github/workflows/test-workflows.ymlindex d39ab8814b..5fda040b2a 100644--- a/.github/workflows/test-workflows.yml+++ b/.github/workflows/test-workflows.yml@@ -34,7 +34,7 @@ jobs:env:ACTIONLINT_TARBALL: ${{ format('actionlint_{0}_linux_amd64.tar.gz', env.ACTIONLINT_VERSION) }}run: |- python -m devscripts.install_deps --only-optional-groups --include-group test+ python -m devscripts.install_deps --omit-default --include-extra testsudo apt -y install shellcheckpython -m pip install -U pyflakescurl -LO "${ACTIONLINT_REPO}/releases/download/v${ACTIONLINT_VERSION}/${ACTIONLINT_TARBALL}"diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 99f18b2f32..f161da3c1d 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -177,7 +177,7 @@ While it is strongly recommended to use `hatch` for yt-dlp development, if you a```shell# To only install development dependencies:-$ python -m devscripts.install_deps --include-group dev+$ python -m devscripts.install_deps --include-extra dev# Or, for an editable install plus dev dependencies:$ python -m pip install -e ".[default,dev]"diff --git a/README.md b/README.mdindex e04d98045b..d42ebd539d 100644--- a/README.md+++ b/README.md@@ -265,7 +265,7 @@ To build the standalone executable, you must have Python and `pyinstaller` (plusYou can run the following commands:```-python devscripts/install_deps.py --include-group pyinstaller+python devscripts/install_deps.py --include-extra pyinstallerpython devscripts/make_lazy_extractors.pypython -m bundle.pyinstaller```diff --git a/bundle/docker/linux/build.sh b/bundle/docker/linux/build.shindex b30d40980e..d6d1791865 100755--- a/bundle/docker/linux/build.sh+++ b/bundle/docker/linux/build.sh@@ -15,12 +15,12 @@ function venvpy {}INCLUDES=(- --include-group pyinstaller- --include-group secretstorage+ --include-extra pyinstaller+ --include-extra secretstorage)if [[ -z "${EXCLUDE_CURL_CFFI:-}" ]]; then- INCLUDES+=(--include-group curl-cffi)+ INCLUDES+=(--include-extra curl-cffi)firunpy -m venv /yt-dlp-build-venv@@ -28,7 +28,7 @@ runpy -m venv /yt-dlp-build-venvsource /yt-dlp-build-venv/bin/activate# Inside the venv we use venvpy instead of runpyvenvpy -m ensurepip --upgrade --default-pip-venvpy -m devscripts.install_deps --only-optional-groups --include-group build+venvpy -m devscripts.install_deps --omit-default --include-extra buildvenvpy -m devscripts.install_deps "${INCLUDES[@]}"venvpy -m devscripts.make_lazy_extractorsvenvpy devscripts/update-version.py -c "${CHANNEL}" -r "${ORIGIN}" "${VERSION}"diff --git a/devscripts/install_deps.py b/devscripts/install_deps.pyindex 07c646a4c0..762213e2f9 100755--- a/devscripts/install_deps.py+++ b/devscripts/install_deps.py@@ -25,16 +25,16 @@ def parse_args():'-e', '--exclude-dependency', metavar='DEPENDENCY', action='append',help='exclude a dependency (can be used multiple times)')parser.add_argument(- '-i', '--include-group', metavar='GROUP', action='append',- help='include an optional dependency group (can be used multiple times)')+ '-i', '--include-extra', metavar='EXTRA', action='append',+ help='include an extra/optional-dependencies list (can be used multiple times)')parser.add_argument('-c', '--cherry-pick', metavar='DEPENDENCY', action='append',help=('only include a specific dependency from the resulting dependency list ''(can be used multiple times)'))parser.add_argument(- '-o', '--only-optional-groups', action='store_true',- help='omit default dependencies unless the "default" group is specified with --include-group')+ '-o', '--omit-default', action='store_true',+ help='omit the "default" extra unless it is explicitly included (it is included by default)')parser.add_argument('-p', '--print', action='store_true',help='only print requirements to stdout')@@ -51,27 +51,27 @@ def uniq(arg) -> dict[str, None]:def main():args = parse_args()project_table = parse_toml(read_file(args.input))['project']- recursive_pattern = re.compile(rf'{project_table["name"]}\[(?P<group_name>[\w-]+)\]')- optional_groups = project_table['optional-dependencies']+ recursive_pattern = re.compile(rf'{project_table["name"]}\[(?P<extra_name>[\w-]+)\]')+ extras = project_table['optional-dependencies']excludes = uniq(args.exclude_dependency)only_includes = uniq(args.cherry_pick)- include_groups = uniq(args.include_group)+ include_extras = uniq(args.include_extra)- def yield_deps(group):- for dep in group:+ def yield_deps(extra):+ for dep in extra:if mobj := recursive_pattern.fullmatch(dep):- yield from optional_groups.get(mobj.group('group_name'), ())+ yield from extras.get(mobj.group('extra_name'), ())else:yield deptargets = {}- if not args.only_optional_groups:+ if not args.omit_default:# legacy: 'dependencies' is empty nowtargets.update(dict.fromkeys(project_table['dependencies']))- targets.update(dict.fromkeys(yield_deps(optional_groups['default'])))+ targets.update(dict.fromkeys(yield_deps(extras['default'])))- for include in filter(None, map(optional_groups.get, include_groups)):+ for include in filter(None, map(extras.get, include_extras)):targets.update(dict.fromkeys(yield_deps(include)))def target_filter(target):