From 37216e779e03110c562c480fe0b0b24ff8a025a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 15 Jul 2020 12:15:19 +0200 Subject: [PATCH] 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. --- macros.pyproject | 3 ++- pyproject-rpm-macros.spec | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/macros.pyproject b/macros.pyproject index d615c22..bab2c4c 100644 --- a/macros.pyproject +++ b/macros.pyproject @@ -61,7 +61,7 @@ echo 'python3dist(toml)' # setuptools assumes no pre-existing dist-info rm -rfv *.dist-info/ >&2 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 } @@ -70,5 +70,6 @@ fi TOX_TESTENV_PASSENV="${TOX_TESTENV_PASSENV:-*}" \\ PATH="%{buildroot}%{_bindir}:$PATH" \\ PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \\ +HOSTNAME="rpmbuild" \\ tox --current-env -q --recreate -e "%{-e:%{-e*}}%{!-e:%{toxenv}}" %{?*} } diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index 3fdd306..fe8f52d 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: 16%{?dist} +Release: 17%{?dist} # Macro files Source001: macros.pyproject @@ -87,6 +87,7 @@ install -m 644 pyproject_save_files.py %{buildroot}%{_rpmconfigdir}/redhat/ %if %{with tests} %check +export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856356 %{python3} -m pytest -vv --doctest-modules %endif @@ -100,6 +101,10 @@ install -m 644 pyproject_save_files.py %{buildroot}%{_rpmconfigdir}/redhat/ %license LICENSE %changelog +* Wed Jul 15 2020 Miro Hrončok - 0-17 +- Set HOSTNAME to prevent tox 3.17+ from a DNS query +- Fixes rhbz#1856356 + * Fri Jun 19 2020 Miro Hrončok - 0-16 - Switch from upstream deprecated pytoml to toml