Skip to content
Snippets Groups Projects
Commit b44f3be1 authored by Vaclav Sraier's avatar Vaclav Sraier Committed by Vaclav Sraier
Browse files

configured build system for native C extensions

parent bc3f97d9
No related branches found
No related tags found
1 merge request!1280supervisord improvements
......@@ -15,3 +15,4 @@ docs/_build/*
*junit.xml
.build_kresd/
.install_kresd/
build/
\ No newline at end of file
from typing import Any, Dict
from setuptools import Extension
def build(setup_kwargs: Dict[Any, Any]) -> None:
setup_kwargs.update(
{
"ext_modules": [
Extension(
name="knot_resolver_manager.kresd_controller.supervisord.plugin.notify",
sources=["knot_resolver_manager/kresd_controller/supervisord/plugin/notifymodule.c"],
),
]
}
)
# !!! Do not use this in production !!!!!
# This makefile is a hack to simplify initial development
#
# Use variant of this instead:
# https://docs.python.org/3/extending/building.html#building
notify.so: notify.o
gcc -shared notify.o -L/usr/local/lib -o notify.so
notify.o: notifymodule.c
gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/include/python3.10 -c notifymodule.c -o notify.o
\ No newline at end of file
......@@ -7,6 +7,12 @@ authors = [
"Aleš Mrázek <ales.mrazek@nic.cz>"
]
# See currently open issue about building C extensions here:
# https://github.com/python-poetry/poetry/issues/2740
[tool.poetry.build]
script = "build.py"
generate-setup-file = true
[tool.poetry.dependencies]
python = "^3.6.8"
aiohttp = "^3.6.12"
......@@ -50,7 +56,7 @@ run-debug = { cmd = "scripts/run-debug", help = "Run the manager under debugger"
docs = { cmd = "scripts/docs", help = "Create HTML documentation" }
test = { shell = "env PYTHONPATH=. pytest --junitxml=unit.junit.xml --cov=knot_resolver_manager --show-capture=all tests/unit/", help = "Run tests" }
check = { cmd = "scripts/codecheck", help = "Run static code analysis" }
format = { shell = "black knot_resolver_manager/ tests/ scripts/; isort .", help = "Run code formatter" }
format = { shell = "black knot_resolver_manager/ tests/ scripts/ build.py; isort .", help = "Run code formatter" }
fixdeps = { shell = "poetry install; npm install; npm update", help = "Install/update dependencies according to configuration files"}
commit = { shell = "scripts/commit", help = "Invoke every single check before commiting" }
container = { cmd = "scripts/container.py", help = "Manage containers" }
......@@ -73,6 +79,9 @@ configure-vscode = {cmd = "scripts/configure-vscode", help = "Create VSCode conf
line-length = 120
target_version = ['py38']
include = '\.py$'
exclude = '''
^/setup.py # Poetry generates it and we want to keep it unchanged
'''
[tool.isort]
line_length=120 # corresponds to -w flag
......@@ -80,6 +89,10 @@ multi_line_output=3 # corresponds to -m flag
include_trailing_comma=true # corresponds to -tc flag
skip_glob = '^((?!py$).)*$' # isort all Python files
float_to_top=true
profile = "black"
skip = [
"setup.py", # Poetry generates it and we want to keep it unchanged
]
[tool.tox]
legacy_tox_ini = """
......
......@@ -18,6 +18,22 @@ ninja install -C manager/.build_kresd
export PATH="$(realpath manager/.install_kresd)/sbin:$PATH"
cd manager
echo
echo Building Knot Resolver Manager native extensions
echo ------------------------------------------------
poetry build
# copy native modules from build directory to source directory
shopt -s globstar
shopt -s nullglob
for d in build/lib*; do
for f in "$d/"**/*.so; do
cp -v "$f" ${f#"$d/"}
done
done
shopt -u globstar
shopt -u nullglob
echo
echo Knot Manager API is accessible on http://localhost:5000
echo -------------------------------------------------------
......
......@@ -43,7 +43,8 @@ setup_kwargs = {
'install_requires': install_requires,
'python_requires': '>=3.6.8,<4.0.0',
}
from build import *
build(setup_kwargs)
setup(**setup_kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment