From e0266ff7ee87f9d1351f6be62a0c4de8ddacc1d1 Mon Sep 17 00:00:00 2001 From: Guillaume Chauvel Date: Tue, 12 May 2020 23:39:48 +0200 Subject: [PATCH] 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] https://github.com/pypa/pip/commit/6f689f61db2c5247656d8ecede022cf95477ead3 [4] https://github.com/pypa/pip/commit/196706d305c1e7cb296824c90d932918036f53e2 [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 --- roles/tox/library/tox_install_sibling_packages.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/roles/tox/library/tox_install_sibling_packages.py b/roles/tox/library/tox_install_sibling_packages.py index 915186c1b..75a82eda7 100644 --- a/roles/tox/library/tox_install_sibling_packages.py +++ b/roles/tox/library/tox_install_sibling_packages.py @@ -115,9 +115,15 @@ def get_installed_packages(tox_python): # Matches strings of the form: # 1. '==' # 2. '# Editable Git install with no remote (==)' - # both results: - return [x[x.find('(') + 1:].split('==')[0] - for x in frozen_pkgs.split('\n') if '==' in x] + # 3. ' @ ' # PEP440, PEP508, PEP610 + # results + 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):