]>
jfr.im git - yt-dlp.git/blob - devscripts/install_deps.py
3 # Allow execution from anywhere
7 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
13 from devscripts
.tomlparse
import parse_toml
14 from devscripts
.utils
import read_file
18 parser
= argparse
.ArgumentParser(description
='Install dependencies for yt-dlp')
20 'input', nargs
='?', metavar
='TOMLFILE', default
='pyproject.toml', help='Input file (default: %(default)s)')
22 '-e', '--exclude', metavar
='REQUIREMENT', action
='append', help='Exclude a required dependency')
24 '-i', '--include', metavar
='GROUP', action
='append', help='Include an optional dependency group')
26 '-o', '--only-optional', action
='store_true', help='Only install optional dependencies')
28 '-p', '--print', action
='store_true', help='Only print a requirements.txt to stdout')
30 '-u', '--user', action
='store_true', help='Install with pip as --user')
31 return parser
.parse_args()
36 toml_data
= parse_toml(read_file(args
.input))
37 deps
= toml_data
['project']['dependencies']
38 targets
= deps
.copy() if not args
.only_optional
else []
40 for exclude
in args
.exclude
or []:
42 simplified_dep
= re
.match(r
'[\w-]+', dep
)[0]
43 if dep
in targets
and (exclude
.lower() == simplified_dep
.lower() or exclude
== dep
):
46 optional_deps
= toml_data
['project']['optional-dependencies']
47 for include
in args
.include
or []:
48 group
= optional_deps
.get(include
)
53 for target
in targets
:
57 pip_args
= [sys
.executable
, '-m', 'pip', 'install', '-U']
59 pip_args
.append('--user')
60 pip_args
.extend(targets
)
62 return subprocess
.call(pip_args
)
65 if __name__
== '__main__':