tox siblings installed packages: Add PEP 440 direct reference format

softwarefactory-project tutorial [1] "Scenario 1" does not fail as it should
for version 3.4, because the "git+https://..." dependency is printed as
"demolib @ git+https://...", which is not listed as an installed package
because it does not match version compare '=='

Starting from pip 20.1, "freeze" command outputs requirements package using direct
references [2], a Helper was introduced by [3] used in freeze by [4]

This change adds the urlspec info extraction.

Additional Info:
- [5] requirements format PEP508
- [6] PEP610 referenced by [4]
- [7] & [8]  "pip freeze" vs "pip list --format=freeze"

[1] https://www.softwarefactory-project.io/zuul-hands-on-part-6-cross-project-dependencies.html
[2] https://www.python.org/dev/peps/pep-0440/#direct-references
[3] 6f689f61db
[4] 196706d305
[5] https://www.python.org/dev/peps/pep-0508/
[6] https://www.python.org/dev/peps/pep-0610/
[7] https://github.com/pypa/pip/issues/8174
[8] https://github.com/pypa/pip/issues/8176

Change-Id: Id038149201829862f9944dfd8d7ceeafac670f3d
This commit is contained in:
Guillaume Chauvel 2020-05-12 23:39:48 +02:00
parent b8a24d635f
commit e0266ff7ee

View File

@ -115,9 +115,15 @@ def get_installed_packages(tox_python):
# Matches strings of the form:
# 1. '<package_name>==<version>'
# 2. '# Editable Git install with no remote (<package_name>==<version>)'
# both results: <package_name>
return [x[x.find('(') + 1:].split('==')[0]
for x in frozen_pkgs.split('\n') if '==' in x]
# 3. '<package_name> @ <URI_reference>' # PEP440, PEP508, PEP610
# results <package_name>
installed_packages = []
for x in frozen_pkgs.split('\n'):
if '==' in x:
installed_packages.append(x[x.find('(') + 1:].split('==')[0])
elif '@' in x:
installed_packages.append(x.split('@')[0].rstrip(' \t'))
return installed_packages
def write_new_constraints_file(constraints, packages):