#
# spec file for package python-pycups
#
# 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
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%{?sle15_python_module_pythons}
Name:           python-pycups
Version:        2.0.4
Release:        2.6
Summary:        Python Bindings for CUPS
License:        GPL-2.0-or-later
Group:          Development/Libraries/Python
URL:            https://github.com/OpenPrinting/pycups
Source:         https://files.pythonhosted.org/packages/source/p/pycups/pycups-%{version}.tar.gz
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module wheel}
BuildRequires:  cups-devel
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
# need to avoid cycle as cups-devel wants us (boo#1172407)
#!BuildIgnore:  cups-rpm-helper
Obsoletes:      python-cups < %{version}
Provides:       python-cups = %{version}
%python_subpackages

%description
Python Bindings for CUPS, the Common Unix Printing System

%package -n cups-rpm-helper
Summary:        RPM macros for building cups drivers
Group:          Development/Libraries/Python
URL:            https://fedoraproject.org/wiki/Features/AutomaticPrintDriverInstallation
Requires:       python3-cups
Requires:       rpm-build
Supplements:    (rpm-build and cups-devel)

%description -n cups-rpm-helper
RPM helper scripts to create automatic "Provides:" tags for printer
driver RPMs.

%prep
%setup -q -n pycups-%{version}

%build
export CFLAGS="%{optflags}"
%pyproject_wheel

%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitearch}
make install-rpmhook DESTDIR=%{buildroot}
%python3_fix_shebang_path %{buildroot}%{_rpmconfigdir}/postscriptdriver.prov

%files %{python_files}
%doc NEWS README TODO
%license COPYING
%{python_sitearch}/cups*.so
%{python_sitearch}/pycups-%{version}.dist-info

%files -n cups-rpm-helper
%{_rpmconfigdir}/fileattrs/psdriver.attr
%{_rpmconfigdir}/postscriptdriver.prov

