jaraco / jaraco/skeleton

Running tests in Fedora packaging

Open
#148 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
150
Forks
38
Avg merge
1m
Merged PRs (30d)
1

Description

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 run `python3 -m pytest`.

One recent example was in `jaraco.packaging` where it errors as:

```
__________________ [doctest] packaging.metadata.hunt_down_url __________________
019
020 Given project metadata, figure out what the package URL is.
021
022 >>> hunt_down_url(load('.'))
UNEXPECTED EXCEPTION: ModuleNotFoundError("No module named 'packaging.version'")
Traceback (most recent call last):
File "/usr/lib64/python3.13/doctest.py", line 1395, in __run
exec(compile(example.source, filename, "single",
~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
compileflags, True), test.globs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1, in
File "/builddir/build/BUILD/python-jaraco-packaging-10.2.2-build/jaraco_packaging-10.2.2/jaraco/packaging/metadata.py", line 15, in load
return util.project_wheel_metadata(source_dir, isolated, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/build/util.py", line 42, in project_wheel_metadata
with DefaultIsolatedEnv() as env:
~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/site-packages/build/env.py", line 90, in __enter__
self._env_backend = _PipBackend()
~~~~~~~~~~~^^
File "/usr/lib/python3.13/site-packages/build/env.py", line 153, in __init__
self._create_with_virtualenv = not self._has_valid_outer_pip and self._has_virtualenv
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.13/functools.py", line 1037, in __get__
val = self.func(instance)
File "/usr/lib/python3.13/site-packages/build/env.py", line 162, in _has_valid_outer_pip
return _has_dependency('pip', '22.3')
File "/usr/lib/python3.13/site-packages/build/env.py", line 46, in _has_dependency
from packaging.version import Version
ModuleNotFoundError: No module named 'packaging.version'
/builddir/build/BUILD/python-jaraco-packaging-10.2.2-build/jaraco_packaging-10.2.2/jaraco/packaging/metadata.py:22: UnexpectedException
```

Basically it interpreted `jaraco.packaging` as `packaging`

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?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing `/usr/bin/pytest` with `python3 -m pytest` and the reported `--import-mode prepend` workaround in the skeleton's test setup. Use the `jaraco/packaging/metadata.py` traceback as a reproduction clue, then determine whether the package layout or imports need adjustment so Fedora test runs do not resolve `jaraco.packaging` as `packaging`.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.