Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -65,14 +68,21 @@ 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
$(MAKE) ruff
$(MAKE) docstyle
$(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
pdm run python -m twine upload --repository ${PYTHON_REGISTRY} dist/*

Comment on lines +83 to +85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fail fast when no artefacts exist

twine expands dist/*; when the glob is empty the shell passes the literal string and twine aborts. Guard against this:

 upload-distribution-archives: ## Upload distribution archives into Python registry
-	pdm run python -m twine upload --repository ${PYTHON_REGISTRY} dist/*
+	@if [ -z "$$(ls -1 dist 2>/dev/null)" ]; then \
+	  echo "No distribution files found in ./dist – did you run make distribution-archives?"; exit 1; \
+	fi
+	pdm run python -m twine upload --repository ${PYTHON_REGISTRY} dist/*
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
upload-distribution-archives: ## Upload distribution archives into Python registry
pdm run python -m twine upload --repository ${PYTHON_REGISTRY} dist/*
upload-distribution-archives: ## Upload distribution archives into Python registry
@if [ -z "$$(ls -1 dist 2>/dev/null)" ]; then \
echo "No distribution files found in ./dist – did you run make distribution-archives?"; exit 1; \
fi
pdm run python -m twine upload --repository ${PYTHON_REGISTRY} dist/*
🤖 Prompt for AI Agents
In the Makefile at lines 82 to 84, the upload-distribution-archives target runs
twine upload on dist/* without checking if any files exist, causing twine to
fail if the glob is empty. Modify the target to first check if any files exist
in the dist directory before running twine, and if none exist, exit with an
error or skip the upload to fail fast and avoid passing a literal glob pattern
to twine.

help: ## Show this help screen
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
Expand Down
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
```

Expand Down Expand Up @@ -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.
Expand Down