Blob Blame History Raw
%bcond docs 1
%bcond tests 1

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

Name:       python-SecretStorage
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-3-Clause
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:  python3-devel

# Test dependencies
%if %{with tests}
BuildRequires:  /usr/bin/dbus-launch
BuildRequires:  /usr/bin/xvfb-run
BuildRequires:  python3-dbus
BuildRequires:  python3-gobject-base
%endif

# For building the documentation
%if %{with docs}
BuildRequires:  python3-sphinx
%endif


%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}

%py_provides    python3-SecretStorage

%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

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

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

%build
%pyproject_wheel

# Build the documentation
%if %{with docs}
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 '{}' +
%endif

%install
%pyproject_install
%pyproject_save_files -l secretstorage

%check
%pyproject_check_import
%if %{with tests}
export %{py3_test_envvars}
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
%endif

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

%if %{with docs}
%files -n python3-secretstorage-doc
%doc      html/*
%endif

%changelog
%autochangelog