Hello Pythonistas,
while working on a change that requires adding a new Shell environment variable to both %pytest and %tox, I figured out we might benefit from defining such variables at one place.
Maxwell suggested that this place should be exposed to packagers, so they could use it with other test runners.
In https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/149 we propose to use it like this:
%check %{python3_test_envvars} %{python3} -m unittest
Or:
%check %{python3_test_envvars} stestr run
The macro would currently be defined as:
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" \ PATH="%{buildroot}%{_bindir}:$PATH" \
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \ PYTHONDONTWRITEBYTECODE=1 \ %{?__pytest_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"} PYTEST_XDIST_AUTO_NUM_WORKERS=%{_smp_build_ncpus}
Some of the variables are pytest-specific, but some are useful with other test runners as well.
I am writing this email to raise awareness and get some feedback, if needed.
As always, the most important question is the bikeshed color^W^W macro name.
On 26. 10. 22 14:48, Miro Hrončok wrote:
Hello Pythonistas,
while working on a change that requires adding a new Shell environment variable to both %pytest and %tox, I figured out we might benefit from defining such variables at one place.
Maxwell suggested that this place should be exposed to packagers, so they could use it with other test runners.
In https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/149 we propose to use it like this:
%check %{python3_test_envvars} %{python3} -m unittest
Or:
%check %{python3_test_envvars} stestr run
The macro would currently be defined as:
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" \ PATH="%{buildroot}%{_bindir}:$PATH" \
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \ PYTHONDONTWRITEBYTECODE=1 \ %{?__pytest_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"} PYTEST_XDIST_AUTO_NUM_WORKERS=%{_smp_build_ncpus}
Some of the variables are pytest-specific, but some are useful with other test runners as well.
I am writing this email to raise awareness and get some feedback, if needed.
As always, the most important question is the bikeshed color^W^W macro name.
This has landed in rawhide as %py3_test_envvars. Will let it there for a while before backporting it or documenting it in the guidelines.
See [1] and [2] for the name reasoning.
[1] https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/149#commen... [2] https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/149#commen...
python-devel@lists.fedoraproject.org