Allow multiple, comma-separated extras in %pyproject_buildrequires -x
This commit is contained in:
parent
59bc07b713
commit
6a8d86ed70
@ -51,6 +51,7 @@ this can be done using the `-r` flag:
|
||||
For projects that specify test requirements using an [`extra`
|
||||
provide](https://packaging.python.org/specifications/core-metadata/#provides-extra-multiple-use),
|
||||
these can be added using the `-x` flag.
|
||||
Multiple extras can be supplied as a comma separated list.
|
||||
For example, if upstream suggests installing test dependencies with
|
||||
`pip install mypackage[testing]`, the test deps would be generated by:
|
||||
|
||||
@ -188,12 +189,8 @@ because in tests we usually rely on `PYTHONPATH` (and `-s` ignores that).
|
||||
Would this behavior be undesired for any reason,
|
||||
undefine `%{py3_shbang_opt}` to turn it off.
|
||||
|
||||
Extras are currently ignored.
|
||||
|
||||
Some valid Python version specifiers are not supported.
|
||||
|
||||
The `-x` flag does not yet support multiple (comma-separated) extras.
|
||||
|
||||
[PEP 517]: https://www.python.org/dev/peps/pep-0517/
|
||||
[PEP 518]: https://www.python.org/dev/peps/pep-0518/
|
||||
|
||||
|
@ -6,7 +6,7 @@ License: MIT
|
||||
|
||||
# Keep the version at zero and increment only release
|
||||
Version: 0
|
||||
Release: 23%{?dist}
|
||||
Release: 24%{?dist}
|
||||
|
||||
# Macro files
|
||||
Source001: macros.pyproject
|
||||
@ -88,6 +88,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
|
||||
%license LICENSE
|
||||
|
||||
%changelog
|
||||
* Tue Aug 11 2020 Miro Hrončok <mhroncok@redhat.com> - 0-24
|
||||
- Allow multiple, comma-separated extras in %%pyproject_buildrequires -x
|
||||
|
||||
* Mon Aug 10 2020 Lumír Balhar <lbalhar@redhat.com> - 0-23
|
||||
- Make macros more universal for alternative Python stacks
|
||||
|
||||
|
@ -51,12 +51,21 @@ class Requirements:
|
||||
python3_pkgversion='3'):
|
||||
self.get_installed_version = get_installed_version
|
||||
|
||||
self.marker_env = {'extra': extras}
|
||||
if extras:
|
||||
self.marker_envs = [{'extra': e.strip()} for e in extras.split(',')]
|
||||
else:
|
||||
self.marker_envs = [{'extra': ''}]
|
||||
|
||||
self.missing_requirements = False
|
||||
|
||||
self.python3_pkgversion = python3_pkgversion
|
||||
|
||||
def evaluate_all_environamnets(self, requirement):
|
||||
for marker_env in self.marker_envs:
|
||||
if requirement.marker.evaluate(environment=marker_env):
|
||||
return True
|
||||
return False
|
||||
|
||||
def add(self, requirement_str, *, source=None):
|
||||
"""Output a Python-style requirement string as RPM dep"""
|
||||
print_err(f'Handling {requirement_str} from {source}')
|
||||
@ -72,7 +81,7 @@ class Requirements:
|
||||
|
||||
name = canonicalize_name(requirement.name)
|
||||
if (requirement.marker is not None and
|
||||
not requirement.marker.evaluate(environment=self.marker_env)):
|
||||
not self.evaluate_all_environamnets(requirement)):
|
||||
print_err(f'Ignoring alien requirement:', requirement_str)
|
||||
return
|
||||
|
||||
@ -293,11 +302,8 @@ def main(argv):
|
||||
)
|
||||
parser.add_argument(
|
||||
'-x', '--extras', metavar='EXTRAS', default='',
|
||||
help='extra for runtime requirements (e.g. -x testing) '
|
||||
'(implies --runtime)',
|
||||
# XXX: a comma-separated list should be possible here
|
||||
# help='comma separated list of "extras" for runtime requirements '
|
||||
# + '(e.g. -x testing,feature-x)',
|
||||
help='comma separated list of "extras" for runtime requirements '
|
||||
'(e.g. -x testing,feature-x) (implies --runtime)',
|
||||
)
|
||||
parser.add_argument(
|
||||
'-p', '--python3_pkgversion', metavar='PYTHON3_PKGVERSION',
|
||||
|
@ -226,7 +226,6 @@ Run dependencies with extras (selected):
|
||||
result: 0
|
||||
|
||||
Run dependencies with multiple extras:
|
||||
xfail: requirement.marker.evaluate seems to not support multiple extras
|
||||
installed:
|
||||
setuptools: 50
|
||||
wheel: 1
|
||||
@ -246,10 +245,11 @@ Run dependencies with multiple extras:
|
||||
expected: |
|
||||
python3dist(setuptools) >= 40.8
|
||||
python3dist(wheel)
|
||||
python3dist(dep1)
|
||||
python3dist(dep2)
|
||||
python3dist(dep3)
|
||||
python3dist(wheel)
|
||||
python3dist(dep4)
|
||||
python3dist(dep3)
|
||||
python3dist(dep2)
|
||||
python3dist(dep1)
|
||||
result: 0
|
||||
|
||||
Tox dependencies:
|
||||
|
54
tests/python-requests.spec
Normal file
54
tests/python-requests.spec
Normal file
@ -0,0 +1,54 @@
|
||||
Name: python-requests
|
||||
Version: 2.24.0
|
||||
Release: 0%{?dist}
|
||||
Summary: Requests is an elegant and simple HTTP library for Python
|
||||
|
||||
License: ASL 2.0
|
||||
URL: https://requests.readthedocs.io/
|
||||
Source0: %{pypi_source requests}
|
||||
BuildArch: noarch
|
||||
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: pyproject-rpm-macros
|
||||
|
||||
%description
|
||||
This package uses multiple extras in %%pyproject_extras_subpkg and in
|
||||
%%pyproject_buildrequires.
|
||||
|
||||
|
||||
%package -n python3-requests
|
||||
Summary: %{summary}
|
||||
|
||||
%description -n python3-requests
|
||||
%{summary}.
|
||||
|
||||
|
||||
%pyproject_extras_subpkg -n python3-requests security socks
|
||||
|
||||
|
||||
%prep
|
||||
%autosetup -n requests-%{version}
|
||||
|
||||
|
||||
%generate_buildrequires
|
||||
%pyproject_buildrequires -x security,socks
|
||||
|
||||
|
||||
%build
|
||||
%pyproject_wheel
|
||||
|
||||
|
||||
%install
|
||||
%pyproject_install
|
||||
%pyproject_save_files requests
|
||||
|
||||
|
||||
%check
|
||||
# Internal check for our macros
|
||||
# making sure that %%pyproject_buildrequires pulled in deps for both extras
|
||||
%{python3} -c 'import cryptography, socks'
|
||||
|
||||
|
||||
%files -n python3-requests -f %{pyproject_files}
|
||||
%doc README.*
|
||||
%license LICENSE
|
@ -43,6 +43,9 @@
|
||||
- setuptools_scm:
|
||||
dir: .
|
||||
run: ./mocktest.sh python-setuptools_scm
|
||||
- requests:
|
||||
dir: .
|
||||
run: ./mocktest.sh python-requests
|
||||
- ipykernel:
|
||||
dir: .
|
||||
run: ./mocktest.sh python-ipykernel
|
||||
|
Loading…
Reference in New Issue
Block a user