-D malloc=jemalloc \
-D unit_tests=enabled
ninja -C build
+ pushd build/python
+ python -Pm build --wheel --no-isolation
+ popd
pushd manager
python -Pm build --wheel --no-isolation
popd
# remove modules with missing dependencies
rm "${pkgdir}/usr/lib/knot-resolver/kres_modules/etcd.lua"
+ # install knot-resolver metadata Python module
+ pushd build/python
+ python -Pm installer --destdir="$pkgdir" dist/*.whl
+ popd
+
# install knot-resolver-manager
pushd manager
python -Pm installer --destdir="$pkgdir" dist/*.whl
# package maintainers to append LDFLAGS
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
-export PYBUILD_NAME=knot_resolver_manager
-export PYBUILD_DESTDIR=debian/knot-resolver-manager/
+export PYKRES_NAME=knot_resolver
+export PYKRES_DEST=debian/knot-resolver-core/
+export KRES_MANAGER_NAME=knot_resolver_manager
+export KRES_MANAGER_DEST=debian/knot-resolver-manager/
# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
-Dc_args="$${CFLAGS}" \
-Dc_link_args="$${LDFLAGS}"
ninja -v -C build_deb
- dh_auto_build --buildsystem=pybuild --sourcedirectory manager
+ PYBUILD_NAME="$${PYKRES_NAME}" PYBUILD_DESTDIR="$${PYKRES_DEST}" \
+ dh_auto_build --buildsystem=pybuild --sourcedirectory build_deb/python
+ PYBUILD_NAME="$${KRES_MANAGER_NAME}" PYBUILD_DESTDIR="$${KRES_MANAGER_DEST}" \
+ dh_auto_build --buildsystem=pybuild --sourcedirectory manager
override_dh_auto_install:
DESTDIR="${PWD}/debian/tmp" ninja -v -C build_deb install
- dh_auto_install --buildsystem=pybuild --sourcedirectory manager
+ PYBUILD_NAME="$${PYKRES_NAME}" PYBUILD_DESTDIR="$${PYKRES_DEST}" \
+ dh_auto_install --buildsystem=pybuild --sourcedirectory build_deb/python
+ PYBUILD_NAME="$${KRES_MANAGER_NAME}" PYBUILD_DESTDIR="$${KRES_MANAGER_DEST}" \
+ dh_auto_install --buildsystem=pybuild --sourcedirectory manager
install -m 644 -D manager/etc/knot-resolver/config.yaml debian/tmp/etc/knot-resolver/config.yaml
install -m 644 -D manager/shell-completion/client.bash debian/tmp/usr/share/bash-completion/completions/kresctl
install -m 644 -D manager/shell-completion/client.fish debian/tmp/usr/share/fish/completions/kresctl.fish
%{NINJA} -v -C build_rpm
+pushd build_rpm/python
+%py3_build
+popd
+
pushd manager
%py3_build
popd
mv %{buildroot}/%{_datadir}/doc/%{name}/* %{buildroot}/%{_pkgdocdir}/
%endif
+pushd build_rpm/python
+%py3_install
+popd
+
# install knot-resolver-manager
pushd manager
%py3_install
%{_libdir}/knot-resolver/kres_modules/view.lua
%{_libdir}/knot-resolver/kres_modules/watchdog.lua
%{_libdir}/knot-resolver/kres_modules/workarounds.lua
+%{python3_sitelib}/knot_resolver.py
+%{python3_sitelib}/knot_resolver-*
+%if 0%{?suse_version}
+%pycache_only %{python3_sitelib}/__pycache__/knot_resolver.*
+%else
+%{python3_sitelib}/__pycache__/knot_resolver.*
+%endif
%{_mandir}/man8/kresd.8.gz
%{_mandir}/man8/kresctl.8.gz
+import importlib.util
import logging
from pathlib import Path
from typing import TYPE_CHECKING, Optional
-from knot_resolver_manager.utils import which
+# Install config is semi-optional - only needed to actually run Manager, but not
+# for its unit tests.
+if importlib.util.find_spec("knot_resolver"):
+ import knot_resolver # type: ignore[import-not-found]
+else:
+ knot_resolver = None
if TYPE_CHECKING:
from knot_resolver_manager.config_store import ConfigStore
def kresd_executable() -> Path:
- return which.which("kresd")
+ assert knot_resolver is not None
+ return knot_resolver.sbin_dir / "kresd"
def kres_gc_executable() -> Path:
- return which.which("kres-cache-gc")
+ assert knot_resolver is not None
+ return knot_resolver.sbin_dir / "kres-cache-gc"
def kresd_cache_dir(config: "KresConfig") -> Path:
meson manager/.build_kresd --prefix=$(realpath manager/.install_kresd) --default-library=static --buildtype=debug
ninja -C manager/.build_kresd
ninja install -C manager/.build_kresd
- export PATH="$(realpath manager/.install_kresd)/sbin:$PATH"
+ export PYTHONPATH="$(realpath manager/.build_kresd/python):${PYTHONPATH:-}"
popd
}
subdir('daemon')
subdir('modules')
subdir('manager')
+subdir('python')
subdir('utils')
if get_option('bench') == 'enabled'
subdir('bench')
--- /dev/null
+from pathlib import Path
+
+__version__ = "@kres_version@"
+
+sbin_dir = Path("@sbin_dir@")
+bin_dir = Path("@bin_dir@")
+etc_dir = Path("@etc_dir@")
+run_dir = Path("@run_dir@")
+lib_dir = Path("@lib_dir@")
+modules_dir = Path("@modules_dir@")
--- /dev/null
+# python
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+python_config = configuration_data()
+python_config.set('kres_version', meson.project_version())
+python_config.set('sbin_dir', sbin_dir)
+python_config.set('bin_dir', bin_dir)
+python_config.set('etc_dir', etc_dir)
+python_config.set('run_dir', run_dir)
+python_config.set('lib_dir', lib_dir)
+python_config.set('modules_dir', modules_dir)
+
+configure_file(
+ input: 'knot_resolver.py.in',
+ output: 'knot_resolver.py',
+ configuration: python_config,
+)
+
+configure_file(
+ input: 'setup.py.in',
+ output: 'setup.py',
+ configuration: python_config,
+)
--- /dev/null
+from setuptools import setup
+
+# TODO: Migrate this to a pyproject.toml once Debian 11 support is dropped.
+setup(
+ name="knot_resolver",
+ version="@kres_version@",
+ description="Knot Resolver helper data for Python",
+ author="Oto Šťáva",
+ author_email="oto.stava@nic.cz",
+ python_requires=">=3.8,<4.0",
+ py_modules=["knot_resolver"],
+)