-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install extra deps using setuptools.config.read_configuration
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#! /usr/bin/env python | ||
|
||
import argparse | ||
from pathlib import Path | ||
from setuptools.config import read_configuration | ||
|
||
|
||
def parse_args(): | ||
p = argparse.ArgumentParser() | ||
p.add_argument( | ||
'-c', '--conf-file', dest='conf_file', default='setup.cfg', | ||
help='Path to the setup.cfg file to read. Default is "%(default)s"', | ||
) | ||
p.add_argument( | ||
'-e', '--extras', dest='extras', | ||
help='Only show "extra" dependencies with the given name', | ||
) | ||
p.add_argument( | ||
'-d', '--delimiter', dest='delimiter', default=' ', | ||
help='Character(s) to separate the results. Default is "%(default)s"', | ||
) | ||
args = p.parse_args() | ||
args.conf_file = Path(args.conf_file) | ||
return args | ||
|
||
def main(): | ||
args = parse_args() | ||
conf = read_configuration(args.conf_file) | ||
if args.extras: | ||
try: | ||
deps = conf['options']['extras_require'][args.extras] | ||
except KeyError: | ||
return | ||
else: | ||
deps = conf['options']['install_requires'] | ||
print(args.delimiter.join(deps)) | ||
|
||
if __name__ == '__main__': | ||
main() |