%changelog
* Thu Oct 31 2024 Dirk Müller <dmueller@suse.com>
- fix_shebang on the postscript driver rpmhook
* Sat Apr 20 2024 Dirk Müller <dmueller@suse.com>
- update to 2.0.4:
  * remove the install_requires from setup.py
  * removed shebang from example/cupstree.py
  * ignore driverless utilities for postscriptdriver tags
    creation (Fedora bug #1873385)
  * remove epydoc from Makefile (#27)
  * fix invalid delete of pointer (#11)
  * Makefile uses wrong Python (#32)
  * define PY_SSIZE_T_CLEAN in cupsipp.h - fixes traceback during
    IPPRequest.writeIO with Python 3.10
  * fix the test.py when there is no printer installed (#46)
  * Use PyObject_Call() instead of deprecated PyEval
* Wed Jan  3 2024 Dirk Müller <dmueller@suse.com>
- require setuptools
* Mon Aug 14 2023 Dirk Müller <dmueller@suse.com>
- build as wheel
* Wed Feb 16 2022 Dirk Müller <dmueller@suse.com>
- spec-cleaner
* Tue Feb 23 2021 Dirk Müller <dmueller@suse.com>
- update to 2.0.1:
  * pypi required .tar.gz
  * cups.require couldn't handle version bigger than 1
  * dropped macros for older CUPS < 2.0.0
  * dropped Python 2 support and its related macros
  * update license headers
  * thread did not hold GIL when called Py_XDECREF() from destroy_TLS(), causing SIGSEGV(Fedora bug #1816107)
  * fixed several compiler warnings
  * fix silent error on Connection.printFiles() (patch by Wilbert Berendsen)
* Sat Nov 21 2020 Benjamin Greiner <code@bnavigator.de>
- Let the python-rpm-macros take care of the correct python3
  provides for all python3 flavors gh#openSUSE/python-rpm-macros#66
* Mon Jul  6 2020 Ludwig Nussel <lnussel@suse.de>
- ignore build requirement of cups-rpm-helper to avoid cycle with cups-devel
  (boo#1172407))
* Wed Aug 28 2019 Martin Wilck <mwilck@suse.com>
- Package /usr/lib/rpm/postscriptdriver.prov again, in the
  new "cups-rpm-helper" subpackage (bsc#735865). The file hasn't
  been packaged any more after the switch from python-cups to
  python-pycups (sr#502741).
  * removed revert-postscriptdriver.prov-py3.patch
    (we use python3 now)
* Tue May 14 2019 svasudevan@suse.com
- Update to version 1.9.74
  * no changelog provided
* Mon Jun 19 2017 toddrme2178@gmail.com
- Provide python-cups/python3-cups
* Fri Jun  9 2017 toddrme2178@gmail.com
- Provide old packages.
- Minor singlespec cleanups.
* Mon Jun  5 2017 aloisio@gmx.com
- Update to 1.9.73
  * Fixed build for CUPS 1.6.3 by making several constants
    conditional on CUPS >= 1.7.
- Converted to single-spec
- Renamed package to python-pycups to follow naming guidelines
* Sun Mar  8 2015 benoit.monin@gmx.fr
- add patch revert-postscriptdriver.prov-py3.patch:
  revert back to python2 for postscriptdriver.prov script
* Thu Feb 26 2015 benoit.monin@gmx.fr
- update to version 1.9.72:
  * Removed private CANCEL_DOCUMENT, GET_DOCUMENT_ATTRIBUTES,
    GET_DOCUMENTS, DELETE_DOCUMENT, SET_DOCUMENT_ATTRIBUTES IPP
    operation constants
  * Fixed build for CUPS 1.4 by making several constants
    conditional on CUPS >= 1.5
- additional changes from version 1.9.71:
  * Fixes for cups.IPP_JOB_CANCELED, cups.IPP_ERROR_JOB_CANCELED,
    cups.IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED,
    cups.IPP_AUTHENTICATION_CANCELED,
    cups.IPP_STATUS_ERROR_CUPS_UPGRADE_REQUIRED, and
    cups.IPP_UPGRADE_REQUIRED
- additional changes from version 1.9.70:
  * cups.ippErrorString(). Fixed build with CUPS 1.5. New-style
    (CUPS 1.6) naming for HTTP status (cups.HTTP_STATUS_*), IPP
    orientation (cups.IPP_ORIENT_*), IPP status (cups.IPP_STATUS_*),
    and IPP I/O (cups.IPP_STATE_*) constants
- additional changes from version 1.9.69:
  * cups.IPPRequest.operation, cups.IPPRequest.state,
    cups.IPPRequest.statuscode, cups.ippOpString(), cups.IPP_OP_*,
    cups.IPPRequest.addSeparator(), cups.IPPRequest.add(),
    cups.IPPRequest.writeIO()
- additional changes from version 1.9.68:
  * Now builds against CUPS 2.0
  * The rpm provider script is now Python3
- additional changes from version 1.9.67:
  * Bindings for streaming API: cups.CUPS_FORMAT_* constants,
    cups.createJob(), cups.startDocument(), cups.writeRequestData(),
    cups.finishDocument()
- remove Changelog from doc: deleted by upstream
* Sat Jan 25 2014 os-dev@jacraig.com
- Update to 1.9.66:
  * Python3 compatibility
- Changes from 1.9.65:
  * cupsconnection.c (PyObject_from_attr_value): Fix getting of booleans.
  * cupsconnection.c (UTF8_from_PyObj): Propagate UTF-8 decoding errors.
  * cupsconnection.c: Don't just append printer name to base URI to get
    printer URI. Need to actually encode the name.
  * cupsconnection.c: Fixed documentation typo for Connection.getPPDs2.
* Sat Sep 14 2013 os-dev@jacraig.com
- Update to 1.9.63:
  * cups.IPPError tuple now contains the specific error string, if one is
    available.
- Changes from 1.9.62:
  * Define all constants regardless of which version of CUPS is built against.
- Added %%doc to build section with several doc files from the source.
* Mon Sep  3 2012 jengelh@inai.de
- Remove redundant %%clean section
- Make package compile on RH6-like systems by using standard
  python macros
* Wed Mar 28 2012 vuntz@opensuse.org
- Update to version 1.9.61:
  + Several bug fixes, including reference count fixes and better
    handling of failures from Py* functions.
* Tue Nov 15 2011 vuntz@opensuse.org
- Update to version 1.9.60:
  + Add new constants defined in cups 1.5.
* Tue Oct  4 2011 vuntz@opensuse.org
- Update to version 1.9.59:
  + Password callbacks can now return None to indicate they want to
    abort the current operation.
* Sat Jul 30 2011 vuntz@opensuse.org
- Update to version 1.9.58:
  + Add cups.Connection.adminExportSamba.
  + Build fixes.
* Thu Jun  9 2011 vuntz@opensuse.org
- Update to version 1.9.57:
  + Fixed rpm provides script for newer versions of rpm.
* Fri Jun  3 2011 vuntz@opensuse.org
- Update to version 1.9.56:
  + Fix build against CUPS < 1.4.
* Fri May 27 2011 vuntz@opensuse.org
- Update to version 1.9.55:
  + Add:
  - cups.IPP_QUALITY_DRAFT, cups.IPP_QUALITY_NORMAL,
    cups.IPP_QUALITY_HIGH
  - cups.IPP_PORTRAIT, cups.IPP_LANDSCAPE,
    cups.IPP_REVERSE_PORTRAIT, cups.IPP_REVERSE_LANDSCAPE
  - cups.IPP_RES_UNITS_CM, cups.IPP_RES_UNITS_INCH
  + Support for IPP_TAG_RESOLUTION as triplet (xres, yres, units).
- Changes from version 1.9.54:
  + Add rpm 4.9 hooks that can tag printer driver RPM packages with
    the MFG and MDL values for devices they support.
- Changes from version 1.9.53:
  + Fix a thread-local storage issue (rh#662805).
* Wed Nov 10 2010 vuntz@opensuse.org
- Update to version 1.9.52:
  + cups.Connection.getPPDs2(): New method, identical to getPPDs()
    but returning all attribute values as lists.
* Fri Sep  3 2010 vuntz@opensuse.org
- Fix build with python 2.7, by fixing a filename in the file list.
* Fri Aug  6 2010 vuntz@opensuse.org
- Update to version 1.9.51:
  + Fixed stack overflow (rh#584991).
  + Use strcpy instead of sprintf when no format required.
- Changes from version 1.9.50:
  + cups.Connection.getPPD3()
  + cups.Connection.getJobs() now takes optional
    requested_attributes argument.
  + cups.Connection.getPrinterAttributes(): member-names is now
    always a list.
  + cups.HTTP_NOT_MODIFIED constant.
  + cups.PPD_ORDER_ANY constant.
  + cups.PPD_ORDER_DOCUMENT constant.
  + cups.PPD_ORDER_EXIT constant.
  + cups.PPD_ORDER_JCL constant.
  + cups.PPD_ORDER_PAGE constant.
  + cups.PPD_ORDER_PROLOG constant.
  + cups.PPD.emitString() method.
  + cups.PPD.emit() method.
  + cups.PPD.emitAfterOrder() method.
  + cups.PPD.emitFd() method.
  + cups.PPD.emitJCL() method.
  + cups.PPD.emitJCLEnd() method.
* Mon Mar 22 2010 vuntz@opensuse.org
- Update to version 1.9.49:
  + Fix rh#567386.
* Sat Feb 13 2010 vuntz@opensuse.org
- Update to version 1.9.48:
  + cups.cancelJob()'s optional second argument is now a keyword.
- Changes from version 1.9.47:
  + cups.restartJob() now takes optional job_hold_until argument.
  + cups.cancelJob() now takes optional purge_job argument.
  + cups.setPasswordCB2() method.
  + cups.Connection.moveJob() method.
  + cups.IPPAttribute and cups.IPPRequest types.
  + IPP state constants.
  + cups.Connection.getDevices() now takes optional timeout
    argument.
- Changes from version 1.9.46:
  + cups.Connection.getDevices() now takes optional limit,
    exclude_schemes and include_schemes arguments.
  + cups.Connection.getPPDs() now takes optional limit,
    exclude_schemes, include_schemes, ppd_device_id, ppd_make,
    ppd_make_and_model, ppd_model_number, ppd_product,
    ppd_psversion, ppd_type and ppd_natural_language arguments.
  + cups.ppdSetConformance() method.
  + cups.PPD_CONFORM_RELAXED constant.
  + cups.PPD_CONFORM_STRICT constant.
  + cups.modelSort() now accepts Unicode strings.
- Changes from version 1.9.45:
  + cups.PPD.localizeIPPReason()
  + cups.PPD.localizeMarkerName()
- Changes from version 1.9.44:
  + Fix threading crashes.
- Changes from version 1.9.43:
  + Avoid crashing when CUPS-Get-Devices call asks for password.
  + Set printer-uri attribute in Connection.getJobs, not job-uri.
  + Fixed threading support.
* Mon Sep 15 2008 dmueller@suse.de
- fix requires (python-base is unversioned and does not exist)
* Wed Sep 10 2008 kssingvo@suse.de
- Update to version 1.9.42:
  * New function for extracting requested attributes from list
  * Support limit and first-job-id attributes
  * New parameter requested_attributes
  * Documentation fix for getJobAttributes
* Wed Aug 20 2008 kssingvo@suse.de
- Update to version 1.9.41:
  * Allow destination to be a file descriptor or a Python file
    object, and call cupsPutFd() in those cases
  * Fixed requested_attributes parameter
* Mon Jul 14 2008 dmueller@suse.de
- Initial package (1.9.40)