Open LecrisUT opened 2 months ago
I'm disinterested in implementing the src
layout. I've long bemoaned the undesirable effect it has to move the primary functionality of the project into a subdirectory. For similar reasons, I'm also not a fan of the flat layout, which is why I've published the essential layout, which goes into a bit more detail about the problems with src and flat layouts. That said, I'm not ready yet to migrate projects to Coherent and the essential layout.
I've put a lot of work into trying to structure projects so they work consistently across all of them. I've learned from pytest that the import-mode
of importlib
is the preferred way forward (other modes are legacy and should only be used if necessary), so I'm also disinterested in switching to those less-preferred modes. Let's see if we can find a better solution.
As a side note, when switching to the coherent system and the essential layout, these issues all go away because the import finder is dead simple.
The good news is that I've put a lot of work into making sure all of the packages' tests are running under pytest using the importlib
mode, so we know it's possible to run the tests using that mode.
It's not yet clear to me what it is about the Fedora packaging scheme that's violating the pytest discovery mechanism. Are you able to describe the steps one could take to simulate what Fedora packaging is doing so we could replicate the issues with a package like jaraco.packaging
?
👍 to whatever layout works best for you and the skeleton, but could we investigate the source of failure together and try to find some downstream-only patches that could help workaround these issues.
Well one issue would be with the outdated version of pytest
in epel 8 or 9, which I don't think they can be updated in Fedora repos. At least the Fedora branches seem to work fine, but I can't confirm if it's because the importlib is working correctly or if the cwd python modules are being picked up, the latter of which we want to avoid.
Basically the workflow is pip wheel
-> install wheel to staging directory -> pytest with PYTHONPATH
pointing to staging directory. The test is meant to make sure all relevant python files are installed correctly and there should not be any files being accidentally picked up due to cwd (default is the extracted sdist). Any suggestions on how to ensure this part works well? We want to avoid cd
ing to a dummy folder because the pytest.ini
would not be picked up.
My current thoughts is if it's possible to modify the structure downstream-only. E.g. because setuptools is too old on epel9 to support PEP621 (because it's a fundamental dependency for packages like pip), I've resorted to switching the build backend to hatchling
(which is more updated and supports PEP621) by patching the pyproject.toml
. Wouldn't it be possible to patch these similarly for these packages?
There are a few ways to reproduce the build environment in Fedora and epel:
--no-build-isolation
and installing the python packages manuallypackit
which mimics all Fedora packaging environments in the upstream repo. I can show this setup in a PR of a repo and see what your thoughts are of its workflow. This would be the top preference because you would be able to debug issues directly in the git repoLet me know how I can best help you investigate this issue or if there are any Fedora packaging questions I can help with.
Edit: added more details on Fedora build workflow
Lately I have been reviewing a bunch of
jaraco.*
packages in Fedora, and every now-and-then I get issues with running the tests where the non-src-layout
interferes with/usr/bin/pytest
calls. Sometimes I work around it by changing the--import-mode prepend
, sometimes I have to runpython3 -m pytest
.One recent example was in
jaraco.packaging
where it errors as:I hope that a
src-layout
can mitigate the need for--import-mode importlib
, but also it might need relative imports all around as well?