diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index c3f65fd..a0cbcdb 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -6,7 +6,7 @@ License: MIT # Keep the version at zero and increment only release Version: 0 -Release: 12%{?dist} +Release: 13%{?dist} Source0: macros.pyproject Source1: pyproject_buildrequires.py @@ -87,6 +87,9 @@ install -m 644 pyproject_buildrequires.py %{buildroot}%{_rpmconfigdir}/redhat/ %license LICENSE %changelog +* Mon Mar 02 2020 Miro Hrončok - 0-13 +- Tox dependency generator: Handle deps read in from a text file (#1808601) + * Wed Feb 05 2020 Miro Hrončok - 0-12 - Fallback to setuptools.build_meta:__legacy__ backend instead of setuptools.build_meta - Properly handle backends with colon diff --git a/pyproject_buildrequires.py b/pyproject_buildrequires.py index aa87481..9be8b36 100644 --- a/pyproject_buildrequires.py +++ b/pyproject_buildrequires.py @@ -189,6 +189,24 @@ def generate_run_requirements(backend, requirements): 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): requirements.add('tox-current-env >= 0.0.2', source='tox itself') requirements.check(source='tox itself') @@ -203,7 +221,10 @@ def generate_tox_requirements(toxenv, requirements): if r.stdout: print_err(r.stdout, end='') 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}') diff --git a/tests/python-openqa_client.spec b/tests/python-openqa_client.spec new file mode 100644 index 0000000..b6e7cc2 --- /dev/null +++ b/tests/python-openqa_client.spec @@ -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/ diff --git a/tests/tests.yml b/tests/tests.yml index 1ea7549..ac51c24 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -28,6 +28,9 @@ - tldr: dir: . run: ./mocktest.sh tldr + - openqa_client: + dir: . + run: ./mocktest.sh python-openqa_client required_packages: - mock - rpmdevtools