diff --git a/Makefile b/Makefile index 83a5a4a..37f61d5 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,19 @@ -VERSION=1.0.2 +VERSION=$(shell python3 -c "import sys; sys.path.insert(0, '.'); from vppcfg._version import __version__; print(__version__)") VPPCFG:=vppcfg PYTHON?=python3 PIP?=pip PIP_DEPENDS=build yamale netaddr pylint -PIP_DEPENDS+=argparse pyyaml ipaddress black +PIP_DEPENDS+=argparse pyyaml ipaddress black build twine WIPE=dist $(VPPCFG).egg-info .pybuild debian/vppcfg debian/vppcfg.*.log WIPE+=debian/vppcfg.*.debhelper debian/.debhelper debian/files WIPE+=debian/vppcfg.substvars WHL_INSTALL=dist/$(VPPCFG)-$(VERSION)-py3-none-any.whl TESTS=tests.py +.PHONY: publish +publish: + $(PYTHON) -m twine upload dist/$(VPPCFG)*$(VERSION)* + .PHONY: build build: $(PYTHON) -m build diff --git a/README.md b/README.md index ba95b7a..f5659ac 100644 --- a/README.md +++ b/README.md @@ -5,34 +5,9 @@ reconciles a running [VPP](https://fd.io/) daemon with its configuration. It is re-entrant and stateless. The tool connects to the VPP API and creates/removes all of the configuration in a minimally intrusive way. -***NOTE*** This code is under development, and probably won't work well until this note is removed. -If you're interested in helping, reach out to <pim at ipng dot ch> to discuss options. - -## Building - -This program expects Python3 and PIP to be installed. It's known to work on Debian Bullseye and -Bookworm, as well as on Ubuntu Focal, Jammy and Noble. - +You can simply install this package from [[PyPi](https://pypi.org/project/vppcfg/)]: ``` - -## Start a Virtual Environment -python3 -m venv .venv -source .venv/bin/activate - -## Install python build dependencies -$ make install-deps - -## Ensure all unittests pass. -$ make test - -## Build vppcfg -$ make build - -## Exit the virtual environment -$ deactivate - -## Install the tool with PIP -$ make install +$ pip install [--break-system-packages] vppcfg ``` ## Running diff --git a/docs/user-guide.md b/docs/user-guide.md index 51612b6..026fe7b 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -5,6 +5,29 @@ safely to a running VPP dataplane. It contains a strict syntax and semantic vali and a path planner that brings the dataplane from any configuration state safely to any other configuration state, as defined by these YAML files. +## Building + +This program expects Python3 and PIP to be installed. It's known to work on Debian Bullseye, +Bookworm and Trixie, as well as on Ubuntu Focal, Jammy and Noble. + +Optionally, edit `vppcfg/_version.py` and bump the version number. Then: +``` +## Start a Virtual Environment +$ python3 -m venv .venv +$ source .venv/bin/activate + +$ make install-deps +$ make test +$ make build +$ deactivate + +## Publish requires a valid ~/.pypirc with an upload token. +$ make publish + +## Install the tool with PIP +$ make install +``` + ## User Guide ``` diff --git a/pyproject.toml b/pyproject.toml index 5e161e5..2ed659e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "vppcfg" -version = "1.0.2" +dynamic = ["version"] authors = [ { name="Pim van Pelt", email="pimg@ipng.ch" } ] @@ -21,3 +21,6 @@ Homepage = "https://git.ipng.ch/ipng/vppcfg" [build-system] requires = ["setuptools>=61.0.0"] build-backend = "setuptools.build_meta" + +[tool.setuptools.dynamic] +version = {attr = "vppcfg._version.__version__"} diff --git a/setup.py b/setup.py index e2f4035..7d64aba 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,16 @@ """vppcfg setuptools setup.py for pip and deb pkg installations""" +import os from setuptools import setup +# Read version from _version.py +version_file = os.path.join(os.path.dirname(__file__), "vppcfg", "_version.py") +with open(version_file) as f: + exec(f.read()) + setup( name="vppcfg", - version="1.0.2", + version=__version__, install_requires=[ "requests", 'importlib-metadata; python_version >= "3.8"', diff --git a/vppcfg/_version.py b/vppcfg/_version.py new file mode 100644 index 0000000..32a6f30 --- /dev/null +++ b/vppcfg/_version.py @@ -0,0 +1,3 @@ +"""Version information for vppcfg.""" + +__version__ = "1.0.3" diff --git a/vppcfg/vppcfg.py b/vppcfg/vppcfg.py index 9b960b2..4afa73d 100755 --- a/vppcfg/vppcfg.py +++ b/vppcfg/vppcfg.py @@ -24,9 +24,11 @@ import yaml # Ensure the paths are correct when we execute from the source tree try: from vppcfg.config import Validator + from vppcfg._version import __version__ except ModuleNotFoundError: sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) from vppcfg.config import Validator + from vppcfg._version import __version__ from vppcfg.vpp.reconciler import Reconciler from vppcfg.vpp.dumper import Dumper @@ -211,6 +213,7 @@ def main(): logging.basicConfig( format="[%(levelname)-8s] %(name)s.%(funcName)s: %(message)s", level=level ) + logging.info(f"vppcfg version {__version__}") opt_kwargs = {} if "vpp_json_dir" in args and args.vpp_json_dir is not None: