Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use looseversion in place of distutils #904

Open
wants to merge 1 commit into
base: stable/caracal
Choose a base branch
from

Conversation

freyes
Copy link
Collaborator

@freyes freyes commented Jun 26, 2024

(cherry picked from commit 012b2d6)

@freyes
Copy link
Collaborator Author

freyes commented Jun 26, 2024

Blocker for s390x validation

@freyes freyes requested review from ajkavanagh and wolsen June 26, 2024 15:13
@freyes freyes changed the base branch from master to stable/caracal June 26, 2024 15:29
@@ -12,3 +12,5 @@ Jinja2
netaddr

pbr!=2.1.0,>=2.0.0 # Apache-2.0

looseversion;python_version >= '3.12'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how does this work when being used in a classic charm?

Copy link
Contributor

Choose a reason for hiding this comment

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

Based on your comment above, it probably breaks unless the parent charm ensures that the package is installed.

try:
from distutils.version import LooseVersion
except ImportError:
from looseversion import LooseVersion
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

shouldn't this be more like:

try:
    from distutils.version import LooseVersion
except ImportError:
    try:
        # reactive charm path, where the venv already has this package
        from looseversion import LooseVersion
    except ImportError:
        # classic charm code path where python packages are installed via apt-get
        apt_install(['python3-looseversion'], fatal=True)
        from looseversion import LooseVersion

Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't like this pattern where charmhelpers runs apt_install; I'd much rather the parent charm resolved the dependencies and installed python3-looseversion where necessary; (which might be all of them in the future). It makes unit testing harder when apt_install() is at module load time.

try:
from distutils.version import LooseVersion
except ImportError:
from looseversion import LooseVersion
Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't like this pattern where charmhelpers runs apt_install; I'd much rather the parent charm resolved the dependencies and installed python3-looseversion where necessary; (which might be all of them in the future). It makes unit testing harder when apt_install() is at module load time.

@@ -12,3 +12,5 @@ Jinja2
netaddr

pbr!=2.1.0,>=2.0.0 # Apache-2.0

looseversion;python_version >= '3.12'
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on your comment above, it probably breaks unless the parent charm ensures that the package is installed.

@ajkavanagh
Copy link
Contributor

Holding off merging whilst @freyes conversation is concluded; there may be further changes needed to the original commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants