#5 Convert to pyproject macros
Merged a year ago by carlwgeorge. Opened a year ago by carlwgeorge.
rpms/ carlwgeorge/python-fasjson-client pyproject  into  rawhide

@@ -0,0 +1,29 @@ 

+ From ec53450377eaa765e84e87b3cbe6fe152b900aaf Mon Sep 17 00:00:00 2001

+ From: Carl George <carl@george.computer>

+ Date: Tue, 14 Feb 2023 16:27:37 -0600

+ Subject: [PATCH 1/2] Use poetry-core as the build backend

+ 

+ poetry-core has far fewer dependencies than poetry.  It's maintained by

+ the same people and poetry itself uses poetry-core.  Switching to this

+ makes packaging easier.  See rhbz#2049649 for more details.

+ 

+ Signed-off-by: Carl George <carl@george.computer>

+ ---

+  pyproject.toml | 4 ++--

+  1 file changed, 2 insertions(+), 2 deletions(-)

+ 

+ diff --git a/pyproject.toml b/pyproject.toml

+ index 3f3be6c..3aee2a6 100644

+ --- a/pyproject.toml

+ +++ b/pyproject.toml

+ @@ -95,5 +95,5 @@ authorized_licenses = [

+  ]

+  

+  [build-system]

+ -requires = ["poetry>=1.0.0"]

+ -build-backend = "poetry.masonry.api"

+ +requires = ["poetry-core"]

+ +build-backend = "poetry.core.masonry.api"

+ -- 

+ 2.39.1

+ 

@@ -0,0 +1,39 @@ 

+ From 7a611f4a140eb743281692cd296cb7256b4f2f7b Mon Sep 17 00:00:00 2001

+ From: Carl George <carl@george.computer>

+ Date: Wed, 15 Feb 2023 02:53:28 -0600

+ Subject: [PATCH 2/2] Restore compatibility with requests < 2.26.0

+ 

+ InvalidJSONError was added in requests 2.26.0.  RHEL 9 only has requests

+ 2.25.1.  If we can't import it, define it ourselves.

+ 

+ https://github.com/psf/requests/commit/05a1a21593c9c8e79393d35fae12c9c27a6f7605

+ 

+ Signed-off-by: Carl George <carl@george.computer>

+ ---

+  fasjson_client/client.py | 10 +++++++++-

+  1 file changed, 9 insertions(+), 1 deletion(-)

+ 

+ diff --git a/fasjson_client/client.py b/fasjson_client/client.py

+ index a5e16f1..15f76c1 100644

+ --- a/fasjson_client/client.py

+ +++ b/fasjson_client/client.py

+ @@ -1,7 +1,15 @@

+  import errno

+  from urllib.parse import urljoin, urlsplit

+  

+ -from requests.exceptions import InvalidJSONError, RequestException

+ +from requests.exceptions import RequestException

+ +# InvalidJSONError was added in requests 2.26.0.  RHEL 9 only has requests

+ +# 2.25.1.  If we can't import it, define it ourselves.

+ +try:

+ +    from requests.exceptions import InvalidJSONError

+ +except ImportError:

+ +    class InvalidJSONError(RequestException):

+ +        pass

+ +

+  from bravado import requests_client

+  from bravado.client import SwaggerClient, CallableOperation

+  from bravado.exception import HTTPError

+ -- 

+ 2.39.1

+ 

@@ -1,12 +0,0 @@ 

- diff --color -Nur fasjson-client-1.0.7.orig/pyproject.toml fasjson-client-1.0.7/pyproject.toml

- --- fasjson-client-1.0.7.orig/pyproject.toml	2022-05-11 03:11:52.100970700 -0700

- +++ fasjson-client-1.0.7/pyproject.toml	2022-09-29 15:33:12.712735777 -0700

- @@ -45,7 +45,7 @@

-  coverage = "^5.0.3 || ^6"

-  flake8 = "^3.7.9"

-  pytest = "^4.6.11 || ^5 || ^6 || ^7"

- -pytest-cov = "^2.8.1 || ^3"

- +pytest-cov = "^2.8.1"

-  pytest-mock = "^1.10.4 || ^2 || ^3"

-  requests-mock = "^1.7"

-  sphinx = "^4.2.0"

file modified
+49 -74
@@ -1,114 +1,89 @@ 

- %global pypi_name fasjson-client

- %global pypi_underscore_name %{lua:s = string.gsub(rpm.expand("%pypi_name"), "-", "_"); print(s)}

+ %bcond_without tests

  

- # EL8 doesn't know the __default_python3_pkgversion macro

- %if ! 0%{?__default_python3_pkgversion:1}

- %global __default_python3_pkgversion %(%__python3 -c 'import sys; print(".".join(str(d) for d in sys.version_info[:2]))' || echo 3)

- %endif

- 

- %define py3verdist() python%{__default_python3_pkgversion}dist(%1)

- 

- # Disable tests for now

- %bcond_with tests

- 

- Name:           python-%{pypi_name}

+ Name:           python-fasjson-client

  Version:        1.0.7

  Release:        %autorelease

  Summary:        An OpenAPI client for FASJSON

  

- License:        LGPLv3+

+ License:        LGPL-3.0-or-later

  URL:            https://github.com/fedora-infra/fasjson-client

- Source0:        %{pypi_source}

- Patch0:         fasjson-client-1.0.7-relax-pytest-cov-requirement.patch

+ Source:         %{pypi_source fasjson-client}

+ # https://github.com/fedora-infra/fasjson-client/pull/304

+ Patch:          0001-Use-poetry-core-as-the-build-backend.patch

+ # https://github.com/fedora-infra/fasjson-client/pull/305

+ Patch:          0002-Restore-compatibility-with-requests-2.26.0.patch

  BuildArch:      noarch

  

- # Split off fasjson-client into subpackage

- Obsoletes:      python3-fasjson-client < 0.1.1

- 

  BuildRequires:  python3-devel

- BuildRequires:  %{py3verdist setuptools}

- # runtime

- BuildRequires:  (%{py3verdist bravado} >= 10.6 with %{py3verdist bravado} < 12)

- BuildRequires:  (%{py3verdist click} >= 6.7 with %{py3verdist click} < 9)

- BuildRequires:  (%{py3verdist cryptography} >= 2.3)

- BuildRequires:  (%{py3verdist gssapi} >= 1.5.1 with %{py3verdist gssapi} < 2)

- BuildRequires:  (%{py3verdist requests} >= 2.20.0 with %{py3verdist requests} < 3)

- BuildRequires:  (%{py3verdist requests-gssapi} >= 1.2.1 with %{py3verdist requests-gssapi} < 2)

- %if %{with tests}

- BuildRequires:  (%{py3verdist toml} >= 0.10.1 with %{py3verdist toml} < 0.11)

- %else

- # EL <= 8

- BuildRequires:  (%{py3verdist toml} >= 0.10.0 with %{py3verdist toml} < 0.11)

- %endif

- # unit tests

  %if %{with tests}

- BuildRequires:  (%{py3verdist coverage} >= 5.0.3 with %{py3verdist coverage} < 7)

- BuildRequires:  (%{py3verdist pytest} >= 4.6.11 with %{py3verdist pytest} < 8)

- BuildRequires:  (%{py3verdist pytest-cov} >= 2.8.1)

- BuildRequires:  (%{py3verdist pytest-mock} >= 1.10.4 with %{py3verdist pytest-mock} < 4)

- BuildRequires:  (%{py3verdist requests-mock} >= 1.7 with %{py3verdist requests-mock} < 2)

+ BuildRequires:  python3-pytest

+ BuildRequires:  python3-pytest-mock

+ BuildRequires:  python3-requests-mock

  %endif

  

- %description

- A python client library for the FASJSON API.

+ %global _description %{expand:

+ A python client library for the FASJSON API.}

  

- %package -n     python3-%{pypi_name}

+ 

+ %description %_description

+ 

+ 

+ %package -n     python3-fasjson-client

  Summary:        %{summary}

- %{?python_provide:%python_provide python3-%{pypi_name}}

- 

- %if 0%{?rhel} && 0%{?rhel} < 9

- # Undefined deps of deps in EL8

- # (-> bravado-core, -> swagger-spec-validator) -> jsonschema

- Requires:       %{py3verdist attrs}

- Requires:       %{py3verdist idna}

- Requires:       %{py3verdist jsonpointer}

- Requires:       %{py3verdist rfc3987}

- Requires:       %{py3verdist setuptools}

- Requires:       %{py3verdist six}

- Requires:       %{py3verdist strict-rfc3339}

- Requires:       %{py3verdist webcolors}

- %endif

  

- %description -n python3-%{pypi_name}

- A python client library for the FASJSON API.

  

- %{?python_extras_subpkg:%python_extras_subpkg -n python3-%{pypi_name} -i %{python3_sitelib}/%{pypi_underscore_name}*.egg-info cli}

+ %description -n python3-fasjson-client %_description

+ 

+ 

+ %pyproject_extras_subpkg -n python3-fasjson-client cli

+ 

  

  %package -n     fasjson-client

  Summary:        %{summary} - CLI

- Requires:       python3-%{pypi_name}%{?python_extras_subpkg:+cli} = %{version}-%{release}

- Obsoletes:      python3-fasjson-client < 0.1.1

+ Requires:       python3-fasjson-client+cli = %{version}-%{release}

  

- %if 0%{?rhel} && 0%{?rhel} < 9

- Requires:       %{py3verdist click}

- Requires:       %{py3verdist cryptography}

- %endif

  

  %description -n fasjson-client

  A command line interface for the FASJSON API.

  

+ 

  %prep

- %autosetup -n %{pypi_name}-%{version}

+ %autosetup -n fasjson-client-%{version} -p 1

+ 

+ 

+ %generate_buildrequires

+ %pyproject_buildrequires -x cli

+ 

  

  %build

- %py3_build

+ %pyproject_wheel

+ 

  

  %install

- %py3_install

+ %pyproject_install

+ %pyproject_save_files fasjson_client

+ 

+ # extra files we don't want to package

+ rm %{buildroot}%{python3_sitelib}/{config.toml.example,tox.ini}

+ 

  

- %if %{with tests}

  %check

- %{__python3} -m pytest -v

+ %if %{with tests}

+ # upstream runs pytest from within tox, but that includes lots of coverage

+ # flags we don't want

+ %pytest -v fasjson_client/tests/unit

+ %else

+ # even when tests are skipped, make sure the module imports correctly

+ %pyproject_check_import -e 'fasjson_client.tests*'

  %endif

  

- %files -n python3-%{pypi_name}

+ 

+ %files -n python3-fasjson-client -f %{pyproject_files}

  %license LICENSE

  %doc README.md

- %{python3_sitelib}/fasjson_client

- %{python3_sitelib}/fasjson_client-%{version}-py%{python3_version}.egg-info

+ 

  

  %files -n fasjson-client

- %license LICENSE

  %{_bindir}/fasjson-client

  

  

  • Re-enable tests
  • Run import check when tests are disabled
  • Update license field to SPDX identifier
  • Remove duplicate license file

Let's hold off on merging this one. I'd like to also switch the build backend from poetry to poetry-core to facilitate building this in EPEL 9, where only the latter is available. I also need to see if I need to disable the tests in EPEL 9 or not.

rebased onto 7ff0263

a year ago

I think this will also need https://src.fedoraproject.org/rpms/python-swagger-spec-validator/pull-request/1 to be available first, otherwise importing swagger_spec_validator fails due to a missing setuptools dependency.

rebased onto bb4d82f

a year ago

Ok this should work now and also be valid for merging back to the epel9 branch, it just needs https://src.fedoraproject.org/rpms/python-swagger-spec-validator/pull-request/1 to be merged first.

Pull-Request has been merged by carlwgeorge

a year ago