Accepting request 1228151 from devel:languages:python

- Stop skipping on Python versions.
- Add patch use-importlib.patch:
  * Use importlib to support Python 3.12+
- Switch to autosetup and pyproject macros.

OBS-URL: https://build.opensuse.org/request/show/1228151
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-sat-stac?expand=0&rev=5
This commit is contained in:
Ana Guerrero 2024-12-04 14:27:29 +00:00 committed by Git OBS Bridge
commit 8580235515
3 changed files with 52 additions and 7 deletions

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Wed Dec 4 06:20:59 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Stop skipping on Python versions.
- Add patch use-importlib.patch:
* Use importlib to support Python 3.12+
- Switch to autosetup and pyproject macros.
-------------------------------------------------------------------
Tue Oct 29 08:13:50 UTC 2024 - Dirk Müller <dmueller@suse.com>

View File

@ -17,9 +17,6 @@
%{?sle15_python_module_pythons}
# from imp import load_source
%global skip_python312 1
%global skip_python313 1
%define packagename sat-stac
Name: python-sat-stac
Version: 0.4.1
@ -28,9 +25,13 @@ Summary: A library for reading and working with Spatio-Temporal Asset Cat
License: MIT
URL: https://github.com/sat-utils/sat-stac
Source: https://files.pythonhosted.org/packages/source/s/sat-stac/sat-stac-%{version}.tar.gz
# PATCH-FIX-UPSTREAM gh#sat-utils/sat-stac#75
Patch0: use-importlib.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module python-dateutil >= 2.7.5}
BuildRequires: %{python_module requests >= 2.19.1}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-python-dateutil >= 2.7.5
@ -46,13 +47,13 @@ and downloading publicly available satellite imagery using a conformant
API such as sat-api.
%prep
%setup -q -n %{packagename}-%{version}
%autosetup -p1 -n %{packagename}-%{version}
%build
%python_build
%pyproject_wheel
%install
%python_install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
for p in %{packagename} ; do
%python_clone -a %{buildroot}%{_bindir}/$p
@ -71,7 +72,7 @@ done
%files %{python_files}
%doc README.md
%python_alternative %{_bindir}/%{packagename}
%{python_sitelib}/*egg-info
%{python_sitelib}/satstac
%{python_sitelib}/sat_stac-%{version}.dist-info
%changelog

36
use-importlib.patch Normal file
View File

@ -0,0 +1,36 @@
From 31dfa7c419c3bae3bab090631cb6a13486e0ffb9 Mon Sep 17 00:00:00 2001
From: Victor Engmark <victor@engmark.name>
Date: Fri, 6 Sep 2024 09:00:10 +1200
Subject: [PATCH] fix: Use new importlib
As recommended by <https://docs.python.org/3/whatsnew/3.12.html#imp>.
---
setup.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index b2bd3d7..692d0cd 100755
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,20 @@
#!/usr/bin/env python
+import importlib.util
+import importlib.machinery
from setuptools import setup, find_packages
-from imp import load_source
from os import path
import io
+def load_source(modname, filename):
+ loader = importlib.machinery.SourceFileLoader(modname, filename)
+ spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
+ module = importlib.util.module_from_spec(spec)
+ # The module is always executed and not cached in sys.modules.
+ # Uncomment the following line to cache the module.
+ # sys.modules[module.__name__] = module
+ loader.exec_module(module)
+ return module
+
__version__ = load_source('satstac.version', 'satstac/version.py').__version__
here = path.abspath(path.dirname(__file__))