mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-24 07:40:30 +01:00
[build] Add default
optional dependency group (#9295)
Authored by: bashonly, Grub4K Co-authored-by: Simon Sawicki <contact@grub4k.xyz>
This commit is contained in:
parent
ac340d0745
commit
cf91400a1d
@ -218,7 +218,7 @@ # To update to nightly from stable executable/binary:
|
|||||||
yt-dlp --update-to nightly
|
yt-dlp --update-to nightly
|
||||||
|
|
||||||
# To install nightly with pip:
|
# To install nightly with pip:
|
||||||
python -m pip install -U --pre yt-dlp
|
python -m pip install -U --pre yt-dlp[default]
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- MANPAGE: BEGIN EXCLUDED SECTION -->
|
<!-- MANPAGE: BEGIN EXCLUDED SECTION -->
|
||||||
|
@ -19,7 +19,7 @@ def parse_args():
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'input', nargs='?', metavar='TOMLFILE', default='pyproject.toml', help='Input file (default: %(default)s)')
|
'input', nargs='?', metavar='TOMLFILE', default='pyproject.toml', help='Input file (default: %(default)s)')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-e', '--exclude', metavar='REQUIREMENT', action='append', help='Exclude a required dependency')
|
'-e', '--exclude', metavar='DEPENDENCY', action='append', help='Exclude a dependency')
|
||||||
parser.add_argument(
|
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(
|
parser.add_argument(
|
||||||
@ -33,21 +33,28 @@ def parse_args():
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
toml_data = parse_toml(read_file(args.input))
|
project_table = parse_toml(read_file(args.input))['project']
|
||||||
deps = toml_data['project']['dependencies']
|
optional_groups = project_table['optional-dependencies']
|
||||||
targets = deps.copy() if not args.only_optional else []
|
excludes = args.exclude or []
|
||||||
|
|
||||||
for exclude in args.exclude or []:
|
deps = []
|
||||||
for dep in deps:
|
if not args.only_optional: # `-o` should exclude 'dependencies' and the 'default' group
|
||||||
simplified_dep = re.match(r'[\w-]+', dep)[0]
|
deps.extend(project_table['dependencies'])
|
||||||
if dep in targets and (exclude.lower() == simplified_dep.lower() or exclude == dep):
|
if 'default' not in excludes: # `--exclude default` should exclude entire 'default' group
|
||||||
targets.remove(dep)
|
deps.extend(optional_groups['default'])
|
||||||
|
|
||||||
optional_deps = toml_data['project']['optional-dependencies']
|
def name(dependency):
|
||||||
for include in args.include or []:
|
return re.match(r'[\w-]+', dependency)[0].lower()
|
||||||
group = optional_deps.get(include)
|
|
||||||
if group:
|
target_map = {name(dep): dep for dep in deps}
|
||||||
targets.extend(group)
|
|
||||||
|
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 = list(target_map.values())
|
||||||
|
|
||||||
if args.print:
|
if args.print:
|
||||||
for target in targets:
|
for target in targets:
|
||||||
|
@ -51,6 +51,7 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
|
default = []
|
||||||
secretstorage = [
|
secretstorage = [
|
||||||
"cffi",
|
"cffi",
|
||||||
"secretstorage",
|
"secretstorage",
|
||||||
|
Loading…
Reference in New Issue
Block a user