Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rpm package python bindings #380

Merged
merged 2 commits into from
Jul 10, 2023
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
6 changes: 3 additions & 3 deletions build-scripts/build-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ function python() {
## Set version and release
sed \
-e "s|@VERSION@|${VERSION}|g" \
< $PYTHON_BINDINGS_DIR"pyproject.toml.in" \
> $PYTHON_BINDINGS_DIR"pyproject.toml"
< $PYTHON_BINDINGS_DIR"setup.py.in" \
> $PYTHON_BINDINGS_DIR"setup.py"

python3 -m build --sdist --wheel --outdir dist/ $PYTHON_BINDINGS_DIR
python3 $PYTHON_BINDINGS_DIR"setup.py" bdist_wheel --dist-dir=dist/
}

echo "Building bindings $1"
Expand Down
21 changes: 21 additions & 0 deletions hirte.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,38 @@ This package contains the service controller command line tool.
%{_mandir}/man1/hirtectl.*


%package python3-pyhirte
Summary: Python bindings for Hirte
BuildRequires: python3-devel
BuildRequires: python3-setuptools
Requires: python3-dasbus

%description python3-pyhirte
pyhirte is a python module to access the public D-Bus API of hirte.
It contains typed python code that is auto-generated from hirte's
API description and manually written code to simplify recurring tasks.

%files python3-pyhirte
%license LICENSE
%doc README.md
%{python3_sitelib}/pyhirte-*.egg-info/
%{python3_sitelib}/pyhirte/


%prep
%autosetup
cp -r src/bindings/python/* ./


%build
%meson -Dapi_bus=system
%meson_build
%py3_build
engelmi marked this conversation as resolved.
Show resolved Hide resolved


%install
%meson_install
%py3_install
engelmi marked this conversation as resolved.
Show resolved Hide resolved


%check
Expand Down
16 changes: 10 additions & 6 deletions src/bindings/python/pyhirte/ext.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-3.0-or-later

from dasbus.connection import MessageBus
from typing import Callable, List, NamedTuple
from typing import Callable, List, NamedTuple, Tuple
from collections import namedtuple
from dasbus.loop import EventLoop
from dasbus.typing import UInt32, ObjPath
Expand Down Expand Up @@ -35,10 +35,13 @@
],
)

def unit_changes_from_tuples(tuples: List[Tuple[str, str, str]]) -> List[UnitChange]:
changes: List[UnitChange] = []
for change in tuples:
changes.append(UnitChange(change[0], change[1], change[2]))
return changes

class EnableUnitsResponse(NamedTuple):
carries_install_info: bool
changes: List[UnitChange]
EnableUnitsResponse = NamedTuple("EnableUnits", carries_install_info=bool, changes=List[UnitChange])


class Unit:
Expand Down Expand Up @@ -82,7 +85,8 @@ def reload_unit(self, unit: str) -> str:
return self._wait_for_complete(self.node.reload_unit, unit)

def enable_unit_files(self, files: List[str]) -> EnableUnitsResponse:
return self.node.enable_unit_files(files, False, False)
resp = self.node.enable_unit_files(files, False, False)
return EnableUnitsResponse(resp[0], unit_changes_from_tuples(resp[1]))

def disable_unit_files(self, files: List[str]) -> List[UnitChange]:
return self.node.disable_unit_files(files, False)
return unit_changes_from_tuples(self.node.disable_unit_files(files, False))
26 changes: 0 additions & 26 deletions src/bindings/python/pyproject.toml

This file was deleted.

26 changes: 0 additions & 26 deletions src/bindings/python/pyproject.toml.in

This file was deleted.

31 changes: 31 additions & 0 deletions src/bindings/python/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: GPL-2.0-or-later
from setuptools import setup, find_packages


def readme():
with open("README.md") as desc:
return desc.read()


setup(
name="pyhirte",
version="0.4.0",
description="Python bindings for hirte's D-Bus API",
long_description=readme(),
author="Hirte developers",
url="https://github.com/containers/hirte/",
license="LGPL-2.0-or-later",
install_requires=[
"dasbus",
],
packages=find_packages(),
include_package_data=True,
package_data={"hirte": ["py.typed"]},
zip_safe=True,
keywords=['hirte', 'python', 'D-Bus', 'systemd'],
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
],
python_requires='>=3.9',
)
31 changes: 31 additions & 0 deletions src/bindings/python/setup.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: GPL-2.0-or-later
from setuptools import setup, find_packages


def readme():
with open("README.md") as desc:
return desc.read()


setup(
name="pyhirte",
version="@VERSION@",
description="Python bindings for hirte's D-Bus API",
long_description=readme(),
author="Hirte developers",
url="https://github.com/containers/hirte/",
license="LGPL-2.0-or-later",
install_requires=[
"dasbus",
],
packages=find_packages(),
include_package_data=True,
package_data={"hirte": ["py.typed"]},
zip_safe=True,
keywords=['hirte', 'python', 'D-Bus', 'systemd'],
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
],
python_requires='>=3.9',
)