%global python3_pkgversion 3.11
# Avoid dependency loops:
#     fsspec -> distributed -> dask -> fsspec
#     fsspec -> gcsfs -> fsspec
#     fsspec -> zarr -> fsspec
%bcond_without bootstrap 1

%global srcname fsspec

Name:           python-%{srcname}
Version:        2024.3.1
%global tag     2024.3.1
Release:        2.ac16.py3.11%{?dist}
Summary:        Specification for Pythonic file system interfaces

License:        BSD-3-Clause
URL:            https://github.com/fsspec/filesystem_spec
Source0:        %{url}/archive/%{tag}/%{srcname}-%{tag}.tar.gz

BuildArch:      noarch

BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}dist(pytest)
BuildRequires:  python%{python3_pkgversion}dist(pytest-asyncio)
BuildRequires:  python%{python3_pkgversion}dist(pytest-mock)
BuildRequires:  python%{python3_pkgversion}dist(pytest-vcr)
BuildRequires:  python%{python3_pkgversion}dist(cloudpickle)
%if %{without bootstrap}
#BuildRequires:  python3dist(distributed) -- not yet available in Fedora
BuildRequires:  python%{python3_pkgversion}dist(zarr)
%endif
BuildRequires:  python%{python3_pkgversion}dist(jinja2)
BuildRequires:  python%{python3_pkgversion}dist(lz4)
BuildRequires:  python%{python3_pkgversion}dist(numpy)
BuildRequires:  python%{python3_pkgversion}dist(python-snappy)
BuildRequires:  python%{python3_pkgversion}dist(zstandard)
BuildRequires:  git-core

%global _description %{expand:
Filesystem Spec is a project to unify various projects and classes to work with
remote filesystems and file-system-like abstractions using a standard pythonic
interface.}

%description %{_description}


%package -n     python%{python3_pkgversion}-%{srcname}
Summary:        %{summary}

%description -n python%{python3_pkgversion}-%{srcname} %{_description}


%prep
%autosetup -n filesystem_spec-%{tag} -p1

%generate_buildrequires
# Skipped extras:
# - (when bootstrapping) gcs and gs: Don't have gcsfs
# - abfs and adl: Don't have adlfs
# - arrow and hdfs: Don't have pyarrow
# - dask: Don't have distributed
# - dropbox: Don't have dropboxdrivefs
# - fuse: Won't work in a build since it requires the kernel module to be loaded.
# - gui: Don't have panel
# - oci: Don't have ocifs
# - s3: Don't have s3fs
# - sftp and ssh: Requires a running SSH server in a container
# - smb: Requires a running SMB server in a container.
%pyproject_buildrequires -x %{?!with_bootstrap:gcs,gs,}git,github,http,libarchive,tqdm

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files %{srcname}

%check

for b in $(find %{buildroot}%{_bindir}/ -type f) ; do mv "$b" $(sed -re "s|(.*)$|\1-%{python3_pkgversion}|"<<<"$b"); done
for m in $(find %{buildroot}%{_mandir}/ -type f) ; do mv "$m" $(sed -re "s|(.*).([1-8])(.*)$|\1-%{python3_pkgversion}.\2\3|"<<<"$m"); done
for m in $(find %{buildroot}%{_datadir}/locale/* -type f) ; do mv "$m" $(sed -re "s|(.*).mo$|\1-%{python3_pkgversion}.mo|"<<<"$m"); done
for l in $(find %{buildroot}/usr/lib64/lib* -type f -o -type l) ; do mv "$l" $(sed -re "s|(.*).so(.*)$|\1-py%{python3_pkgversion}.so\2|"<<<"$l"); done
for p in $(find %{buildroot}/usr/lib64/pkgconfig/* -type f) ; do mv "$p" $(sed -re "s|(.*).pc$|\1-py%{python3_pkgversion}.pc|"<<<"$p"); done
%files -n python%{python3_pkgversion}-%{srcname} -f %{pyproject_files}
%doc README.md
%license LICENSE

%changelog
* Sun May 12 2024 Ding-Yi Chen <dingyichen@gmail.com> -  2024.3.1-2.ac16.py3.11
 - Cut corner packaging