Skip to content

Commit

Permalink
chore: migrate to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaakola-aiven committed Sep 13, 2024
1 parent 69d26f8 commit 494c650
Show file tree
Hide file tree
Showing 21 changed files with 394 additions and 415 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
*

# Include source directories and files required for building.
!.git
!karapace
!requirements/*.txt
!setup.py
!version.py
!README.rst
!pyproject.toml
!container/start.sh
!container/healthcheck.py

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
labels: |
[email protected]
org.opencontainers.image.url=https://karapace.io
org.opencontainers.image.documentation=https://github.com/aiven/karapace/
org.opencontainers.image.documentation=https://github.com/Aiven-Open/karapace/
org.opencontainers.image.vendor=Aiven
org.opencontainers.image.licenses=Apache-2.0
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
python-version: '3.12'
- name: Install libsnappy-dev
run: sudo apt install libsnappy-dev
- run: pip install -r requirements/requirements.txt -r requirements/requirements-typing.txt
- name: Install requirements and typing requirements
run: pip install -r requirements/requirements.txt -r requirements/requirements-typing.txt
- run: make karapace/version.py
- run: mypy
1 change: 1 addition & 0 deletions .github/workflows/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
requirements.txt
- name: Install libsnappy-dev
run: sudo apt install libsnappy-dev
- name: Install requirements
- run: pip install -r requirements/requirements.txt
# Compare with latest release when running on main.
- run: make schema against=$(git describe --abbrev=0 --tags)
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ Contributions are very welcome on Karapace. When contributing please keep this i

There is very little you need to get started coding for Karapace:

- Use [one of the supported python versions](https://github.com/aiven/karapace/blob/master/setup.py)
documented in the `setup.py` classifiers.
- Use [one of the supported python versions](https://github.com/Aiven-Open/karapace/blob/master/pyproject.toml)
documented in the `project:requires-python`.
- Create [a virtual environment](https://docs.python.org/3/tutorial/venv.html) and install the dev dependencies in it:

```python
python -m venv <path_to_venv>
source <path_to_venv>/bin/activate
pip install -r ./requirements/requirements-dev.txt
pip install -e .
pip install .
pip install .[dev] .[typing]
```

## Website
Expand Down Expand Up @@ -75,7 +75,7 @@ The code is statically checked and formatted using [a few tools][requirements-de
To run these automatically on each commit please enable the [pre-commit](https://pre-commit.com)
hooks.

[requirements-dev]: https://github.com/aiven/karapace/blob/master/requirements/requirements-dev.txt
[requirements-dev]: https://github.com/Aiven-Open/karapace/blob/master/requirements/requirements-dev.txt

## Manual testing

Expand All @@ -90,7 +90,7 @@ karapace karapace.config.json
### Configuration

To see descriptions of configuration keys see our
[README](https://github.com/aiven/karapace#configuration-keys).
[README](https://github.com/Aiven-Open/karapace#configuration-keys).

Each configuration key can be overridden with an environment variable prefixed with `KARAPACE_`,
exception being configuration keys that actually start with the `karapace` string. For example, to
Expand Down
24 changes: 16 additions & 8 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ endif

PYTHON_VERSION ?= 3.8

define PIN_VERSIONS_COMMAND
pip install pip-tools && \
python -m piptools compile -o /karapace/requirements/requirements.txt /karapace/pyproject.toml && \
python -m piptools compile --extra dev -o /karapace/requirements/requirements-dev.txt /karapace/pyproject.toml && \
python -m piptools compile --extra typing -o /karapace/requirements/requirements-typing.txt /karapace/pyproject.toml
endef


export PATH := $(VENV_DIR)/bin:$(PATH)
export PS4 := \e[0m\e[32m==> \e[0m
export LC_ALL := C
Expand Down Expand Up @@ -40,12 +48,10 @@ venv/.deps: requirements/requirements-dev.txt requirements/requirements.txt | ve
source ./bin/get-protoc
source ./bin/get-snappy
set -x
$(PIP) install --use-pep517 -r '$(<)'
$(PIP) install --use-pep517 .
$(PIP) install --use-pep517 . .[dev]
$(PIP) check
touch '$(@)'


karapace/version.py:
$(PYTHON) version.py

Expand Down Expand Up @@ -84,12 +90,14 @@ cleanest: cleaner
.PHONY: requirements
requirements: export CUSTOM_COMPILE_COMMAND='make requirements'
requirements:
pip install --upgrade pip setuptools pip-tools
cd requirements && pip-compile --upgrade --resolver=backtracking requirements.in -o requirements.txt
cd requirements && pip-compile --upgrade --resolver=backtracking requirements-dev.in -o requirements-dev.txt
cd requirements && pip-compile --upgrade --resolver=backtracking requirements-typing.in -o requirements-typing.txt
$(PIP) install --upgrade pip setuptools pip-tools
$(PIP) install . .[dev] .[typing]

.PHONY: schema
schema: against := origin/main
schema:
python3 -m karapace.backup.backends.v3.schema_tool --against=$(against)
$(PYTHON) -m karapace.backup.backends.v3.schema_tool --against=$(against)

.PHONY: pin-requirements
pin-requirements:
docker run -it -v .:/karapace --security-opt label=disable python:$(PYTHON_VERSION)-bullseye /bin/bash -c "$(PIN_VERSIONS_COMMAND)"
4 changes: 1 addition & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ include karapace.unit
include tests/*.py
include scripts/*
include README.rst
include version.py
include setup.py
include setup.cfg
include pyproject.toml
include LICENSE
include MANIFEST.in

Expand Down
19 changes: 8 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Karapace

``karapace``. Your Apache Kafka® essentials in one tool.

An `open-source <https://github.com/aiven/karapace/blob/master/LICENSE>`_ implementation
An `open-source <https://github.com/Aiven-Open/karapace/blob/master/LICENSE>`_ implementation
of `Kafka REST <https://docs.confluent.io/platform/current/kafka-rest/index.html#features>`_ and
`Schema Registry <https://docs.confluent.io/platform/current/schema-registry/index.html>`_.

Expand Down Expand Up @@ -81,14 +81,14 @@ override the ``bootstrap_uri`` config value, one would use the environment varia
``KARAPACE_BOOTSTRAP_URI``. Here_ you can find an example configuration file to give you an idea
what you need to change.

.. _`Here`: https://github.com/aiven/karapace/blob/master/karapace.config.json
.. _`Here`: https://github.com/Aiven-Open/karapace/blob/master/karapace.config.json

Source install
--------------

Alternatively you can do a source install using::

python setup.py install
pip install .

Quickstart
==========
Expand Down Expand Up @@ -657,7 +657,7 @@ If you don't need or want to have the Karapace images around you can now proceed
Installed from Sources
----------------------

If you installed Karapace from the sources via ``python setup.py install``, it can be uninstalled with the following ``pip`` command::
Karapace is installed ``pip install .``, it can be uninstalled with the following ``pip`` command::

pip uninstall karapace

Expand Down Expand Up @@ -701,11 +701,8 @@ targets that correctly clean the ``runtime`` directory without deleting it, but
keep this in mind whenever you are not using ``make`` (e.g. running tests from
your IDE).

Note that the pre-commit checks are currently not working with the default
Python version. This is because isort dropped Python 3.7 support. You have to
use at least Python 3.8 for the pre-commit checks. Use ``pipx`` or ``brew`` or
… to install pre-commit and use the global installation, there is also no
dependency on it.
Use ``pipx`` or ``brew`` or to install pre-commit and use the global installation,
there is also no dependency on it.

License
=======
Expand All @@ -720,7 +717,7 @@ Contact
=======

Bug reports and patches are very welcome, please post them as GitHub issues
and pull requests at https://github.com/aiven/karapace . Any possible
and pull requests at https://github.com/Aiven-Open/karapace . Any possible
vulnerabilities or other serious issues should be reported directly to the
maintainers <[email protected]>.

Expand All @@ -741,6 +738,6 @@ to them for pioneering the concept.
.. _`Aiven`: https://aiven.io/

Recent contributors are listed on the GitHub project page,
https://github.com/aiven/karapace/graphs/contributors
https://github.com/Aiven-OPen/karapace/graphs/contributors

Copyright ⓒ 2021 Aiven Ltd.
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,6 @@ ignore_missing_imports = True

[mypy-networkx.*]
ignore_missing_imports = True

[mypy-systemd.*]
ignore_missing_imports = True
109 changes: 109 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,112 @@
[build-system]
requires = ["setuptools > 64", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "karapace"
requires-python = ">= 3.8"
dynamic = ["version"]
readme = "README.rst"
license = {file = "LICENSE"}
dependencies = [
"accept-types < 1",
"aiohttp < 4",
"aiokafka == 0.10.0",
"cachetools == 5.3.3",
"confluent-kafka == 2.4.0",
"isodate < 1",
"jsonschema < 5",
"lz4",
"networkx < 4",
"protobuf < 4",
"pyjwt >= 2.4.0 , < 3",
"python-dateutil < 3",
"python-snappy",
"rich ~= 13.7.1",
"tenacity < 10",
"typing-extensions",
"ujson < 6",
"watchfiles < 1",
"xxhash ~= 3.3",
"zstandard",
"prometheus-client == 0.20.0",

# Patched dependencies
#
# Note: It is important to use commits to reference patched dependencies. This
# has two advantages:
# - Reproducible builds
# - The contents of the file change, which invalidates the existing docker
# images and forces a new image generation.
#
"avro @ https://github.com/aiven/avro/archive/5a82d57f2a650fd87c819a30e433f1abb2c76ca2.tar.gz#subdirectory=lang/py",
]

classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Database :: Database Engines/Servers",
"Topic :: Software Development :: Libraries",
]

[project.scripts]
karapace = "karapace.karapace_all:main"
karapace_schema_backup = "karapace.backup.cli:main"
karapace_mkpasswd = "karapace.auth:main"

[project.urls]
Homepage = "https://karapace.io"
Repository = "https://github.com/Aiven-Open/karapace/"
Issues = "https://github.com/Aiven-Open/karapace/issues"

[project.optional-dependencies]
sentry-sdk = ["sentry-sdk>=1.6.0"]
ujson = ["ujson"]
systemd-logging = ["systemd-python==235"]
dev = [
# Developer QoL
"pdbpp",

# testing
"filelock",
"hypothesis",
"psutil",
"pytest",
"pytest-cov",
"pytest-random-order",
"pytest-timeout",
"pytest-xdist[psutil]",
"requests",

# performance test
"locust",

# Sentry SDK
"sentry-sdk"
]
typing = [
"mypy",
"sentry-sdk",
"types-cachetools",
"types-jsonschema",
"types-protobuf < 4"
]


[tool.setuptools.packages.find]
include = ["karapace"]

[tool.setuptools_scm]
version_file = "karapace/version.py"

[tool.black]
target-version = ["py38"]
line-length = 125
22 changes: 0 additions & 22 deletions requirements/requirements-dev.in

This file was deleted.

Loading

0 comments on commit 494c650

Please sign in to comment.