#1013700 python-qtpy: FTBFS: pytest7 regression, TypeError: the 'package' argument is required to perform a relative import #1013700
- Package:
- src:python-qtpy
- Source:
- python-qtpy
- Submitter:
- Louis-Philippe Véronneau
- Date:
- 2022-07-05 07:51:06 UTC
- Severity:
- serious
- Tags:
Hi, During a selected rebuild of python packages in sid, your package failed to build with pytest version 7.1.2-1. The full build log is available from: http://qa-logs.debian.net/2022/06/09/pytest/python-qtpy_2.1.0-2_unstable_pytest-exp.log I had a closer look at the error log and identified the regression as: 'TypeError: the 'package' argument is required to perform a relative import'. Hopefully, that's helpful! All bugs filed during this rebuild are listed at: https://bugs.debian.org/cgi-bin/pkgreport.cgi?tag=pytest7;users=debian-python@lists.debian.org or: https://udd.debian.org/bugs/?release=na&merged=ign&fnewerval=7&flastmodval=7&fusertag=only&fusertagtag=pytest7&fusertaguser=debian-python@lists.debian.org&allbugs=1&cseverity=1&ctags=1&caffected=1#results If you reassign this bug to another package, please mark it as 'affects'-ing this package. See https://www.debian.org/Bugs/server-control#affects If you fail to reproduce this, please provide a build log and diff it with the one provided so that we can identify if something relevant changed in the meantime.
Dear all, I wonder whether you might have any clue about https://bugs.debian.org/1013700 I have mostly worked out the "cause" of the bug, but I haven't quite got to the bottom of it. When running the command PYTHONPATH=. python3.10 -m pytest qtpy/tests in the directory .pybuild/cpython3_3.10_qtpy/build, I get the error message: ImportError while loading conftest '/home/jdg/debian/spyder-packages/qtpy/build-area/python-qtpy-2.1.0/.pybuild/cpython3_3.10_qtpy/build/qtpy/tests/conftest.py'. TypeError: the 'package' argument is required to perform a relative import for '.pybuild.cpython3_3.10_qtpy.build.qtpy.tests' If the directory .pybuild is renamed to pybuild, the tests run without a problem. So there seems to be something funny about conftest.py (and removing all of the other files from the qtpy/tests directory except for the empty __init__.py gives the same error); here's a link to it: https://salsa.debian.org/python-team/packages/python-qtpy/-/blob/master/qtpy/tests/conftest.py But there doesn't seem to be anything out of the ordinary about this. So I am mystified: why does pytest 7.x seem to not give this error on any other Debian package? The only solution I currently have for this package is skip the tests at build time and rely on autopkgtest to do them. Best wishes, Julian
Hi,
I'm a lurker of debian-python@lists.debian.org but seeing Python+Qt I
wanted to have a look. I don't have a solution (I might look more
another time if time permits) but I might have something that might help
someone who knows the tools better.
I am not familiar with Python Debian packaging details/tools neither
with pytest :-( so take all of this with a pinch of salt.
If it helps the error comes from:
/usr/lib/python3.9/importlib/__init__.py in the functin "import_modules"
it does:
"""
if name.startswith('.'):
if not package:
msg = ("the 'package' argument is required to perform a relative "
"import for {!r}")
raise TypeError(msg.format(name))
"""
When the import fails the "name" parameter of "import_modules" function
is: '.pybuild.cpython3_3.9_qtpy.build.qtpy.tests' , which is derived
from the hidden dirctory ".pybuild" as created by default by "pybuild".
I think that the initial "." is used only as a directory name but Python
assumes that is a relative import requiring the package parameter.
Just to check my thoughts, and after running dpkg-buildpackage and
failing let's try again:
$ cd .pybuild/cpython3_3.9_qtpy/build; python3.9 -m pytest qtpy/tests ; cd -
Fails with the:
TypeError: the 'package' argument is required to perform a relative import for '.pybuild.cpython3_3.9_qtpy.build.qtpy.tests'
/home/carles/git/python-qtpy
Then let's try to avoid the initial "." confusion:
$ mv .pybuild pybuild
$ cd pybuild/cpython3_3.9_qtpy/build; python3.9 -m pytest qtpy/tests ; cd -
It works.
I don't know why this is the only package affected by this though...
Hopefully it helps a bit!
--
Carles Pina i Estany
https://carles.pina.cat
Hi Carles, Thanks for your thoughts! Yes, indeed that seems to be the issue. But what I don't understand is why the import is turned into .pybuild.cpython3_3.9_qtpy.build.qtpy.tests and not just qtpy.tests or a longer path, and why only this package fails in this way. Perhaps this is the only package that has an import statement in pytest_configure? Best wishes, Julian
Hi Julian, I see how pytest does it (but keep reading) This I don't know and I'm curious, and it might help disecting the issue (or understanding it). Do you know of any other python3 package that you expected to fail? (using pytest in a similar way). I might try to get both and follow what they do different (to hopefully know what is python-qtpy doing different :-) ) I'm sure that there are tons of packages that use pytest :-) I'm wondering if you had a good candidate. Best regards, -- Carles Pina i Estany https://carles.pina.cat
Hi Carles, It is utterly, utterly bizarre. But I think I've found the problem. There's a pytest.ini file in the package, but it's not copied into the test directory. So when pytest is run in the .pybuild directory, it climbs all the way back up the directory tree to the python-qtpy-2.1.0 until it discovers the pytest.ini file there and uses that. It sees that we are requesting qtpy/tests, which it then expands into the directory path .pybuild/cpython3_3.10_qtpy/build/qtpy/tests, starting from the directory in which it found pytest.ini, and this causes the breakage. The solution is to copy the pytest.ini file into the .pybuild directories by adding it to debian/pybuild.testfiles Why this behaviour changed between pytest 6.x and pytest 7.x I don't know; I don't see it obviously documented. But that at least resolves this problem. Thanks for your help! Best wishes, Julian
Hello, Bug #1013700 in python-qtpy reported by you has been fixed in the Git repository and is awaiting an upload. You can see the commit message below and you can check the diff of the fix at: https://salsa.debian.org/python-team/packages/python-qtpy/-/commit/e7d0236cc1a1e1718a05ed4a09a7dd24fca6b723 (this message was generated automatically) -- Greetings https://bugs.debian.org/1013700
We believe that the bug you reported is fixed in the latest version of python-qtpy, which is due to be installed in the Debian FTP archive. A summary of the changes between this version and the previous one is attached. Thank you for reporting the bug, which will now be closed. If you have further comments please address them to 1013700@bugs.debian.org, and the maintainer will reopen the bug report if appropriate. Debian distribution maintenance software pp. Julian Gilbey <jdg@debian.org> (supplier of updated python-qtpy package) (This message was generated automatically at their request; if you believe that there is a problem with it please contact the archive administrators by mailing ftpmaster@ftp-master.debian.org) Format: 1.8 Date: Mon, 04 Jul 2022 22:45:45 +0100 Source: python-qtpy Architecture: source Version: 2.1.0-3 Distribution: unstable Urgency: medium Maintainer: Debian Python Team <team+python@tracker.debian.org> Changed-By: Julian Gilbey <jdg@debian.org> Closes: 1013700 Changes: python-qtpy (2.1.0-3) unstable; urgency=medium . * Fix FTBFS error with Pytest 7.x (closes: #1013700) * Update d/copyright and standards-version * Add missing documentation to /usr/share/doc/python3-qtpy * Add build-depends for new pybuild version * Add qtpy(1) manpage Checksums-Sha1: 7f197188ec46fad9c47d968e9fe72faa8224dfc9 3534 python-qtpy_2.1.0-3.dsc c04c7a83177e4a558c4808ae301b3e120a55557a 5832 python-qtpy_2.1.0-3.debian.tar.xz 6b2417ed8c1775d1221cf737b1a15d9267e7f740 13821 python-qtpy_2.1.0-3_amd64.buildinfo Checksums-Sha256: cf68d770359e31eda1503f55a9d698ca73ed05706119d29bacc37ac65336b6f7 3534 python-qtpy_2.1.0-3.dsc 49357d644766a3d08ebe4e267a91e738f4267ff9d9873f4fb47ea888aa047f65 5832 python-qtpy_2.1.0-3.debian.tar.xz 5183d6203033878db2349ad230ba95044f3869afa570deaf2501130554c97c8e 13821 python-qtpy_2.1.0-3_amd64.buildinfo Files: 9ca95a3f918c5da6298595eb44f2f80c 3534 python optional python-qtpy_2.1.0-3.dsc 6152f2f4285136a8193aababc315e8c5 5832 python optional python-qtpy_2.1.0-3.debian.tar.xz 51d97f443b0509944b714031f4965eb1 13821 python optional python-qtpy_2.1.0-3_amd64.buildinfo -----BEGIN PGP SIGNATURE----- iQJDBAEBCAAtFiEEfhrD+iemSShMMj72aVxCkxbAe/4FAmLDYG4PHGpkZ0BkZWJp YW4ub3JnAAoJEGlcQpMWwHv+OYsP/1zonH2FJIibZgT9V4p1NMyyVqxtrsTSE2aF ZAmAOESR8GopZKgwKPOsYE5zpJGX24IfGARlPcQnwrKKOSNsJ6YR/L1Ryv/0evYC mqTuPenww96oIkogECxjNBkomt/MQJ/sEQ+dklPPr7uttQPWbg30xdVtHpFe7Aqx A1zBxq5JYZCs9Sy5+TFNWwsDXufBeh+++ksNDU77uKVpQHKc/OYLkeE5LdGLsDRW Ohn2u8wPvRy8C0QXoOA/nDfOYNpUzlPP0C0SLvXQ9u+kVAQpzqo37/2pPOHmbWk0 DcQtFizriRVmYunNi+/2Aco/Pny15j8DRei3o7bSKPGtSGk5+66LxWfr7TsVL8t0 PbutVgJ4Zs1RAjSJrbk9TAfxuMPSTgODUlB0gcFq4vXLy03Hu9Wu8opRPetec0ZK u5Z4dEgl0xtOWE/i7jBkGNjjSQklNNICGWtB3SwT1ayvcx197nUAt+jE7Cqlw2tK HSTXpvacc/B87XLr969gSbt98CTFAWf9H0WSrvJbNxT4DrJNkdgVNFIDrF4RrrLU KAw6n+v218rZdsbo20VLfDWQzyUVClR/sBtE6RkZQSPbJ9Bu4OmusvYrcWJ788Xv RROYOYGN67PhveNj6q/CoRUYMC01eeAkzhlX4I4M5qJxsXtbGvZ23nW6Y5xoZVmg NiGlnhZT =ALaB -----END PGP SIGNATURE-----
Hi, [...] You're welcome! Cheers, -- Carles Pina i Estany https://carles.pina.cat