[devscripts] install_deps: Align options/terms with PEP 735 (#15200)

Authored by: bashonly
This commit is contained in:
bashonly
2025-12-07 17:39:05 -06:00
committed by GitHub
parent 1d43fa5af8
commit 29fe515d8d
11 changed files with 32 additions and 32 deletions

View File

@@ -343,14 +343,14 @@ jobs:
brew uninstall --ignore-dependencies python3
python3 -m venv ~/yt-dlp-build-venv
source ~/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 builds
python3 -m pip install -U --no-binary :all: -r requirements.txt
# We need to fuse our own universal2 wheels for curl_cffi
python3 -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.txt
for platform in "macosx_11_0_arm64" "macosx_11_0_x86_64"; do
python3 -m pip download \
--only-binary=:all: \
@@ -484,11 +484,11 @@ jobs:
mkdir /pyi-wheels
python -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 build
if ("${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: Prepare

View File

@@ -67,7 +67,7 @@ jobs:
unzip quickjs.zip
- name: Install test requirements
run: |
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.txt
python ./devscripts/install_deps.py --print -c certifi -c requests -c urllib3 -c yt-dlp-ejs >> requirements.txt
python -m pip install -U -r requirements.txt
- name: Run tests

View File

@@ -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 tests
timeout-minutes: 15
continue-on-error: False

View File

@@ -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 tests
continue-on-error: true
run: 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 tests
continue-on-error: true
run: python ./devscripts/run_tests.py download

View File

@@ -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 tests
timeout-minutes: 15
run: |
@@ -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 extractors
run: python ./devscripts/make_lazy_extractors.py
- name: Run ruff

View File

@@ -180,7 +180,7 @@ jobs:
- name: Install Requirements
run: |
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: Prepare
env:

View File

@@ -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 test
sudo apt -y install shellcheck
python -m pip install -U pyflakes
curl -LO "${ACTIONLINT_REPO}/releases/download/v${ACTIONLINT_VERSION}/${ACTIONLINT_TARBALL}"

View File

@@ -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]"

View File

@@ -265,7 +265,7 @@ To build the standalone executable, you must have Python and `pyinstaller` (plus
You can run the following commands:
```
python devscripts/install_deps.py --include-group pyinstaller
python devscripts/install_deps.py --include-extra pyinstaller
python devscripts/make_lazy_extractors.py
python -m bundle.pyinstaller
```

View File

@@ -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)
fi
runpy -m venv /yt-dlp-build-venv
@@ -28,7 +28,7 @@ runpy -m venv /yt-dlp-build-venv
source /yt-dlp-build-venv/bin/activate
# Inside the venv we use venvpy instead of runpy
venvpy -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 build
venvpy -m devscripts.install_deps "${INCLUDES[@]}"
venvpy -m devscripts.make_lazy_extractors
venvpy devscripts/update-version.py -c "${CHANNEL}" -r "${ORIGIN}" "${VERSION}"

View File

@@ -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 dep
targets = {}
if not args.only_optional_groups:
if not args.omit_default:
# legacy: 'dependencies' is empty now
targets.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):