Path: csiph.com!weretis.net!feeder8.news.weretis.net!usenet.goja.nl.eu.org!aioe.org!bofh.it!news.nic.it!robomod From: Carles Pina i Estany Newsgroups: linux.debian.maint.python,linux.debian.bugs.dist Subject: Re: Strangely rare pytest 7.x bug report Date: Tue, 05 Jul 2022 09:50:01 +0200 Message-ID: References: X-Mailbox-Line: From debian-python-request@lists.debian.org Tue Jul 5 07:47:43 2022 Old-Return-Path: X-Amavis-Spam-Status: No, score=-7.21 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, LDO_WHITELIST=-5, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no X-Policyd-Weight: using cached result; rate: -4.6 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/2.0.5 (2021-01-21) X-Mailing-List: archive/latest/20048 List-ID: List-URL: List-Archive: https://lists.debian.org/msgid-search/YsPsiugEZPa704DF@pina.cat Approved: robomod@news.nic.it Lines: 141 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Cc: Debian Python list , 1013700@bugs.debian.org X-Original-Date: Tue, 5 Jul 2022 08:47:22 +0100 X-Original-Message-ID: X-Original-References: Xref: csiph.com linux.debian.maint.python:14216 linux.debian.bugs.dist:1108702 Hi, On Jul/04/2022, Julian Gilbey wrote: > It is utterly, utterly bizarre. But I think I've found the problem. [...] > Thanks for your help! You're welcome! Cheers, > > Best wishes, > > Julian > > On Mon, Jul 04, 2022 at 08:39:32PM +0100, Carles Pina i Estany wrote: > > > > Hi Julian, > > > > On Jul/04/2022, Julian Gilbey wrote: > > > 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 > > > > I see how pytest does it (but keep reading) > > > > > 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? > > > > 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, > > > > > > > > Best wishes, > > > > > > Julian > > > > > > On Mon, Jul 04, 2022 at 04:03:39PM +0100, Carles Pina i Estany wrote: > > > > > > > > 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! > > > > > > > > On Jul/04/2022, Julian Gilbey wrote: > > > > > 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 -- Carles Pina i Estany https://carles.pina.cat