Skip to content

Commit c7883e3

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 c7883e3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

setup.py

Lines changed: 14 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,19 @@
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+
juju_ver_n = version[0:3]
60+
juju_ver_n1 = "%s.%s" % (version[0], int(version[2]) + 1)
61+
install_require.append('juju>=%s,<%s' % (juju_ver_n,
62+
juju_ver_n1))
63+
else:
64+
install_require.append('juju<3.0.0')
65+
except (FileNotFoundError, subprocess.CalledProcessError):
66+
install_require.append('juju<3.0.0')
5467

5568
tests_require = [
5669
'tox >= 2.3.1',

0 commit comments

Comments
 (0)