Tox dependency generator: Handle deps read in from a text file
Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1808601 tox docs: https://tox.readthedocs.io/en/latest/example/basic.html#depending-on-requirements-txt-or-defining-constraints Relevant tox-current-env issue: https://github.com/fedora-python/tox-current-env/issues/22
This commit is contained in:
parent
9bb7de7385
commit
99d952cd6c
@ -6,7 +6,7 @@ License: MIT
|
|||||||
|
|
||||||
# Keep the version at zero and increment only release
|
# Keep the version at zero and increment only release
|
||||||
Version: 0
|
Version: 0
|
||||||
Release: 12%{?dist}
|
Release: 13%{?dist}
|
||||||
|
|
||||||
Source0: macros.pyproject
|
Source0: macros.pyproject
|
||||||
Source1: pyproject_buildrequires.py
|
Source1: pyproject_buildrequires.py
|
||||||
@ -87,6 +87,9 @@ install -m 644 pyproject_buildrequires.py %{buildroot}%{_rpmconfigdir}/redhat/
|
|||||||
%license LICENSE
|
%license LICENSE
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Mar 02 2020 Miro Hrončok <mhroncok@redhat.com> - 0-13
|
||||||
|
- Tox dependency generator: Handle deps read in from a text file (#1808601)
|
||||||
|
|
||||||
* Wed Feb 05 2020 Miro Hrončok <mhroncok@redhat.com> - 0-12
|
* Wed Feb 05 2020 Miro Hrončok <mhroncok@redhat.com> - 0-12
|
||||||
- Fallback to setuptools.build_meta:__legacy__ backend instead of setuptools.build_meta
|
- Fallback to setuptools.build_meta:__legacy__ backend instead of setuptools.build_meta
|
||||||
- Properly handle backends with colon
|
- Properly handle backends with colon
|
||||||
|
@ -189,6 +189,24 @@ def generate_run_requirements(backend, requirements):
|
|||||||
requirements.extend(requires, source=f'wheel metadata: {key}')
|
requirements.extend(requires, source=f'wheel metadata: {key}')
|
||||||
|
|
||||||
|
|
||||||
|
def parse_tox_requires_lines(lines):
|
||||||
|
packages = []
|
||||||
|
for line in lines:
|
||||||
|
line = line.strip()
|
||||||
|
if line.startswith('-r'):
|
||||||
|
path = line[2:]
|
||||||
|
with open(path) as f:
|
||||||
|
packages.extend(parse_tox_requires_lines(f.read().splitlines()))
|
||||||
|
elif line.startswith('-'):
|
||||||
|
print_err(
|
||||||
|
f'WARNING: Skipping dependency line: {line}\n'
|
||||||
|
+ f' tox deps options other than -r are not supported (yet).',
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
packages.append(line)
|
||||||
|
return packages
|
||||||
|
|
||||||
|
|
||||||
def generate_tox_requirements(toxenv, requirements):
|
def generate_tox_requirements(toxenv, requirements):
|
||||||
requirements.add('tox-current-env >= 0.0.2', source='tox itself')
|
requirements.add('tox-current-env >= 0.0.2', source='tox itself')
|
||||||
requirements.check(source='tox itself')
|
requirements.check(source='tox itself')
|
||||||
@ -203,7 +221,10 @@ def generate_tox_requirements(toxenv, requirements):
|
|||||||
if r.stdout:
|
if r.stdout:
|
||||||
print_err(r.stdout, end='')
|
print_err(r.stdout, end='')
|
||||||
r.check_returncode()
|
r.check_returncode()
|
||||||
requirements.extend(depfile.read().splitlines(),
|
|
||||||
|
deplines = depfile.read().splitlines()
|
||||||
|
packages = parse_tox_requires_lines(deplines)
|
||||||
|
requirements.extend(packages,
|
||||||
source=f'tox --print-deps-only: {toxenv}')
|
source=f'tox --print-deps-only: {toxenv}')
|
||||||
|
|
||||||
|
|
||||||
|
48
tests/python-openqa_client.spec
Normal file
48
tests/python-openqa_client.spec
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
%global pypi_name openqa_client
|
||||||
|
Name: python-%{pypi_name}
|
||||||
|
Version: 4.0.0
|
||||||
|
Release: 1%{?dist}
|
||||||
|
Summary: Python client library for openQA API
|
||||||
|
|
||||||
|
License: GPLv2+
|
||||||
|
URL: https://github.com/os-autoinst/openQA-python-client
|
||||||
|
Source0: %{pypi_source}
|
||||||
|
|
||||||
|
BuildArch: noarch
|
||||||
|
BuildRequires: pyproject-rpm-macros
|
||||||
|
|
||||||
|
%description
|
||||||
|
This package uses tox.ini file with recursive deps (via the -r option).
|
||||||
|
|
||||||
|
%package -n python3-%{pypi_name}
|
||||||
|
Summary: %{summary}
|
||||||
|
%{?python_provide:%python_provide python3-%{pypi_name}}
|
||||||
|
|
||||||
|
%description -n python3-%{pypi_name}
|
||||||
|
%{summary}.
|
||||||
|
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%autosetup -p1 -n %{pypi_name}-%{version}
|
||||||
|
# setuptools-git is needed to build the source distribution, but not
|
||||||
|
# for packaging, which *starts* from the source distribution
|
||||||
|
sed -i -e 's., "setuptools-git"..g' pyproject.toml
|
||||||
|
|
||||||
|
%generate_buildrequires
|
||||||
|
%pyproject_buildrequires -t
|
||||||
|
|
||||||
|
%build
|
||||||
|
%pyproject_wheel
|
||||||
|
|
||||||
|
%install
|
||||||
|
%pyproject_install
|
||||||
|
|
||||||
|
%check
|
||||||
|
%tox
|
||||||
|
|
||||||
|
|
||||||
|
%files -n python3-%{pypi_name}
|
||||||
|
%doc README.*
|
||||||
|
%license COPYING
|
||||||
|
%{python3_sitelib}/%{pypi_name}/
|
||||||
|
%{python3_sitelib}/%{pypi_name}-%{version}.dist-info/
|
@ -28,6 +28,9 @@
|
|||||||
- tldr:
|
- tldr:
|
||||||
dir: .
|
dir: .
|
||||||
run: ./mocktest.sh tldr
|
run: ./mocktest.sh tldr
|
||||||
|
- openqa_client:
|
||||||
|
dir: .
|
||||||
|
run: ./mocktest.sh python-openqa_client
|
||||||
required_packages:
|
required_packages:
|
||||||
- mock
|
- mock
|
||||||
- rpmdevtools
|
- rpmdevtools
|
||||||
|
Loading…
Reference in New Issue
Block a user