Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import print_function

import os
import subprocess
import sys
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
Expand Down Expand Up @@ -50,7 +51,22 @@
if os.environ.get("TEST_JUJU3"):
install_require.append('juju')
else:
install_require.append('juju<3.0.0')
try:
version = subprocess.check_output(['juju', '--version'],
universal_newlines=True).strip()
print('juju --version ->', version)
if int(version.split(.)[0]) >= 3:
(major, minor) = version.split('.')[0:2]
Copy link
Contributor

Choose a reason for hiding this comment

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

This will fail whenever minor version cropped into double digit like 4.10

(major, minor, *_) = version.split('.')
juju_ver_n = "%s.%s" % (major, minor)
juju_ver_n1 = "%s.%s" % (major, int(minor) + 1)

Copy link
Member Author

@freyes freyes Mar 6, 2025

Choose a reason for hiding this comment

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

I don't think that will make that piece of code fail:

>>> version = "4.10.6-genericlinux-amd64"
>>> (major, minor) = version.split('.')[0:2]
>>> major
'4'
>>> minor
'10'

I did fix this line though -> https://github.com/openstack-charmers/zaza/compare/56c4edb7dee667ed7169f2ae4ed5688ec59afb4f..cb31096758c3f56aac13b06dafe93b3e942cd949

Copy link
Contributor

Choose a reason for hiding this comment

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

AAh such a silly mistake from me, you are right

Copy link
Contributor

Choose a reason for hiding this comment

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

missing '' for . in the new change

major = int(major)
minor = int(minor)
juju_ver_n = "%s.%s" % (major, minor)
juju_ver_n1 = "%s.%s" % (major, minor + 1)
install_require.append('juju>=%s,<%s' % (juju_ver_n,
Copy link
Contributor

Choose a reason for hiding this comment

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

I am sceptical about using juju>=juju_ver_n especially for cases of any new juju major series release (using terminology mentioned in [1]) like 3.x -> 3.y or 4.x -> 4,y
Since there is usually couple of days gap between Juju release and py-libjuju release.
Here is the past data for 3.6 release for juju and pylibjuju [2] [3]

We need to check with juju team if they really follows what they mentioned in documentation [1] to use juju>=version[0],<juju_ver_n1

[1] https://canonical-juju.readthedocs-hosted.com/en/latest/user/reference/juju/juju-cross-version-compatibility/#juju-cli-controllers-and-ref-agents
[2] https://github.com/juju/juju/releases/tag/v3.6.0
[3] https://github.com/juju/python-libjuju/releases/tag/3.6.0.0

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd expect libjuju to significantly lag behind juju for new major versions. But then, running e.g. libjuju 3.x with juju 4.x is likely to run into compatibility issues, so I'm thinking failing the run for major version mismatches might be a good decision anyway.

Wonder if the version parsing should be made more robust to better handle version string format changes or double-digit versions though.

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 pushed a new revision of that patch with a more reasonable parsing.

juju_ver_n1))
else:
install_require.append('juju<3.0.0')
except (FileNotFoundError, subprocess.CalledProcessError):
install_require.append('juju<3.0.0')

tests_require = [
'tox >= 2.3.1',
Expand Down
Loading