Running tests in Fedora packaging

Open
#148 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

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.

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 "<doctest packaging.metadata.hunt_down_url[0]>", line 1, in <module>
  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?

Dominant language
No language data
Stars
152
Forks
38
Avg merge
6h 27m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jaraco/skeleton

All issues in jaraco/skeleton

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.