Ignore environment markers in pythonbundles.py

Use packaging.requirements instead of a naïve split on ==.
This commit is contained in:
Miro Hrončok 2023-03-07 17:35:06 +01:00
parent 279638a969
commit 079b71a567
5 changed files with 14 additions and 2 deletions

View File

@ -49,6 +49,7 @@ install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} *.py
%changelog %changelog
* Tue Mar 07 2023 Miro Hrončok <mhroncok@redhat.com> - 14-3 * Tue Mar 07 2023 Miro Hrončok <mhroncok@redhat.com> - 14-3
- Avoid needless pkg_resources import in pythonbundles.py - Avoid needless pkg_resources import in pythonbundles.py
- Ignore environment markers in pythonbundles.py
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 14-2 * Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 14-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

View File

@ -15,6 +15,8 @@
import pathlib import pathlib
import sys import sys
from packaging import requirements
import pythondistdeps import pythondistdeps
def generate_bundled_provides(paths, namespace): def generate_bundled_provides(paths, namespace):
@ -33,8 +35,14 @@ def generate_bundled_provides(paths, namespace):
continue continue
line = line.strip() line = line.strip()
if line: if line:
name, _, version = line.partition('==') requirement = requirements.Requirement(line)
name = pythondistdeps.normalize_name(name) for spec in requirement.specifier:
if spec.operator == '==':
version = spec.version
break
else:
raise ValueError('pythonbundles.py only handles exactly one == requirement')
name = pythondistdeps.normalize_name(requirement.name)
bundled_name = f"bundled({namespace}({name}))" bundled_name = f"bundled({namespace}({name}))"
python_provide = pythondistdeps.convert(bundled_name, '==', version) python_provide = pythondistdeps.convert(bundled_name, '==', version)
provides.add(f'Provides: {python_provide}') provides.add(f'Provides: {python_provide}')

View File

@ -3,3 +3,4 @@ Provides: bundled(python3dist(ordered-set)) = 3.1.1
Provides: bundled(python3dist(packaging)) = 16.8 Provides: bundled(python3dist(packaging)) = 16.8
Provides: bundled(python3dist(pyparsing)) = 2.2.1 Provides: bundled(python3dist(pyparsing)) = 2.2.1
Provides: bundled(python3dist(six)) = 1.10 Provides: bundled(python3dist(six)) = 1.10
Provides: bundled(python3dist(tomli)) = 1.2.3

View File

@ -1,3 +1,4 @@
packaging==16.8 packaging==16.8
pyparsing==2.2.1 pyparsing==2.2.1
ordered-set==3.1.1 ordered-set==3.1.1
tomli==1.2.3;python_version<"3.11"

View File

@ -1,3 +1,4 @@
Provides: bundled(python3dist(ordered-set)) = 3.1.1 Provides: bundled(python3dist(ordered-set)) = 3.1.1
Provides: bundled(python3dist(packaging)) = 16.8 Provides: bundled(python3dist(packaging)) = 16.8
Provides: bundled(python3dist(pyparsing)) = 2.2.1 Provides: bundled(python3dist(pyparsing)) = 2.2.1
Provides: bundled(python3dist(tomli)) = 1.2.3