Skip to content

fix: Robust resource lookup for editable installs - #6183

Merged
richtja merged 2 commits into
avocado-framework:masterfrom
YvanY0:fix-pkg_resources
Aug 13, 2025
Merged

fix: Robust resource lookup for editable installs#6183
richtja merged 2 commits into
avocado-framework:masterfrom
YvanY0:fix-pkg_resources

Conversation

@YvanY0

@YvanY0 YvanY0 commented Jul 4, 2025

Copy link
Copy Markdown

This commit resolves a TypeError that occurred when avocado and avocado-vt was installed in editable mode. Previously, pkg_resources would fail to correctly resolve resource paths (like avocado.conf) because the module's file attribute could be None.

To fix this, we've switched to importlib.resources.files for locating package data. This modern API is more reliable and correctly handles resource lookups across various installation methods, including editable installs.

Summary by CodeRabbit

  • Refactor
    • Modernized packaged-configuration resource handling; no user-facing changes or behavior differences expected.
  • Chores
    • CI workflow updated to use newer Ubuntu images (tasks moved to newer OS versions); no changes to build steps or runtime behavior.

@coderabbitai

coderabbitai Bot commented Jul 4, 2025

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Replaced pkg_resources usage with importlib.resources.files to locate the package config file in avocado/core/settings.py. Updated CI job identifiers and Ubuntu container images in .github/workflows/ci.yml (renamed jobs and moved some jobs from ubuntu:20.04→22.04 and ubuntu:22.04→24.04). No public API changes.

Changes

Cohort / File(s) Change Summary
Package config lookup
avocado/core/settings.py
Replaced pkg_resources.resource_exists/resource_filename logic with importlib.resources.files("avocado") / "etc" / "avocado" / "avocado.conf", checking is_file() and storing the path string if present.
CI workflow: Ubuntu job renames & image updates
.github/workflows/ci.yml
Renamed job identifiers and updated container images: version_task_ubuntu_22version_task_ubuntu_24 (image ubuntu:24.04), version_task_ubuntu_20version_task_ubuntu_22 (image ubuntu:22.04), egg_task_ubuntu_22egg_task_ubuntu_24 (image ubuntu:24.04), egg_task_ubuntu_20egg_task_ubuntu_22 (image ubuntu:22.04). Internal step logic unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74bf027 and a2ea8b8.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (29)
  • GitHub Check: rpm-build:fedora-41-ppc64le
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-41-s390x
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:fedora-41-aarch64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:fedora-41-aarch64
  • GitHub Check: rpm-build:fedora-41-ppc64le
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:fedora-41-s390x
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: Egg task fedora:40
  • GitHub Check: Fedora selftests
  • GitHub Check: Podman spawner with 3rd party runner plugin
  • GitHub Check: Egg task ubi:9.2
  • GitHub Check: Version task debian:11.0
  • GitHub Check: Version task ubi:8.8
  • GitHub Check: Version task ubuntu:22.04
  • GitHub Check: Version task debian:12.4
  • GitHub Check: Smokecheck on Linux with Python 3.11
  • GitHub Check: Smokecheck on Linux with Python 3.10
  • GitHub Check: macOS with Python 3.11
  • GitHub Check: Static checks
  • GitHub Check: Code Coverage (3.11)
🔇 Additional comments (4)
.github/workflows/ci.yml (4)

333-345: Good move to ubuntu:24.04 for the version task; aligns with Python ≥3.12 and importlib.resources.files.

This brings the container job in line with the runtime expectations of the pkg_resources→importlib.resources migration.


435-447: No pip installation needed for egg composite action

Verified that the .github/actions/egg/action.yml only runs python3 setup.py bdist_egg, setup.py clean, and a python3 -c import—it never invokes pip. The existing apt -y install python3 python3-setuptools step is sufficient; no changes required.


448-460: Drop unnecessary pip install in ubuntu:22.04 egg task
The .github/actions/egg action invokes python3 setup.py bdist_egg and runs the egg directly—it never calls pip. Adding python3-pip (or ca-certificates) isn’t required here, so you can keep the install step as-is.

Likely an incorrect or invalid review comment.


151-176: windows-2025 runner label is supported—no change required.

The GitHub Actions hosted environments include an explicit windows-2025 image today, so your workflow’s runs-on: windows-2025 will work as intended. If you prefer to track the “latest” Windows Server (migrating to 2025 in Sep 2025), you can use windows-latest, but you don’t need to update this job.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mr-avocado

mr-avocado Bot commented Jul 4, 2025

