diff --git a/openstack_requirements/cmds/generate.py b/openstack_requirements/cmds/generate.py index 6a61851108..e4b29dd227 100644 --- a/openstack_requirements/cmds/generate.py +++ b/openstack_requirements/cmds/generate.py @@ -15,6 +15,7 @@ import copy import hashlib import optparse import os.path +import shutil import subprocess import sys @@ -155,7 +156,7 @@ def _validate_options(options): if not options.pythons: raise Exception("No Pythons given - see -p.") for python in options.pythons: - if not os.path.exists(python): + if not shutil.which(python): raise Exception( "Python %(python)s not found." % dict(python=python)) if not options.requirements: @@ -227,6 +228,8 @@ def main(argv=None, stdout=None): _freeze(options.requirements, python) for python in options.pythons] _clone_versions(freezes, options) blacklist = _parse_blacklist(options.blacklist) - frozen = sorted(_combine_freezes(freezes, blacklist), key=_make_sort_key) + frozen = [ + "# generated using: tox -e generate\n", + *sorted(_combine_freezes(freezes, blacklist), key=_make_sort_key)] stdout.writelines(frozen) stdout.flush() diff --git a/tox.ini b/tox.ini index 03efdcb54b..67b0ff0d04 100644 --- a/tox.ini +++ b/tox.ini @@ -30,10 +30,11 @@ commands = {posargs} commands = update-requirements {posargs} [testenv:generate] +description = Regenerates upper-constraints.txt # Generate needs an unconstrained install to get new dependencies deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -commands = generate-constraints {posargs} +commands = generate-constraints {posargs: -b blacklist.txt -r global-requirements.txt -p python3.6 -p python3.7 -p python3.8 -p python3.9 > upper-constraints.txt} [testenv:validate] commands = @@ -49,6 +50,7 @@ whitelist_externals = {[testenv:linters]whitelist_externals} commands = {[testenv:linters]commands} [testenv:linters] +description = Perform linting deps = hacking>=1.0.0 bashate>=0.5.1