From 813205505453e71c95bd7e824cf73d1070603188 Mon Sep 17 00:00:00 2001 From: Caner Derici Date: Wed, 14 Feb 2024 11:09:03 -0700 Subject: [PATCH 1/4] Add packaging to setup.py and docs/requirements (as well as tox setup) This fixes the 1st issue described in https://github.com/juju/python-libjuju/issues/1025#issuecomment-1944086744 --- docs/requirements.txt | 3 ++- setup.py | 1 + tox.ini | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index cb80e25f2..cf690bbf3 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -12,4 +12,5 @@ paramiko macaroonbakery toposort python-dateutil -kubernetes \ No newline at end of file +kubernetes +packaging \ No newline at end of file diff --git a/setup.py b/setup.py index 1a10222af..6c9165ffe 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ 'typing_inspect>=0.6.0', 'kubernetes>=12.0.1', 'hvac', + 'packaging', ], include_package_data=True, maintainer='Juju Ecosystem Engineering', diff --git a/tox.ini b/tox.ini index 132b804f1..69a9bceca 100644 --- a/tox.ini +++ b/tox.ini @@ -40,6 +40,7 @@ deps = websockets kubernetes hvac + packaging [testenv:docs] deps = From fe848808ea5e0115b772289901251287a578e645 Mon Sep 17 00:00:00 2001 From: Caner Derici Date: Wed, 14 Feb 2024 11:18:40 -0700 Subject: [PATCH 2/4] Move the version info into the source code instead of static VERSION file This fixes #1025 by removing the dependency to the external static VERSION file from within the project, allowing it to work in environments where pylibjuju is installed as a dependency library. Note that this changes the release process. In particular where we need to manually change the version information is moved into version.py (the release process document will be updated) This also removes the VERSION file. --- MANIFEST.in | 2 +- Makefile | 2 +- VERSION | 1 - juju/version.py | 13 +------------ setup.py | 5 +++-- 5 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 VERSION diff --git a/MANIFEST.in b/MANIFEST.in index c14d3fcbc..aaca35be5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include *.py CONTRIBUTORS LICENSE README.rst VERSION +include *.py CONTRIBUTORS LICENSE README.rst recursive-include juju *.py recursive-include examples *.py recursive-include docs *.rst diff --git a/Makefile b/Makefile index c2c25a304..5ecad85a3 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BIN := .tox/py3/bin PY := $(BIN)/python3 PIP := $(BIN)/pip3 -VERSION=$(shell cat VERSION) +VERSION := $(shell $(PY) -c "from version import CLIENT_VERSION; print(CLIENT_VERSION)") .PHONY: clean clean: diff --git a/VERSION b/VERSION deleted file mode 100644 index 7266d5bcd..000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.3.1.0 diff --git a/juju/version.py b/juju/version.py index e4289b46b..e9b48bf59 100644 --- a/juju/version.py +++ b/juju/version.py @@ -1,19 +1,8 @@ # Copyright 2023 Canonical Ltd. # Licensed under the Apache V2, see LICENCE file for details. -import pathlib -import re - LTS_RELEASES = ["jammy", "focal", "bionic", "xenial", "trusty", "precise"] DEFAULT_ARCHITECTURE = 'amd64' -# CLIENT_VERSION (that's read from the VERSION file) is the highest Juju server -# version that this client supports. -# Note that this is a ceiling. CLIENT_VERSION <= juju-controller-version works. -# For CLIENT_VERSION < juju-controller-version (strictly smaller), we emit a warning -# to update the client to the latest. -# However, for any CLIENT_VERSION > juju-controller-version, a "client incompatible -# with server" will be returned by the juju controller. -VERSION_FILE_PATH = pathlib.Path(__file__).parent.parent / 'VERSION' -CLIENT_VERSION = re.search(r'\d+\.\d+\.\d+', open(VERSION_FILE_PATH).read().strip()).group() +CLIENT_VERSION = "3.3.1.0" diff --git a/setup.py b/setup.py index 6c9165ffe..a2e8ee94b 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,8 @@ from setuptools import find_packages, setup +from juju.version import CLIENT_VERSION + here = Path(__file__).absolute().parent readme = here / 'docs' / 'readme.rst' changelog = here / 'docs' / 'changelog.rst' @@ -13,11 +15,10 @@ changelog.read_text() ) long_description_content_type = 'text/x-rst' -version = here / 'VERSION' setup( name='juju', - version=version.read_text().strip(), + version=CLIENT_VERSION.strip(), packages=find_packages( exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), package_data={'juju': ['py.typed']}, From c05cccbee056d8f6a3e8ffbf96107e30bccae8b8 Mon Sep 17 00:00:00 2001 From: Caner Derici Date: Wed, 14 Feb 2024 11:42:20 -0700 Subject: [PATCH 3/4] Fix python import command in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5ecad85a3..ffa0a3b88 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BIN := .tox/py3/bin PY := $(BIN)/python3 PIP := $(BIN)/pip3 -VERSION := $(shell $(PY) -c "from version import CLIENT_VERSION; print(CLIENT_VERSION)") +VERSION := $(shell $(PY) -c "from juju.version import CLIENT_VERSION; print(CLIENT_VERSION)") .PHONY: clean clean: From 3bdb58eab5aedc1e52449314026520b821cf25ed Mon Sep 17 00:00:00 2001 From: Caner Derici Date: Wed, 14 Feb 2024 11:49:40 -0700 Subject: [PATCH 4/4] Fix VERSION dependency in docs/conf for sphinx build --- docs/conf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 87c54f91b..417179595 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,13 +21,16 @@ from pathlib import Path here = Path(__file__).absolute().parent -version = (here.parent / 'VERSION').read_text().strip() + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('..')) +from juju.version import CLIENT_VERSION +version = CLIENT_VERSION + # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here.