Copy link
Copy Markdown

Dear contributor,
the rpm-build:fedora-rawhide-x86_64 CI failure is probably not caused by your changes, but an infrastructure issue. Please ignore this failure.

@mr-avocado mr-avocado Bot moved this to Review Requested in Default project Jul 4, 2025
@YvanY0

YvanY0 commented Jul 4, 2025

Copy link
Copy Markdown
Author

The issue is: After install avocado and avocado-vt with pip install --user -e ., then bootstrap tp-qemu/tp-libvirt, and then

>>> from avocado.core import data_dir
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/home/kar/workspace/avocado/avocado/core/__init__.py", line 20, in <module>
    from avocado.core.dispatcher import InitDispatcher
  File "/var/home/kar/workspace/avocado/avocado/core/dispatcher.py", line 26, in <module>
    from avocado.core.enabled_extension_manager import EnabledExtensionManager
  File "/var/home/kar/workspace/avocado/avocado/core/enabled_extension_manager.py", line 20, in <module>
    from avocado.core.settings import settings
  File "/var/home/kar/workspace/avocado/avocado/core/settings.py", line 839, in <module>
    settings = Settings()  # pylint: disable-msg=invalid-name
               ^^^^^^^^^^
  File "/var/home/kar/workspace/avocado/avocado/core/settings.py", line 379, in __init__
    self._prepare_base_dirs()
  File "/var/home/kar/workspace/avocado/avocado/core/settings.py", line 419, in _prepare_base_dirs
    if resource_exists("avocado", config_pkg_base):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pkg_resources/__init__.py", line 1205, in resource_exists
    return get_provider(package_or_requirement).has_resource(resource_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pkg_resources/__init__.py", line 407, in get_provider
    return _find_adapter(_provider_factories, loader)(module)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pkg_resources/__init__.py", line 1491, in __init__
    self.module_path = os.path.dirname(getattr(module, '__file__', ''))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen posixpath>", line 181, in dirname
TypeError: expected str, bytes or os.PathLike object, not NoneType

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 258dc38 and 73cc1b9.

📒 Files selected for processing (1)
  • avocado/core/settings.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Fedora develop install/uninstall task
  • GitHub Check: Fedora selftests
  • GitHub Check: Egg task fedora:40
  • GitHub Check: Podman spawner with 3rd party runner plugin
  • GitHub Check: Egg task ubi:9.2
  • GitHub Check: Analyze (python)
  • GitHub Check: Code Coverage (3.11)
  • GitHub Check: Build Package (wheel/tarball) for Python 3.9
  • GitHub Check: Build Package (wheel/tarball) for Python 3.11
  • GitHub Check: Build Package (wheel/tarball) for Python 3.8
  • GitHub Check: Version task ubi:8.8
  • GitHub Check: Windows with Python 3.10
  • GitHub Check: Windows with Python 3.11
  • GitHub Check: Windows with Python 3.9
  • GitHub Check: Version task debian:12.4
  • GitHub Check: macOS with Python 3.11
  • GitHub Check: Windows with Python 3.13
  • GitHub Check: Version task ubuntu:22.04
  • GitHub Check: Smokecheck on Linux with Python 3.10
  • GitHub Check: Static checks
🔇 Additional comments (2)
avocado/core/settings.py (2)

45-45: Excellent modernization: Replace deprecated pkg_resources with importlib.resources

This change modernizes the resource handling by using the recommended importlib.resources.files API instead of the deprecated pkg_resources. This is a best practice update that improves compatibility and robustness.


417-420: Robust resource lookup implementation for editable installs

The implementation correctly uses the modern importlib.resources.files API to construct the resource path and check for file existence. This approach is more robust than the previous pkg_resources methods, especially for editable installs where the module's __file__ attribute might be None.

The logic is equivalent to the previous implementation:

  • Constructs the path using the / operator (modern pathlib-style)
  • Checks existence with is_file() instead of resource_exists
  • Converts to string path when the resource exists

Comment thread avocado/core/settings.py
@YvanY0

YvanY0 commented Jul 4, 2025

Copy link
Copy Markdown
Author

Hello @richtja @harvey0100, can you help review this PR? The issue only happens with --editable install.

BTW, GH actions have some failures, but consider Python 3.8 and Ubuntu 20.04 are all out of support, so are we plan to remove them from the CI check?

@codecov

codecov Bot commented Jul 4, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.34%. Comparing base (ef3385d) to head (a2ea8b8).
⚠️ Report is 58 commits behind head on master.

Files with missing lines Patch % Lines
avocado/core/settings.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6183      +/-   ##
==========================================
+ Coverage   68.33%   68.34%   +0.01%     
==========================================
  Files         205      205              
  Lines       22413    22413              
==========================================
+ Hits        15315    15318       +3     
+ Misses       7098     7095       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@harvey0100
harvey0100 requested review from clebergnu and richtja July 4, 2025 10:11
@YvanY0
YvanY0 force-pushed the fix-pkg_resources branch from 73cc1b9 to 4c0745e Compare July 4, 2025 10:40
@YvanY0 YvanY0 changed the title Fix: Robust resource lookup for editable installs fix: Robust resource lookup for editable installs Jul 4, 2025
@harvey0100

Copy link
Copy Markdown
Contributor

Hi @PaulYuuu

PR looks good to me, but first of all want to have a discussion with Jan and Cleber about this and review the current issues happening with our CI and decide what we will do.

@YvanY0

YvanY0 commented Jul 4, 2025

Copy link
Copy Markdown
Author

Hi @PaulYuuu

PR looks good to me, but first of all want to have a discussion with Jan and Cleber about this and review the current issues happening with our CI and decide what we will do.

Thank you @harvey0100, I agree with you, and let me list some info here.

Python3.8

Branch Schedule Status First release End of life
3.8 PEP 569 end-of-life 2019-10-14 2024-10-07

Ubuntu 20.04

Ubuntu 20.04 LTS (Focal Fossa) has reached the end of its standard five-year support window on 31 May 2025. It’s time to start thinking about your options for upgrading.

Ubi8.8? Not sure if we still want it.

BTW, this PR only removed pkg_resources from settings.py, for others files which use pkg_resources, we should remove them or pin the setuptools <81, see:

/root/.local/lib/python3.12/site-packages/avocado/core/init.py:18: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.

@richtja richtja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PaulYuuu, IIUIC these changes will need deprecation of python 3.8, unfortunately I am not sure if we are prepared for stopping the support of python 3.8. We will need a brother discussion with avocado-vt and tp maintainers to find out if we can do it.

@YvanY0

YvanY0 commented Jul 8, 2025

Copy link
Copy Markdown
Author

Hi @PaulYuuu, IIUIC these changes will need deprecation of python 3.8, unfortunately I am not sure if we are prepared for stopping the support of python 3.8. We will need a brother discussion with avocado-vt and tp maintainers to find out if we can do it.

Sure, this only happens in --editable mode, so we have enough time slots to gather more opinions from other maintainers.

richtja added a commit to richtja/avocado that referenced this pull request Jul 28, 2025
Reference: avocado-framework#6183
Signed-off-by: Jan Richter <jarichte@redhat.com>
@richtja richtja mentioned this pull request Jul 28, 2025
richtja added a commit to richtja/avocado that referenced this pull request Aug 6, 2025
Reference: avocado-framework#6183
Signed-off-by: Jan Richter <jarichte@redhat.com>
This commit resolves a TypeError that occurred when avocado and
avocado-vt was installed in editable mode. Previously, pkg_resources
would fail to correctly resolve resource paths (like avocado.conf)
because the module's __file__ attribute could be None.

To fix this, we've switched to importlib.resources.files for locating
package data. This modern API is more reliable and correctly handles
resource lookups across various installation methods, including editable
installs.

Signed-off-by: Yihuang Yu <yihyu@redhat.com>
@YvanY0
YvanY0 force-pushed the fix-pkg_resources branch from 4c0745e to f04bef6 Compare August 13, 2025 01:21

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f04bef6 and 7244cd1.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (48)
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-41-s390x
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:fedora-41-ppc64le
  • GitHub Check: rpm-build:fedora-41-aarch64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-41-aarch64
  • GitHub Check: rpm-build:fedora-41-s390x
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:fedora-41-ppc64le
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:fedora-41-aarch64
  • GitHub Check: rpm-build:fedora-41-ppc64le
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:fedora-41-s390x
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: Podman spawner with 3rd party runner plugin
  • GitHub Check: Egg task ubuntu:20.04
  • GitHub Check: Fedora develop install/uninstall task
  • GitHub Check: Fedora selftests
  • GitHub Check: Version task fedora:40
  • GitHub Check: Build Package (wheel/tarball) for Python 3.11
  • GitHub Check: Experimental checks
  • GitHub Check: Build Package (wheel/tarball) for Python 3.13
  • GitHub Check: Build Package (wheel/tarball) for Python 3.9
  • GitHub Check: Build Package (wheel/tarball) for Python 3.12
  • GitHub Check: Build Package (wheel/tarball) for Python 3.10
  • GitHub Check: Egg task ubi:9.2
  • GitHub Check: Version task debian:12.4
  • GitHub Check: Version task ubi:8.8
  • GitHub Check: Smokecheck on Linux with Python 3.10
  • GitHub Check: Smokecheck on Linux with Python 3.11
  • GitHub Check: Version task ubuntu:22.04
  • GitHub Check: Static checks
  • GitHub Check: macOS with Python 3.11
  • GitHub Check: Code Coverage (3.11)
🔇 Additional comments (1)
.github/workflows/ci.yml (1)

152-152: Verify the runner label ‘windows-2025’.

GitHub-hosted Windows runners are typically windows-latest/windows-2022. Please confirm that windows-2025 is a valid, available label in your org. If not, switch to a supported label to avoid job failures.

If not valid, update to:

-    runs-on: windows-2025
+    runs-on: windows-2022

Or:

-    runs-on: windows-2025
+    runs-on: windows-latest

Comment thread .github/workflows/ci.yml Outdated
steps:
- name: Install Python dependencies
run: apt update && apt -y install python3 python3-setuptools ca-certificates
run: apt update && apt -y install python3.9 python3-setuptools ca-certificates

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Installing python3.9 doesn’t switch the default interpreter (python3 still points to 3.8 on ubuntu:20.04).

As written, downstream steps called by the composite action likely continue to use Python 3.8. If the goal is to run with 3.9 (to ensure importlib.resources.files availability), explicitly switch python3 to 3.9 and ensure setuptools/pip exist for 3.9 inside the container.

Apply this diff to set python3 -> 3.9 and bootstrap pip/setuptools:

-        run: apt update && apt -y install python3.9 python3-setuptools ca-certificates
+        run: |
+          apt update
+          apt -y install python3.9 python3.9-venv python3.9-distutils ca-certificates
+          update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
+          update-alternatives --set python3 /usr/bin/python3.9
+          python3 -m ensurepip --upgrade || true
+          python3 -m pip install -U "setuptools<80" wheel

Ensure default python3 is v3.9 in CI

On ubuntu-20.04, installing python3.9 does not switch the /usr/bin/python3 symlink (it remains Python 3.8). Downstream steps will continue to use 3.8 unless you explicitly change it. You have two options:

Use the built-in setup step (recommended):

- uses: actions/setup-python@v4
  with:
    python-version: 3.9

Or manually install and switch via apt:

-        run: apt update && apt -y install python3.9 python3-setuptools ca-certificates
+        run: |
+          apt update
+          apt install -y python3.9 python3.9-distutils python3.9-venv ca-certificates
+          update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
+          update-alternatives --set python3 /usr/bin/python3.9
+          python3 -m ensurepip --upgrade || true
+          python3 -m pip install --upgrade pip setuptools wheel
🤖 Prompt for AI Agents
In .github/workflows/ci.yml around line 354, the workflow installs python3.9 via
apt but does not update /usr/bin/python3, so CI still uses Python 3.8; fix by
either replacing the apt install with the actions/setup-python@v4 step
specifying python-version: 3.9 (recommended), or if you must install via apt,
after installing python3.9 run the appropriate update-alternatives commands to
register python3.9 and set it as the default /usr/bin/python3 (and ensure pip
for that python is available).

Comment thread .github/workflows/ci.yml Outdated
steps:
- name: Install Python dependencies
run: apt update && apt -y install python3 python3-setuptools
run: apt update && apt -y install python3.9 python3-setuptools

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Same issue for egg_task_ubuntu_20: python3 will remain 3.8 unless explicitly switched.

Building eggs via the composite action will likely invoke python3 (3.8). Ensure the job actually uses 3.9 and has setuptools/pip for that interpreter.

Apply this diff:

-        run: apt update && apt -y install python3.9 python3-setuptools
+        run: |
+          apt update
+          apt -y install python3.9 python3.9-venv python3.9-distutils
+          update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
+          update-alternatives --set python3 /usr/bin/python3.9
+          python3 -m ensurepip --upgrade || true
+          python3 -m pip install -U "setuptools<80" wheel

Ensure Python 3.9 Is the Default and Has pip/setuptools Installed

The python3-setuptools package targets the system’s default Python 3 (3.8 on Ubuntu 20.04), so simply installing python3.9 + python3-setuptools won’t:

  • Make python3 point to 3.9
  • Provide pip/setuptools for the 3.9 interpreter

Apply this update in .github/workflows/ci.yml (around line 456):

-        run: apt update && apt -y install python3.9 python3-setuptools
+        run: |
+          apt update
+          apt -y install python3.9 python3.9-venv python3.9-distutils
+          update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
+          update-alternatives --set python3 /usr/bin/python3.9
+          python3 -m ensurepip --upgrade || true
+          python3 -m pip install -U "setuptools<80" wheel

This ensures:

  • python3 invokes Python 3.9
  • A venv module and distutils are available
  • pip and setuptools are bootstrapped for 3.9
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: apt update && apt -y install python3.9 python3-setuptools
run: |
apt update
apt -y install python3.9 python3.9-venv python3.9-distutils
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
update-alternatives --set python3 /usr/bin/python3.9
python3 -m ensurepip --upgrade || true
python3 -m pip install -U "setuptools<80" wheel
🤖 Prompt for AI Agents
In .github/workflows/ci.yml around line 456, the workflow installs python3.9
plus python3-setuptools which only targets the system default Python (3.8 on
Ubuntu 20.04) and therefore won't make python3 point to 3.9 or provide
pip/setuptools for the 3.9 interpreter; replace that step with installing
python3.9, python3.9-venv and python3.9-distutils, then use update-alternatives
to register and set /usr/bin/python3 to python3.9, and finally bootstrap
pip/setuptools for 3.9 by running python3.9 -m ensurepip --upgrade (or python3.9
-m pip install --upgrade pip setuptools) so the workflow invokes the correct
interpreter and has pip/venv/distutils available.

@YvanY0
YvanY0 force-pushed the fix-pkg_resources branch from 7244cd1 to 74bf027 Compare August 13, 2025 01:52
@YvanY0

YvanY0 commented Aug 13, 2025

Copy link
Copy Markdown
Author

Hello @richtja @harvey0100 , as you can see, ubuntu:20.04 still using python3.8. And if I install python3.9 instead of python3, it does not have the entry python3, only has python3.9, so ubuntu20.04 all failed.

Considering ubuntu 20.04 is EOL, so is possible remove it from our GitHub Actions?

@richtja

richtja commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

Hello @richtja @harvey0100 , as you can see, ubuntu:20.04 still using python3.8. And if I install python3.9 instead of python3, it does not have the entry python3, only has python3.9, so ubuntu20.04 all failed.

Considering ubuntu 20.04 is EOL, so is possible remove it from our GitHub Actions?

Hi @PaulYuuu, yes you are right, I have missed that in #6197 sorry about that. Could you please introduce a commit here with drop of ubuntu-20.04 and introduction of ubuntu-24.04 instead?

I can open a separated PR about this change, but IMO that would block you even longer and won't be efficient.

@YvanY0

YvanY0 commented Aug 13, 2025

Copy link
Copy Markdown
Author

Hello @richtja @harvey0100 , as you can see, ubuntu:20.04 still using python3.8. And if I install python3.9 instead of python3, it does not have the entry python3, only has python3.9, so ubuntu20.04 all failed.
Considering ubuntu 20.04 is EOL, so is possible remove it from our GitHub Actions?

Hi @PaulYuuu, yes you are right, I have missed that in #6197 sorry about that. Could you please introduce a commit here with drop of ubuntu-20.04 and introduction of ubuntu-24.04 instead?

I can open a separated PR about this change, but IMO that would block you even longer and won't be efficient.

Sure, I will update later.

Drop ubuntu 20.04 egg and version tasks, as it's EOL. Instead, introduce
new ubuntu 24.04 tasks to cover new ubuntu version.

Signed-off-by: Yihuang Yu <yihyu@redhat.com>
@YvanY0
YvanY0 force-pushed the fix-pkg_resources branch from 74bf027 to a2ea8b8 Compare August 13, 2025 10:25
maramsmurthy pushed a commit to maramsmurthy/avocado that referenced this pull request Aug 13, 2025
Reference: avocado-framework#6183
Signed-off-by: Jan Richter <jarichte@redhat.com>

@richtja richtja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PaulYuuu, thanks for the updates it LGTM.

@richtja
richtja merged commit f0c9dfb into avocado-framework:master Aug 13, 2025
63 checks passed
@github-project-automation github-project-automation Bot moved this from Review Requested to Done 112 in Default project Aug 13, 2025
xianglongfei-8888 pushed a commit to xianglongfei-8888/avocado that referenced this pull request Nov 25, 2025
Reference: avocado-framework#6183
Signed-off-by: Jan Richter <jarichte@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants