From 06f6e4839b203e7e445a7982e327970b6b447253 Mon Sep 17 00:00:00 2001 From: Jason Shepherd Date: Mon, 27 May 2024 13:50:23 +1000 Subject: [PATCH 1/2] remove deprecated dependency on distutils --- osidb_bindings/helpers.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/osidb_bindings/helpers.py b/osidb_bindings/helpers.py index aef5b09..23b4a1e 100644 --- a/osidb_bindings/helpers.py +++ b/osidb_bindings/helpers.py @@ -2,12 +2,33 @@ osidb-registry-bindings helpers """ import json -from distutils.util import strtobool from os import getenv from typing import Any, Union from .exceptions import OSIDBBindingsException +_MAP = { + "y": True, + "yes": True, + "t": True, + "true": True, + "on": True, + "1": True, + "n": False, + "no": False, + "f": False, + "false": False, + "off": False, + "0": False, +} + + +def strtobool(value): + try: + return _MAP[str(value).lower()] + except KeyError: + raise ValueError('"{}" is not a valid bool value'.format(value)) + def get_env( key: str, From 9c6ba74aaa6d43a388a42ea0657717393b48222c Mon Sep 17 00:00:00 2001 From: Jason Shepherd Date: Wed, 22 May 2024 15:54:26 +1000 Subject: [PATCH 2/2] build srpm --- .copr/Makefile | 9 +++++++ DEVELOP.md | 4 +++ TUTORIAL.md | 6 +++++ osidb_bindings.spec | 58 +++++++++++++++++++++++++++++++++++++++++++ scripts/build_srpm.sh | 10 ++++++++ scripts/helpers.sh | 3 +++ setup.py | 2 +- 7 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .copr/Makefile create mode 100644 osidb_bindings.spec create mode 100755 scripts/build_srpm.sh diff --git a/.copr/Makefile b/.copr/Makefile new file mode 100644 index 0000000..a2c2213 --- /dev/null +++ b/.copr/Makefile @@ -0,0 +1,9 @@ +srpm: + @echo ">Installing SRPM dependencies" + dnf install -y python3-setuptools rpmdevtools + + @echo ">Setting up rpm build environment" + rpmdev-setuptree -d + + @echo ">Building SRPM" + scripts/build_srpm.sh $(outdir) diff --git a/DEVELOP.md b/DEVELOP.md index 7294ef0..bbab1e2 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -280,3 +280,7 @@ When new major/minor OSIDB version is being released, we can do a pre-release of * Tag and release needs be in format x.x.x to comply with [semantic versioning](#version-policy) * Tag needs to point to the latest commit * Release description should include the newest section of the [CHANGELOG.md](CHANGELOG.md) + +### Fedora COPR RPM build + +There is an RPM repository setup in [Fedora COPR](https://copr.fedorainfracloud.org/coprs/jazinner/osidb-bindings/). RPMs are build automatically based on git tag events. When a git tag is added to the repository Fedora COPR runs the .copr/Makefile which builds an RPM for the target distributions (currently Fedora 39 and 40). \ No newline at end of file diff --git a/TUTORIAL.md b/TUTORIAL.md index 3f3138a..fe3e956 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -15,6 +15,12 @@ You can install the bindings via Python 3 pip: ``` pip install osidb-bindings ``` +* RPM from [Fedora Copr](https://copr.fedorainfracloud.org/coprs/jazinner/osidb-bindings/) + ``` + dnf copr enable jazinner/osidb-bindings + dnf install osidb_bindings + ``` + * directly from the [GitHub](https://github.com/RedHatProductSecurity/osidb-bindings) repository (will install the version from master branch) ``` diff --git a/osidb_bindings.spec b/osidb_bindings.spec new file mode 100644 index 0000000..a7aa840 --- /dev/null +++ b/osidb_bindings.spec @@ -0,0 +1,58 @@ +%define name osidb_bindings +%define version 3.7.0 +%define release 0%{?dist} + +Name: %{name} +Version: %{version} +Release: %{release} +Summary: OSIDB Python Bindings + +URL: https://github.com/RedHatProductSecurity/osdib-bindings +Source0: %{name}-%{version}.tar.gz +License: MIT +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot + +BuildArch: noarch +AutoReqProv: no +BuildRequires: python3-devel +BuildRequires: python3-wheel +BuildRequires: tox +BuildRequires: python3-tox-current-env +Requires: python3-aiohttp +Requires: python3-attrs +Requires: python3-dateutil +Requires: python3-requests +Requires: python3-requests-gssapi + + +%description +Python Client bindings for OSIDB + +%prep +%autosetup -n %{name}-%{version} -p1 + +%generate_buildrequires + +%pyproject_buildrequires + + +%build +%pyproject_wheel + +%install +%pyproject_install + +%pyproject_save_files %{name} + +%check +%tox + +%files -n %{name} -f %{pyproject_files} +%ghost %{python3_sitelib}/tests/* + +%changelog +* Wed May 22 2024 Jason - 3.6.0 +- RPM packing for osidb_bindings added + + + diff --git a/scripts/build_srpm.sh b/scripts/build_srpm.sh new file mode 100755 index 0000000..cd20f3e --- /dev/null +++ b/scripts/build_srpm.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +mkdir dist +python3 setup.py clean sdist +cp dist/* ~/build/SOURCES/ +rpmbuild --undefine dist -bs "osidb_bindings.spec" --clean +cp ~/build/SRPMS/* "$1" + diff --git a/scripts/helpers.sh b/scripts/helpers.sh index d31fe6e..826b4e0 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -56,6 +56,9 @@ update_version() { echo "Updating the CHANGELOG.md to ${version}" sed -i 's/^## Unreleased.*/## Unreleased\n\n## ['"${version}"'] - '$(date '+%Y-%m-%d')'/' CHANGELOG.md + echo "Updating the osidb_bindings.spec to ${version}" + sed -i 's/^%define version [0-9]*\.[0-9]*\.[0-9]*/%define version '${version}'/g' osidb_bindings.spec + echo } diff --git a/setup.py b/setup.py index 63f7740..7b9d34b 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ long_description = fh.read() setup( - name="osidb-bindings", + name="osidb_bindings", version="3.7.0", author="Jakub Frejlach, Red Hat Product Security", author_email="jfrejlac@redhat.com",