From 2755feab2a82c870156115307011f74a093b5192 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Fri, 11 Jul 2025 10:48:12 +0200 Subject: [PATCH 1/2] New Makefile targets --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 0c22a90f..e3044595 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ ARTIFACT_DIR := $(if $(ARTIFACT_DIR),$(ARTIFACT_DIR),tests/test_results) PATH_TO_PLANTUML := ~/bin +# Python registry to where the package should be uploaded +PYTHON_REGISTRY = pypi + run: ## Run the service locally uv run src/lightspeed_stack.py @@ -73,6 +76,12 @@ verify: $(MAKE) docstyle $(MAKE) check-types +distribution-archives: ## Generate distribution archives to be uploaded into Python registry + pdm run python -m build + +upload-distribution-archives: ## Upload distribution archives into Python registry + pdm run python -m twine upload --repository ${PYTHON_REGISTRY} dist/* + help: ## Show this help screen @echo 'Usage: make ... ' @echo '' From e4805cca245c72c4b0fa023bad57818b121a3ee0 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Fri, 11 Jul 2025 10:49:49 +0200 Subject: [PATCH 2/2] Howto prepare and publish Python package --- Makefile | 3 ++- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e3044595..93d57997 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ docstyle: ruff: uv run ruff check . --per-file-ignores=tests/*:S101 --per-file-ignores=scripts/*:S101 -verify: +verify: ## Run all linters $(MAKE) black $(MAKE) pylint $(MAKE) pyright @@ -77,6 +77,7 @@ verify: $(MAKE) check-types distribution-archives: ## Generate distribution archives to be uploaded into Python registry + rm -rf dist pdm run python -m build upload-distribution-archives: ## Upload distribution archives into Python registry diff --git a/README.md b/README.md index 33392beb..31832279 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,10 @@ Lightspeed Core Stack (LCS) is an AI powered assistant that provides answers to * [Endpoints](#endpoints) * [Readiness Endpoint](#readiness-endpoint) * [Liveness Endpoint](#liveness-endpoint) +* [Publish the service as Python package on PyPI](#publish-the-service-as-python-package-on-pypi) + * [Generate distribution archives to be uploaded into Python registry](#generate-distribution-archives-to-be-uploaded-into-python-registry) + * [Upload distribution archives into selected Python registry](#upload-distribution-archives-into-selected-python-registry) + * [Packages on PyPI and Test PyPI](#packages-on-pypi-and-test-pypi) * [Contributing](#contributing) * [License](#license) * [Additional tools](#additional-tools) @@ -162,6 +166,9 @@ format Format the code into unified format schema Generate OpenAPI schema file requirements.txt Generate requirements.txt file containing hashes for all non-devel packages shellcheck Run shellcheck +verify Run all linters +distribution-archives Generate distribution archives to be uploaded into Python registry +upload-distribution-archives Upload distribution archives into Python registry help Show this help screen ``` @@ -230,6 +237,51 @@ The liveness endpoint performs a basic health check to verify the service is ali } ``` +# Publish the service as Python package on PyPI + +To publish the service as an Python package on PyPI to be installable by anyone +(including Konflux hermetic builds), perform these two steps: + +## Generate distribution archives to be uploaded into Python registry + +``` +make distribution-archives +``` + +Please make sure that the archive was really built to avoid publishing older one. + +## Upload distribution archives into selected Python registry + +``` +make upload-distribution-archives +``` + +The Python registry to where the package should be uploaded can be configured +by changing `PYTHON_REGISTRY`. It is possible to select `pypi` or `testpypi`. + +You might have your API token stored in file `~/.pypirc`. That file should have +the following form: + +``` +[testpypi] + username = __token__ + password = pypi-{your-API-token} + +[pypi] + username = __token__ + password = pypi-{your-API-token} +``` + +If this configuration file does not exist, you will be prompted to specify API token from keyboard every time you try to upload the archive. + + + +## Packages on PyPI and Test PyPI + +* https://pypi.org/project/lightspeed-stack/ +* https://test.pypi.org/project/lightspeed-stack/0.1.0/ + + # Contributing * See [contributors](CONTRIBUTING.md) guide.