Blob Blame History Raw
%global srcname SecretStorage

%global commit 3e5097c3c9a9c4fbfec74df4ceb0387308648525
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global date 20240314

Name:       python-%{srcname}
Version:    3.3.3^%{date}git%{shortcommit}
Release:    %autorelease
Summary:    Python bindings to FreeDesktop.org Secret Service API
URL:        https://github.com/mitya57/secretstorage
Source0:    https://github.com/mitya57/secretstorage/archive/%{commit}/secretstorage-%{shortcommit}.tar.gz
License:    BSD
BuildArch:  noarch

# Use the latest libsecret from upstream to run the tests as
# built libsecret does not ship those Python files, TODO make it so
Source1:    http://download.gnome.org/sources/libsecret/0.21/libsecret-0.21.4.tar.xz

BuildRequires:  /usr/bin/dbus-launch
BuildRequires:  /usr/bin/xvfb-run
BuildRequires:  python3-devel
BuildRequires:  python3-dbus
BuildRequires:  python3-gobject-base
BuildRequires:  python3-sphinx

%{?python_enable_dependency_generator}

%generate_buildrequires
%pyproject_buildrequires

%description
This module provides a way for securely storing passwords and other secrets.

It uses D-Bus Secret Service API that is supported by GNOME Keyring (>= 2.30)
and KSecretsService.

The main classes provided are secretstorage.Item, representing a secret item
(that has a label, a secret and some attributes) and secretstorage.Collection,
a place items are stored in.

SecretStorage supports most of the functions provided by Secret Service,
including creating and deleting items and collections, editing items, locking
and unlocking collections (asynchronous unlocking is also supported).


%package -n python3-secretstorage
Summary:        %{summary}

Provides:       python3-%{srcname} = %{version}-%{release}
Obsoletes:      python3-%{srcname} < 3

%{?python_provide:%python_provide python3-secretstorage}
%{?python_provide:%python_provide python3-%{srcname}}

%description -n python3-secretstorage
This module provides a way for securely storing passwords and other secrets.

It uses D-Bus Secret Service API that is supported by GNOME Keyring (>= 2.30)
and KSecretsService.

The main classes provided are secretstorage.Item, representing a secret item
(that has a label, a secret and some attributes) and secretstorage.Collection,
a place items are stored in.

SecretStorage supports most of the functions provided by Secret Service,
including creating and deleting items and collections, editing items, locking
and unlocking collections (asynchronous unlocking is also supported).

%package -n python3-secretstorage-doc
Summary:        SecretStorage documentation
Obsoletes:      python-%{srcname}-doc < 2.3.1-11
%{?python_provide:%python_provide python3-secretstorage-doc}

%description -n python3-secretstorage-doc
Documentation for SecretStorage.

%prep
%autosetup -n secretstorage-%{commit}
tar xf %{SOURCE1}

%build
%pyproject_wheel

# Build the documentation
sphinx-build-3 docs html

# Remove unnecessary files generated by python-sphinx
find build -name '.buildinfo' -delete -print
find build -name 'doctrees' -type d -print -exec rm -r '{}' +

%install
%pyproject_install
%pyproject_save_files -l secretstorage

%check
%pyproject_check_import
export PYTHONPATH=%{buildroot}%{python3_sitelib}
for MOCK in libsecret-0.21.4/libsecret/mock-service-{normal,only-plain,lock}.py; do
  xvfb-run -a dbus-launch --exit-with-session %{__python3} tests/run_tests.py ${MOCK}
done


%files -n python3-secretstorage -f %{pyproject_files}
%doc changelog README.rst

%files -n python3-secretstorage-doc
%doc      html/*

%changelog
%autochangelog