From cb31096758c3f56aac13b06dafe93b3e942cd949 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Tue, 4 Mar 2025 15:54:34 -0300 Subject: [PATCH] Align the python-libjuju dependency with the installed juju version python-libjuju is released with a tight dependency with the underlying juju version, so when using juju-3.4 , python-libjuju-3.4 is needed, any mismatch will result in failures later. This patch will still honor the semantic of TEST_JUJU3. --- setup.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 91739dda..5da50722 100644 --- a/setup.py +++ b/setup.py @@ -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 @@ -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] + 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, + 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',