Skip to content

Commit 0b210a1

Browse files
authored
Merge pull request #1026 from cderici/resolve-build-problems-3.3.1.0
#1026 #### Description This solves 2 problems with the latest release (also described in [this comment](#1025 (comment))): 1. We depend on the `packaging` module, but didn't include it in the `setup.py` (because our testing and dev environments have tox installed and tox satisfies that requirement for itself, so we didn't notice). 2. We [accidentally depend](https://github.com/juju/python-libjuju/blob/905de781cb92041dcae158412861464d87a8bb77/juju/version.py#L18) on the static [VERSION ](https://github.com/juju/python-libjuju/blob/master/VERSION) file where we keep track of the version of pylibjuju. This change fixes #1025, solving these issues by: 1. Adding the `packaging` to the required modules. 2. Removing the file `VERSION`, and moving the static version information into the `version.py` module (just like in Juju) and use that information from there. The places that dynamically use that information (outside of the juju modules) are i) `setup.py` to get the version info into the build, ii) `Makefile` to use it in the release target iii) `docs/config.py` for building the docs. All of these spots are updated to use the info within the `version.py`. #### QA Steps We'll use the steps described in #1025. After pulling the branch in this PR; - Create a new virtual env: ``` python -m venv venv ``` - Activate it: ``` source venv/bin/activate ``` - Build pylibjuju at this spot: ``` python setup.py sdist ``` - The sdist build will create a `dist/juju-3.3.1.0.tar.gz`, so install that: ``` pip install dist/juju-3.3.1.0.tar.gz ``` - Now try to import a `Controller`. ``` python3 -c "from juju.controller import Controller" ``` Without the (1)st change in this PR, this command would result in: ``` ModuleNotFoundError: No module named 'packaging' ``` And without the (2)nd change, this command would error with ``` FileNotFoundError: [Errno 2] No such file or directory: '......./venv/lib/python3.10/site-packages/VERSION' ``` But with this change, we shouldn't see either (or any other) error. I.e., the command should succeed with no problems. #### Notes & Discussion Note that this changes the release process. In particular where we need to manually change the version information is moved into the `version.py` module (the release process document will be updated right before this PR is merged). Moreover, we need to make a patch release (`3.3.1.1`) after this for these changes to take effect (i.e. for pylibjuju to be usable in the environments where it's installed as a dependency). JUJU-5484
2 parents 905de78 + 3bdb58e commit 0b210a1

8 files changed

Lines changed: 14 additions & 19 deletions

File tree

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include *.py CONTRIBUTORS LICENSE README.rst VERSION
1+
include *.py CONTRIBUTORS LICENSE README.rst
22
recursive-include juju *.py
33
recursive-include examples *.py
44
recursive-include docs *.rst

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
BIN := .tox/py3/bin
22
PY := $(BIN)/python3
33
PIP := $(BIN)/pip3
4-
VERSION=$(shell cat VERSION)
4+
VERSION := $(shell $(PY) -c "from juju.version import CLIENT_VERSION; print(CLIENT_VERSION)")
55

66
.PHONY: clean
77
clean:

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121
from pathlib import Path
2222

2323
here = Path(__file__).absolute().parent
24-
version = (here.parent / 'VERSION').read_text().strip()
24+
2525

2626
# If extensions (or modules to document with autodoc) are in another directory,
2727
# add these directories to sys.path here. If the directory is relative to the
2828
# documentation root, use os.path.abspath to make it absolute, like shown here.
2929
sys.path.insert(0, os.path.abspath('..'))
3030

31+
from juju.version import CLIENT_VERSION
32+
version = CLIENT_VERSION
33+
3134
# -- General configuration ------------------------------------------------
3235

3336
# If your documentation needs a minimal Sphinx version, state it here.

docs/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ paramiko
1212
macaroonbakery
1313
toposort
1414
python-dateutil
15-
kubernetes
15+
kubernetes
16+
packaging

juju/version.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
# Copyright 2023 Canonical Ltd.
22
# Licensed under the Apache V2, see LICENCE file for details.
33

4-
import pathlib
5-
import re
6-
74
LTS_RELEASES = ["jammy", "focal", "bionic", "xenial", "trusty", "precise"]
85

96
DEFAULT_ARCHITECTURE = 'amd64'
107

11-
# CLIENT_VERSION (that's read from the VERSION file) is the highest Juju server
12-
# version that this client supports.
13-
# Note that this is a ceiling. CLIENT_VERSION <= juju-controller-version works.
14-
# For CLIENT_VERSION < juju-controller-version (strictly smaller), we emit a warning
15-
# to update the client to the latest.
16-
# However, for any CLIENT_VERSION > juju-controller-version, a "client incompatible
17-
# with server" will be returned by the juju controller.
18-
VERSION_FILE_PATH = pathlib.Path(__file__).parent.parent / 'VERSION'
19-
CLIENT_VERSION = re.search(r'\d+\.\d+\.\d+', open(VERSION_FILE_PATH).read().strip()).group()
8+
CLIENT_VERSION = "3.3.1.0"

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from setuptools import find_packages, setup
77

8+
from juju.version import CLIENT_VERSION
9+
810
here = Path(__file__).absolute().parent
911
readme = here / 'docs' / 'readme.rst'
1012
changelog = here / 'docs' / 'changelog.rst'
@@ -13,11 +15,10 @@
1315
changelog.read_text()
1416
)
1517
long_description_content_type = 'text/x-rst'
16-
version = here / 'VERSION'
1718

1819
setup(
1920
name='juju',
20-
version=version.read_text().strip(),
21+
version=CLIENT_VERSION.strip(),
2122
packages=find_packages(
2223
exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
2324
package_data={'juju': ['py.typed']},
@@ -32,6 +33,7 @@
3233
'typing_inspect>=0.6.0',
3334
'kubernetes>=12.0.1',
3435
'hvac',
36+
'packaging',
3537
],
3638
include_package_data=True,
3739
maintainer='Juju Ecosystem Engineering',

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ deps =
4040
websockets
4141
kubernetes
4242
hvac
43+
packaging
4344

4445
[testenv:docs]
4546
deps =

0 commit comments

Comments
 (0)