Move version to single place; Move 'build' to User Guide; Add 'make publish'

This commit is contained in:
Pim van Pelt
2025-11-09 04:37:38 +01:00
parent 67df74968b
commit 04258ad46d
7 changed files with 48 additions and 31 deletions

View File

@@ -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 VPPCFG:=vppcfg
PYTHON?=python3 PYTHON?=python3
PIP?=pip PIP?=pip
PIP_DEPENDS=build yamale netaddr pylint 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=dist $(VPPCFG).egg-info .pybuild debian/vppcfg debian/vppcfg.*.log
WIPE+=debian/vppcfg.*.debhelper debian/.debhelper debian/files WIPE+=debian/vppcfg.*.debhelper debian/.debhelper debian/files
WIPE+=debian/vppcfg.substvars WIPE+=debian/vppcfg.substvars
WHL_INSTALL=dist/$(VPPCFG)-$(VERSION)-py3-none-any.whl WHL_INSTALL=dist/$(VPPCFG)-$(VERSION)-py3-none-any.whl
TESTS=tests.py TESTS=tests.py
.PHONY: publish
publish:
$(PYTHON) -m twine upload dist/$(VPPCFG)*$(VERSION)*
.PHONY: build .PHONY: build
build: build:
$(PYTHON) -m build $(PYTHON) -m build

View File

@@ -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 re-entrant and stateless. The tool connects to the VPP API and creates/removes all of the
configuration in a minimally intrusive way. configuration in a minimally intrusive way.
***NOTE*** This code is under development, and probably won't work well until this note is removed. You can simply install this package from [[PyPi](https://pypi.org/project/vppcfg/)]:
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.
``` ```
$ pip install [--break-system-packages] 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
``` ```
## Running ## Running

View File

@@ -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 and a path planner that brings the dataplane from any configuration state safely to any
other configuration state, as defined by these YAML files. 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 ## User Guide
``` ```

View File

@@ -1,6 +1,6 @@
[project] [project]
name = "vppcfg" name = "vppcfg"
version = "1.0.2" dynamic = ["version"]
authors = [ authors = [
{ name="Pim van Pelt", email="pimg@ipng.ch" } { name="Pim van Pelt", email="pimg@ipng.ch" }
] ]
@@ -21,3 +21,6 @@ Homepage = "https://git.ipng.ch/ipng/vppcfg"
[build-system] [build-system]
requires = ["setuptools>=61.0.0"] requires = ["setuptools>=61.0.0"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[tool.setuptools.dynamic]
version = {attr = "vppcfg._version.__version__"}

View File

@@ -1,10 +1,16 @@
"""vppcfg setuptools setup.py for pip and deb pkg installations""" """vppcfg setuptools setup.py for pip and deb pkg installations"""
import os
from setuptools import setup 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( setup(
name="vppcfg", name="vppcfg",
version="1.0.2", version=__version__,
install_requires=[ install_requires=[
"requests", "requests",
'importlib-metadata; python_version >= "3.8"', 'importlib-metadata; python_version >= "3.8"',

3
vppcfg/_version.py Normal file
View File

@@ -0,0 +1,3 @@
"""Version information for vppcfg."""
__version__ = "1.0.3"

View File

@@ -24,9 +24,11 @@ import yaml
# Ensure the paths are correct when we execute from the source tree # Ensure the paths are correct when we execute from the source tree
try: try:
from vppcfg.config import Validator from vppcfg.config import Validator
from vppcfg._version import __version__
except ModuleNotFoundError: except ModuleNotFoundError:
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from vppcfg.config import Validator from vppcfg.config import Validator
from vppcfg._version import __version__
from vppcfg.vpp.reconciler import Reconciler from vppcfg.vpp.reconciler import Reconciler
from vppcfg.vpp.dumper import Dumper from vppcfg.vpp.dumper import Dumper
@@ -211,6 +213,7 @@ def main():
logging.basicConfig( logging.basicConfig(
format="[%(levelname)-8s] %(name)s.%(funcName)s: %(message)s", level=level format="[%(levelname)-8s] %(name)s.%(funcName)s: %(message)s", level=level
) )
logging.info(f"vppcfg version {__version__}")
opt_kwargs = {} opt_kwargs = {}
if "vpp_json_dir" in args and args.vpp_json_dir is not None: if "vpp_json_dir" in args and args.vpp_json_dir is not None: