From 660f210446eb1c4e0614e4597cfbb93d14d7120dee779cf12ac964014b243d1a Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Thu, 11 Jan 2024 02:07:49 +0000 Subject: [PATCH 1/2] - Switch to pyproject macro. - Stop using greedy globs in %files. - Actually run fdupes. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-http-parser?expand=0&rev=35 --- python-http-parser.changes | 7 +++++++ python-http-parser.spec | 15 +++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/python-http-parser.changes b/python-http-parser.changes index 93d0803..3a8cd45 100644 --- a/python-http-parser.changes +++ b/python-http-parser.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Jan 11 02:06:44 UTC 2024 - Steve Kowalik + +- Switch to pyproject macro. +- Stop using greedy globs in %files. +- Actually run fdupes. + ------------------------------------------------------------------- Wed Jun 17 04:47:07 UTC 2020 - Steve Kowalik diff --git a/python-http-parser.spec b/python-http-parser.spec index a614717..641b10b 100644 --- a/python-http-parser.spec +++ b/python-http-parser.spec @@ -1,7 +1,7 @@ # # spec file for package python-http-parser # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,18 +16,19 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-http-parser Version: 0.9.0 Release: 0 Summary: HTTP Request/Response Parser for Python in C License: MIT -Group: Development/Languages/Python URL: https://github.com/benoitc/http-parser/ Source: https://files.pythonhosted.org/packages/source/h/http-parser/http-parser-%{version}.tar.gz BuildRequires: %{python_module Cython} BuildRequires: %{python_module devel} +BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +BuildRequires: fdupes BuildRequires: python-rpm-macros %python_subpackages @@ -42,16 +43,18 @@ http-parser from Ryan Dahl. # fix wrongly generated cyx files find . -name '*.pyx' -exec cython {} \; export CFLAGS="%{optflags} -fno-strict-aliasing" -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install # Remove exec bits from example scripts chmod a-x examples/* +%python_expand %fdupes %{buildroot}%{$python_sitearch} %files %{python_files} %license LICENSE %doc NOTICE README.rst examples -%{python_sitearch}/* +%{python_sitearch}/http_parser +%{python_sitearch}/http_parser-%{version}.dist-info %changelog From 34bbb070e7aeff59952ebac98e0b6d8fff82cbd5fd611a78fd557ab14e40d03b Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Thu, 11 Jan 2024 03:17:22 +0000 Subject: [PATCH 2/2] - Switch to autosetup and pyproject macros. - Add patch remove-imp-module.patch: * Use importlib, not imp. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-http-parser?expand=0&rev=36 --- python-http-parser.changes | 6 +++-- python-http-parser.spec | 4 +++- remove-imp-module.patch | 45 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 remove-imp-module.patch diff --git a/python-http-parser.changes b/python-http-parser.changes index 3a8cd45..9c2b9ac 100644 --- a/python-http-parser.changes +++ b/python-http-parser.changes @@ -1,9 +1,11 @@ ------------------------------------------------------------------- -Thu Jan 11 02:06:44 UTC 2024 - Steve Kowalik +Thu Jan 11 03:17:05 UTC 2024 - Steve Kowalik -- Switch to pyproject macro. +- Switch to autosetup and pyproject macros. - Stop using greedy globs in %files. - Actually run fdupes. +- Add patch remove-imp-module.patch: + * Use importlib, not imp. ------------------------------------------------------------------- Wed Jun 17 04:47:07 UTC 2020 - Steve Kowalik diff --git a/python-http-parser.spec b/python-http-parser.spec index 641b10b..83d675b 100644 --- a/python-http-parser.spec +++ b/python-http-parser.spec @@ -23,6 +23,8 @@ Summary: HTTP Request/Response Parser for Python in C License: MIT URL: https://github.com/benoitc/http-parser/ Source: https://files.pythonhosted.org/packages/source/h/http-parser/http-parser-%{version}.tar.gz +# PATCH-FIX-UPSTREAM gh#benoitc/http-parser#101 +Patch0: remove-imp-module.patch BuildRequires: %{python_module Cython} BuildRequires: %{python_module devel} BuildRequires: %{python_module pip} @@ -37,7 +39,7 @@ HTTP request/response parser for Python in C, based on http-parser from Ryan Dahl. %prep -%setup -q -n http-parser-%{version} +%autosetup -p1 -n http-parser-%{version} %build # fix wrongly generated cyx files diff --git a/remove-imp-module.patch b/remove-imp-module.patch new file mode 100644 index 0000000..1de113b --- /dev/null +++ b/remove-imp-module.patch @@ -0,0 +1,45 @@ +From 4d4984ce129253f9de475bfd3c683301c916e8b1 Mon Sep 17 00:00:00 2001 +From: Steve Kowalik +Date: Thu, 11 Jan 2024 14:14:07 +1100 +Subject: [PATCH] Switch to importlib in setup.py + +The imp module has been deprecated and was removed in Python 3.12. +Switch to using importlib functions to load the module, rather than +imp.load_source(). + +Fixes #99 +--- + setup.py | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/setup.py b/setup.py +index 5c3f768..04de1d0 100644 +--- a/setup.py ++++ b/setup.py +@@ -9,7 +9,8 @@ + from distutils.command.build_ext import build_ext + from distutils.command.sdist import sdist as _sdist + import glob +-from imp import load_source ++import importlib.machinery ++import importlib.util + import io + import os + import shutil +@@ -28,6 +29,16 @@ + # find the compiler + ext_errors += (IOError,) + ++ ++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) ++ loader.exec_module(module) ++ return module ++ ++ + http_parser = load_source("http_parser", os.path.join("http_parser", + "__init__.py")) +