Fix handling of self-referencing extras when reading pyproject.toml
Keep the information about the requirement extras by storing the Requirement instances in the list of the ignored requirements, rather than the strings in the form they were initially read from metadata. The requirements strings read from pyproject.toml don't contain the extra information, we insert the extra marker only after converting them to Requirement instances. When stored as the text, the information about the extra went missing in the course of the script.
This commit is contained in:
parent
c7553b2c7d
commit
bc6cb55227
@ -14,7 +14,7 @@ License: MIT
|
||||
# Increment Y and reset Z when new macros or features are added
|
||||
# Increment Z when this is a bugfix or a cosmetic change
|
||||
# Dropping support for EOL Fedoras is *not* considered a breaking change
|
||||
Version: 1.15.0
|
||||
Version: 1.15.1
|
||||
Release: 1%{?dist}
|
||||
|
||||
# Macro files
|
||||
@ -173,6 +173,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
|
||||
|
||||
|
||||
%changelog
|
||||
* Thu Oct 03 2024 Karolina Surma <ksurma@redhat.com> - 1.15.1-1
|
||||
- Fix handling of self-referencing extras when reading pyproject.toml
|
||||
|
||||
* Tue Sep 17 2024 Python Maint <python-maint@redhat.com> - 1.15.0-1
|
||||
- Add a possibility to read runtime requirements from pyproject.toml [project] table
|
||||
- Fixes: rhbz#2261939
|
||||
|
@ -101,18 +101,23 @@ class Requirements:
|
||||
return True
|
||||
return False
|
||||
|
||||
def add(self, requirement_str, *, package_name=None, source=None, extra=None):
|
||||
def add(self, requirement, *, package_name=None, source=None, extra=None):
|
||||
"""Output a Python-style requirement string as RPM dep"""
|
||||
|
||||
requirement_str = str(requirement)
|
||||
print_err(f'Handling {requirement_str} from {source}')
|
||||
|
||||
try:
|
||||
requirement = Requirement(requirement_str)
|
||||
except InvalidRequirement:
|
||||
hint = guess_reason_for_invalid_requirement(requirement_str)
|
||||
message = f'Requirement {requirement_str!r} from {source} is invalid.'
|
||||
if hint:
|
||||
message += f' Hint: {hint}'
|
||||
raise ValueError(message)
|
||||
# requirements read initially from the metadata are strings
|
||||
# further on we work with them as Requirement instances
|
||||
if not isinstance(requirement, Requirement):
|
||||
try:
|
||||
requirement = Requirement(requirement)
|
||||
except InvalidRequirement:
|
||||
hint = guess_reason_for_invalid_requirement(requirement)
|
||||
message = f'Requirement {requirement!r} from {source} is invalid.'
|
||||
if hint:
|
||||
message += f' Hint: {hint}'
|
||||
raise ValueError(message)
|
||||
|
||||
if requirement.url:
|
||||
print_err(
|
||||
@ -130,7 +135,7 @@ class Requirements:
|
||||
if (requirement.marker is not None and
|
||||
not self.evaluate_all_environments(requirement)):
|
||||
print_err(f'Ignoring alien requirement:', requirement_str)
|
||||
self.ignored_alien_requirements.append(requirement_str)
|
||||
self.ignored_alien_requirements.append(requirement)
|
||||
return
|
||||
|
||||
# Handle self-referencing requirements
|
||||
|
@ -1246,3 +1246,35 @@ pyproject.toml with dynamic table and no deps:
|
||||
python3dist(setuptools)
|
||||
python3dist(wheel)
|
||||
result: 0
|
||||
|
||||
pyproject.toml with self-referencing extras:
|
||||
skipif: not SETUPTOOLS_60
|
||||
read_pyproject_dependencies: true
|
||||
installed:
|
||||
setuptools: 50
|
||||
wheel: 1
|
||||
tomli: 1
|
||||
extras:
|
||||
- test
|
||||
pyproject.toml: |
|
||||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
[project]
|
||||
name = "contourpy"
|
||||
version = "0.1"
|
||||
dependencies = ["numpy >= 1.23"]
|
||||
[project.optional-dependencies]
|
||||
bokeh = ["bokeh", "selenium"]
|
||||
test = ["contourpy[test-no-images]", "matplotlib", "Pillow"]
|
||||
test-no-images = ["pytest", "pytest-rerunfailures", "wurlitzer"]
|
||||
expected: |
|
||||
python3dist(setuptools)
|
||||
python3dist(wheel)
|
||||
python3dist(numpy) >= 1.23
|
||||
python3dist(matplotlib)
|
||||
python3dist(pillow)
|
||||
python3dist(pytest)
|
||||
python3dist(pytest-rerunfailures)
|
||||
python3dist(wurlitzer)
|
||||
result: 0
|
||||
|
Loading…
Reference in New Issue
Block a user