You may need to copy some additional files there, e.g.:
export PYBUILD_BEFORE_TEST=cp -r {dir}/foo {dir}/bar {build_dir}
export PYBUILD_AFTER_TEST=rm -rf {build_dir}/foo {build_dir}/bar
(Please CC as I'm not subscribed to debian-devel)
I am maintaining the package src:kiwi [1] which hasn't been updated in
Debian for some time since upstream has added tests that only work when
the package source is installed into the test environment, i.e. available through PYTHONPATH.
I have tried to adjust the environment variables in debian/rules as follows and tried to invoke the testsuite from the test/unit subdirectory:
export PYTHONPATH = $(CURDIR)
export PYBUILD_TEST_ARGS_python3 = cd {build_dir}; python{version} -m discoverYou should use python* -m pytest (note that you need to run it for all supported Python versions.
override_dh_auto_test:
ifeq ($(filter nocheck nobench, $(DEB_BUILD_OPTIONS)),)
/bin/sh -c "cd test/unit && pytest-3"
[1] https://salsa.debian.org/debian/kiwi
On Thu, Oct 24, 2024 at 12:44:45PM +0200, John Paul Adrian Glaubitz wrote:
(Please CC as I'm not subscribed to debian-devel)
(this is how I realized this is not debian-python@, consider using that
for more relevant coverage)
I am maintaining the package src:kiwi [1] which hasn't been updated in Debian for some time since upstream has added tests that only work when
the package source is installed into the test environment, i.e. available through PYTHONPATH.
I believe any or at least most Python unittests require the module being tested to be available in sys.path and pybuild already helps with that, by running tests in a directory with the package installed, is that not
enough? What are the specific problems you have?
I have tried to adjust the environment variables in debian/rules as follows and tried to invoke the testsuite from the test/unit subdirectory:
export PYTHONPATH = $(CURDIR)
$(CURDIR) is already in sys.path when running python -m.
export PYBUILD_TEST_ARGS_python3 = cd {build_dir}; python{version} -m discover
override_dh_auto_test:You should use python* -m pytest (note that you need to run it for all supported Python versions.
ifeq ($(filter nocheck nobench, $(DEB_BUILD_OPTIONS)),)
/bin/sh -c "cd test/unit && pytest-3"
I had to look it up and the mechanism used is calledI ran into this issue with old-style setuptools packages (i.e.,
"entry_points". The kiwi package adds such entry_points and wants
to test them in its testsuite.
Thus, I need to figure out how to make those entry_points visible
from the build environment so that the testsuite can find and test
them.
Is there any other Debian Python package that uses entry points?
I am maintaining the package src:kiwi [1] which hasn't been updated in
Debian for some time since upstream has added tests that only work when
the package source is installed into the test environment, i.e. available through PYTHONPATH.
If it actually needs the .dist-info to be on path (fully installed), you
can try runnig the tests under tox. That's probably what the upstream
does.
tox tests in Debian package builds are a little different because we use --system-site-packages virtualenvs, but they can be a good way to deal
with this.
I ran into this issue with old-style setuptools packages (i.e.,
packages with a setup.py); AFAIK the entry_points mechanism needs
valid egg-info or dist-info metadata in the PYTHONPATH. My
workaround was
export PYBUILD_BEFORE_TEST=\
{interpreter} setup.py egg_info; \
cp -r {dir}/src/*.egg-info {build_dir}
export PYBUILD_AFTER_TEST=\
rm -r {dir}/src/*.egg-info {build_dir}/*.egg-info
On Fri, 2024-10-25 at 22:19 +0200, Timo Röhling wrote:
I ran into this issue with old-style setuptools packages (i.e.,
packages with a setup.py); AFAIK the entry_points mechanism needs
valid egg-info or dist-info metadata in the PYTHONPATH. My
workaround was
export PYBUILD_BEFORE_TEST=\
{interpreter} setup.py egg_info; \
cp -r {dir}/src/*.egg-info {build_dir}
export PYBUILD_AFTER_TEST=\
rm -r {dir}/src/*.egg-info {build_dir}/*.egg-info
Thanks, this is what I was looking for. I will give this a try.
I just realized that this doesn't work because kiwi doesn't have a setup.py anymore but just uses pyproject.toml. Do you know how it works in this case?
tox tests in Debian package builds are a little different because we use --system-site-packages virtualenvs, but they can be a good way to deal
with this.
Can you name any package using this mechanism so I can have a look?
I'm not really experienced with tox, so it would be great to have some guidance in the form of sample code.
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 428 |
Nodes: | 16 (2 / 14) |
Uptime: | 110:36:15 |
Calls: | 9,053 |
Files: | 13,395 |
Messages: | 6,016,034 |