Skip to content

Conversation

@ogajduse
Copy link
Member

Summary

• Replace deprecated pkg_resources with modern importlib
• Fix Python 3.12+ compatibility issues
• Update shebang from python2 to python3

Fixes #405

🤖 Generated with Claude Code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ogajduse
Copy link
Member Author

importlib.resources.files was added in Python 3.9. If 3.9 is the lowest version we support, we should be fine.
https://docs.python.org/3/library/importlib.resources.html#importlib.resources.files

This patch will allow running on Python > 3.11.

@ogajduse
Copy link
Member Author

All test failures seem to be unrelated. I've filed #412 for one of the failures I've spotted.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Looks good. I don't consider the docs config to be blocking and I need this on my own dev setup so merging this.

package = pkg_resources.require("obal")[0]
version = package.version
release = package.version
from importlib import metadata
Copy link
Member

Choose a reason for hiding this comment

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

release = package.version
from importlib import metadata
version = release = metadata.version('obal')
except:
Copy link
Member

Choose a reason for hiding this comment

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

Shall we scope it explicitly to metadata.PackageNotFoundError now?

I'd be tempted to use

from importlib import metadata
try:
    version = release = metadata.version('obal')
except metadata.PackageNotFoundError:
    version = release = ''

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll check this one out


import os
import obsah
from importlib import resources
Copy link
Member

Choose a reason for hiding this comment

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

# https://github.com/pytest-dev/pytest-xdist/issues/414
distribution = pkg_resources.get_distribution('obal')
path = os.path.join(distribution.location, path)
path = str(resources.files(__name__) / 'data')
Copy link
Member

Choose a reason for hiding this comment

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

Note to self: added in Python 3.9 (https://docs.python.org/3/library/importlib.resources.html#importlib.resources.files). This call looks correct for both 3.9 and 3.12+ (where it was changed).

@ekohl
Copy link
Member

ekohl commented Nov 22, 2025

I opened #417 for the rpmlint warning but that still failed so I also opened #418 to address the other errors you found and reported in #412.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Would you mind rebasing this and also update the README that we require Python 3.9+?

@ogajduse ogajduse requested a review from ekohl November 28, 2025 14:40
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

@ekohl ekohl merged commit ab47bee into theforeman:master Nov 28, 2025
5 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove deprecated pkg_resources in order to support Python 3.12+

2 participants