Skip to content

Commit 56c4edb

Browse files
committed
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.
1 parent 51c90db commit 56c4edb

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

setup.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from __future__ import print_function
2020

2121
import os
22+
import subprocess
2223
import sys
2324
from setuptools import setup, find_packages
2425
from setuptools.command.test import test as TestCommand
@@ -50,7 +51,22 @@
5051
if os.environ.get("TEST_JUJU3"):
5152
install_require.append('juju')
5253
else:
53-
install_require.append('juju<3.0.0')
54+
try:
55+
version = subprocess.check_output(['juju', '--version'],
56+
universal_newlines=True).strip()
57+
print('juju --version ->', version)
58+
if int(version[0]) >= 3:
59+
(major, minor) = version.split('.')[0:2]
60+
major = int(major)
61+
minor = int(minor)
62+
juju_ver_n = "%s.%s" % (major, minor)
63+
juju_ver_n1 = "%s.%s" % (major, minor + 1)
64+
install_require.append('juju>=%s,<%s' % (juju_ver_n,
65+
juju_ver_n1))
66+
else:
67+
install_require.append('juju<3.0.0')
68+
except (FileNotFoundError, subprocess.CalledProcessError):
69+
install_require.append('juju<3.0.0')
5470

5571
tests_require = [
5672
'tox >= 2.3.1',

0 commit comments

Comments
 (0)