Adding [aliases] fails with error: invalid command 'xyz'

Viewed 356

Attempting to add shortcuts such as cov = coverage report --show-missing to the [aliases] section of setup.cfg causes python setup.py cov to fail with error: invalid command 'coverage'. What additional options are needed to support this?

Version info:

$ python -V
Python 3.7.3
$ pip list | egrep 'setuptools|pip|coverage|pytest'
coverage           5.2.1
pip                20.2.2
pytest             5.4.3
pytest-html        2.1.1
pytest-metadata    1.10.0
setuptools         50.0.0

setup.cfg:

[aliases]
test = coverage run -m pytest --html=pytest-report.html --self-contained-html
cov = coverage report --show-missing
covhtml = coverage html --title "Coverage report - xyz"

[tool:pytest]
testpaths = tests

[coverage:run]
branch = True
source = pyapp

[options]
# ...
install_requires =
    Flask==1.1.*
    psycopg2==2.8.*
    requests==2.*
    werkzeug==1.*
    click==7.*
setup_requires =
    pytest-runner
tests_require =
    coverage
    pytest
    pytest-html
1 Answers

setup.cfg aliases creates aliases for setup.py, not general commands. In your case python setup.py cov is equivalent to

python setup.py coverage report --show-missing

and setup.py complains it doesn't have a command coverage.

Related