Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/issue 4850 #4851

Merged
merged 3 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"spglib~=1.14"
],
"notebook": [
"jupyter-client~=6.1,<6.1.13",
"jupyter~=1.0",
"notebook~=6.1,>=6.1.5"
],
Expand All @@ -108,7 +109,7 @@
"pytest~=6.0",
"pytest-asyncio~=0.12",
"pytest-timeout~=1.3",
"pytest-cov~=2.7",
"pytest-cov~=2.7,<2.11",
"pytest-rerunfailures~=9.1,>=9.1.1",
"pytest-benchmark~=3.2",
"pympler~=0.9",
Expand Down
31 changes: 31 additions & 0 deletions utils/dependency_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,37 @@ def check_requirements(extras, github_annotate): # pylint disable: too-many-loc
click.secho("Requirements files appear to be in sync with specifications in 'setup.json'.", fg='green')


@cli.command()
@click.argument('extras', nargs=-1)
@click.option('--format', 'fmt', type=click.Choice(['pip', 'pipfile']), default='pip')
def show_requirements(extras, fmt):
"""Show the installation requirements.

For example:

show-requirements --format=pipfile all

This will show all reqiurements including *all* extras in Pipfile format.
"""

# Read the requirements from 'setup.json'
setup_cfg = _load_setup_cfg()

if 'all' in extras:
extras = list(setup_cfg['extras_require'])

to_install = {Requirement.parse(r) for r in setup_cfg['install_requires']}
for key in extras:
to_install.update(Requirement.parse(r) for r in setup_cfg['extras_require'][key])

if fmt == 'pip':
click.echo('\n'.join(sorted(map(str, to_install))))
elif fmt == 'pipfile':
click.echo('[packages]')
for requirement in sorted(to_install, key=str):
click.echo(f'{requirement.name} = "{requirement.specifier}"')


@cli.command()
@click.argument('extras', nargs=-1)
def pip_install_extras(extras):
Expand Down