Set HOSTNAME to prevent tox 3.17+ from a DNS query

Tox calls socket.getfqdn() and that call does a DNS query.
In mock with disabled networking, it takes a minute until that times out.
When a spec file uses %pyproject_buildrequires -t and %tox, it is a 3 minute delay.

Since 3.17, tox does not call socket.getfqdn() when HOSTNAME variable is set to a value:

https://github.com/tox-dev/tox/pull/1616

The value is only used in result log, so setting it to "rpmbuild"
actually makes the logs more reproducible as well.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1856356
when tox is used in %pyproject_buildrequires -t or %tox.
This commit is contained in:
Miro Hrončok 2020-07-15 12:15:19 +02:00
parent a723865460
commit 37216e779e
2 changed files with 8 additions and 2 deletions

View File

@ -61,7 +61,7 @@ echo 'python3dist(toml)'
# setuptools assumes no pre-existing dist-info # setuptools assumes no pre-existing dist-info
rm -rfv *.dist-info/ >&2 rm -rfv *.dist-info/ >&2
if [ -f %{__python3} ]; then if [ -f %{__python3} ]; then
RPM_TOXENV="%{toxenv}" %{__python3} -I %{_rpmconfigdir}/redhat/pyproject_buildrequires.py %{?**} RPM_TOXENV="%{toxenv}" HOSTNAME="rpmbuild" %{__python3} -I %{_rpmconfigdir}/redhat/pyproject_buildrequires.py %{?**}
fi fi
} }
@ -70,5 +70,6 @@ fi
TOX_TESTENV_PASSENV="${TOX_TESTENV_PASSENV:-*}" \\ TOX_TESTENV_PASSENV="${TOX_TESTENV_PASSENV:-*}" \\
PATH="%{buildroot}%{_bindir}:$PATH" \\ PATH="%{buildroot}%{_bindir}:$PATH" \\
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \\ PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \\
HOSTNAME="rpmbuild" \\
tox --current-env -q --recreate -e "%{-e:%{-e*}}%{!-e:%{toxenv}}" %{?*} tox --current-env -q --recreate -e "%{-e:%{-e*}}%{!-e:%{toxenv}}" %{?*}
} }

View File

@ -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: 16%{?dist} Release: 17%{?dist}
# Macro files # Macro files
Source001: macros.pyproject Source001: macros.pyproject
@ -87,6 +87,7 @@ install -m 644 pyproject_save_files.py %{buildroot}%{_rpmconfigdir}/redhat/
%if %{with tests} %if %{with tests}
%check %check
export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856356
%{python3} -m pytest -vv --doctest-modules %{python3} -m pytest -vv --doctest-modules
%endif %endif
@ -100,6 +101,10 @@ install -m 644 pyproject_save_files.py %{buildroot}%{_rpmconfigdir}/redhat/
%license LICENSE %license LICENSE
%changelog %changelog
* Wed Jul 15 2020 Miro Hrončok <mhroncok@redhat.com> - 0-17
- Set HOSTNAME to prevent tox 3.17+ from a DNS query
- Fixes rhbz#1856356
* Fri Jun 19 2020 Miro Hrončok <mhroncok@redhat.com> - 0-16 * Fri Jun 19 2020 Miro Hrončok <mhroncok@redhat.com> - 0-16
- Switch from upstream deprecated pytoml to toml - Switch from upstream deprecated pytoml to toml