New Upstream Release - cairocffi

Ready changes

Summary

Merged new upstream version: 1.5.1 (was: 1.4.0).

Diff

diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index d3fd51f..b31c0a1 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -9,19 +9,10 @@ jobs:
       fail-fast: false
       matrix:
         os: [ubuntu-latest, macos-latest, windows-latest]
-        python-version: [3.7, 3.8, 3.9, pypy3]
-        exclude:
-          # pypy3 on GitHub is advertised as Python 3.6
-          - os: ubuntu-latest
-            python-version: pypy3
-          # No wheel for numpy
-          - os: macos-latest
-            python-version: pypy3
-          - os: windows-latest
-            python-version: pypy3
+        python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
     steps:
-      - uses: actions/checkout@v2
-      - uses: actions/setup-python@v2
+      - uses: actions/checkout@v3
+      - uses: actions/setup-python@v4
         with:
           python-version: ${{ matrix.python-version }}
       - name: xvfb daemon (Ubuntu)
@@ -29,9 +20,7 @@ jobs:
         run: sudo /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16
       - name: Pip installs (Ubuntu)
         if: matrix.os == 'ubuntu-latest'
-        run: |
-          python -m pip install -e .[test,xcb]
-          python -m pip install -e .[test]
+        run: python -m pip install -e .[xcb]
       - name: Install cairo gdk-pixbuf (MacOS)
         if: matrix.os == 'macos-latest'
         run: |
@@ -45,11 +34,8 @@ jobs:
           xcopy "C:\msys64\mingw64\share\fonts\TTF" "C:\Users\runneradmin\.fonts" /e /i
           echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH
           rm C:\msys64\mingw64\bin\python.exe
-      - name: Force numpy install binary (Pypy3)
-        if: matrix.python-version == 'pypy3'
-        run: python -m pip install --only-binary ":all:" numpy
       - name: Install tests’ requirements
-        run: python -m pip install .[test]
+        run: python -m pip install -e .[test]
       - name: Launch tests
         run: |
           python cairocffi/ffi_build.py
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..0183c35
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1 @@
+include utils/* docs/*
\ No newline at end of file
diff --git a/NEWS.rst b/NEWS.rst
index f204cb3..fd33aac 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,6 +2,27 @@ cairocffi changelog
 -------------------
 
 
+Version 1.5.1
+.............
+
+Released on 2023-04-15
+
+* `#212 <https://github.com/Kozea/cairocffi/issues/212>`_:
+  Bring back XCB support during wheel generation
+
+
+Version 1.5.0
+.............
+
+Released on 2023-03-17
+
+* `#106 <https://github.com/Kozea/cairocffi/issues/106>`_,
+  `#200 <https://github.com/Kozea/cairocffi/issues/200>`_:
+  Fallback to manual PNG file creation on hardened systems
+* `#210 <https://github.com/Kozea/cairocffi/pull/210>`_:
+  Use pyproject.toml for packaging and remove other useless files
+
+
 Version 1.4.0
 .............
 
diff --git a/README.rst b/README.rst
index 52fa910..9df6d80 100644
--- a/README.rst
+++ b/README.rst
@@ -14,7 +14,7 @@ to decode various image formats for use in cairo.
 * Free software: BSD license
 * For Python 3.7+, tested on CPython and PyPy
 * Documentation: https://cairocffi.readthedocs.io
-* Changelog: https://github.com/Kozea/cairocffi/releases
+* Changelog: https://cairocffi.readthedocs.io/en/stable/changelog.html
 * Code, issues, tests: https://github.com/Kozea/cairocffi
 * Code of conduct: https://www.courtbouillon.org/code-of-conduct
 * Professional support: https://www.courtbouillon.org
diff --git a/cairocffi/VERSION b/cairocffi/VERSION
deleted file mode 100644
index 88c5fb8..0000000
--- a/cairocffi/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-1.4.0
diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
index ca4529c..1852bb3 100644
--- a/cairocffi/__init__.py
+++ b/cairocffi/__init__.py
@@ -11,12 +11,11 @@
 
 import sys
 from ctypes.util import find_library
-from pathlib import Path
 
 from . import constants
 from ._generated.ffi import ffi
 
-VERSION = __version__ = (Path(__file__).parent / 'VERSION').read_text().strip()
+VERSION = __version__ = '1.5.1'
 # supported version of cairo, used to be pycairo version too:
 version = '1.17.2'
 version_info = (1, 17, 2)
diff --git a/cairocffi/constants.py b/cairocffi/constants.py
index b8e63bf..a045d36 100644
--- a/cairocffi/constants.py
+++ b/cairocffi/constants.py
@@ -1,8 +1,8 @@
 # *** Do not edit this file ***
 # Generated by utils/mkconstants.py
+# flake8: noqa
 
 TAG_DEST = b"cairo.dest"
-
 TAG_LINK = b"Link"
 
 STATUS_SUCCESS = 0
@@ -1907,7 +1907,6 @@ cairo_region_xor_rectangle (cairo_region_t *dst,
 void
 cairo_debug_reset_static_data (void);
 
-
 const int CAIRO_PDF_OUTLINE_ROOT = 0;
 
 
diff --git a/cairocffi/ffi_build.py b/cairocffi/ffi_build.py
index 9c124c5..77e5729 100644
--- a/cairocffi/ffi_build.py
+++ b/cairocffi/ffi_build.py
@@ -22,7 +22,8 @@ constants = module_from_spec(constants_spec)
 constants_spec.loader.exec_module(constants)
 
 # Create an empty _generated folder if needed
-(Path(__file__).parent / '_generated').mkdir(exist_ok=True)
+generated = Path(__file__).parent / '_generated'
+generated.mkdir(exist_ok=True)
 
 # Primary cffi definitions
 ffi = FFI()
@@ -32,10 +33,11 @@ ffi.cdef(constants._CAIRO_HEADERS)
 # include xcffib cffi definitions for cairo xcb support
 try:
     from xcffib.ffi_build import ffi as xcb_ffi
-    ffi.include(xcb_ffi)
-    ffi.cdef(constants._CAIRO_XCB_HEADERS)
 except ImportError:
     pass
+else:
+    ffi.include(xcb_ffi)
+    ffi.cdef(constants._CAIRO_XCB_HEADERS)
 
 # gdk pixbuf cffi definitions
 ffi_pixbuf = FFI()
@@ -102,6 +104,15 @@ ffi_pixbuf.cdef('''
 ''')
 
 
-if __name__ == '__main__':
+def compile():
     ffi.compile()
+    ffi_path = generated / 'ffi.py'
+    ffi_path.write_text('# flake8: noqa\n' + ffi_path.read_text())
     ffi_pixbuf.compile()
+    ffi_pixbuf_path = generated / 'ffi_pixbuf.py'
+    ffi_pixbuf_path.write_text(
+        '# flake8: noqa\n' + ffi_pixbuf_path.read_text())
+
+
+if __name__ == '__main__':
+    compile()
diff --git a/cairocffi/surfaces.py b/cairocffi/surfaces.py
index e86bec4..73bdf12 100644
--- a/cairocffi/surfaces.py
+++ b/cairocffi/surfaces.py
@@ -659,7 +659,7 @@ class Surface(object):
                 write_func = _make_write_func(target)
                 _check_status(cairo.cairo_surface_write_to_png_stream(
                     self._pointer, write_func, ffi.NULL))
-            except SystemError:  # noqa
+            except (SystemError, MemoryError):  # noqa
                 # Callback creation has failed
                 if hasattr(target, 'name'):
                     # File-like object has a name, write here
diff --git a/debian/changelog b/debian/changelog
index bafc0b4..5605b2e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+cairocffi (1.5.1-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Mon, 22 May 2023 19:48:35 -0000
+
 cairocffi (1.4.0-1) unstable; urgency=medium
 
   * Team upload.
diff --git a/debian/patches/use_local_objects.inv.patch b/debian/patches/use_local_objects.inv.patch
index fb196ba..a1fe8dd 100644
--- a/debian/patches/use_local_objects.inv.patch
+++ b/debian/patches/use_local_objects.inv.patch
@@ -10,10 +10,10 @@ Patch-Name: use_local_objects.inv.patch
  docs/conf.py | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
-diff --git a/docs/conf.py b/docs/conf.py
-index 7825f06..2f93a2d 100644
---- a/docs/conf.py
-+++ b/docs/conf.py
+Index: cairocffi.git/docs/conf.py
+===================================================================
+--- cairocffi.git.orig/docs/conf.py
++++ cairocffi.git/docs/conf.py
 @@ -12,5 +12,5 @@ exclude_patterns = ['_build']
  autodoc_member_order = 'bysource'
  autodoc_default_flags = ['members']
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..c54e6b2
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,56 @@
+[build-system]
+requires = ["setuptools >= 61.0.0", "cffi >= 1.1.0"]
+build-backend = "build"
+backend-path = ["utils"]
+
+[project]
+name = "cairocffi"
+description = "cffi-based cairo bindings for Python"
+readme = {file = "README.rst", content-type = "text/x-rst"}
+requires-python = ">=3.7"
+license = {file = "LICENSE"}
+keywords = ["cairo", "cffi", "binding"]
+authors = [
+    {name = "Simon Sapin", email = "contact@courtbouillon.org"}
+]
+classifiers = [
+    "Development Status :: 5 - Production/Stable",
+    "Intended Audience :: Developers",
+    "License :: OSI Approved :: BSD License",
+    "Operating System :: POSIX :: Linux",
+    "Operating System :: MacOS :: MacOS X",
+    "Operating System :: Microsoft :: Windows",
+    "Programming Language :: Python :: 3 :: Only",
+    "Programming Language :: Python :: 3.7",
+    "Programming Language :: Python :: 3.8",
+    "Programming Language :: Python :: 3.9",
+    "Programming Language :: Python :: 3.10",
+    "Programming Language :: Python :: 3.11",
+    "Topic :: Multimedia :: Graphics"
+]
+dependencies = [
+    "cffi >= 1.1.0"
+]
+dynamic = ["version"]
+
+[tool.setuptools.dynamic]
+version = {attr = "cairocffi.VERSION"}
+
+[project.urls]
+Documentation = "https://cairocffi.readthedocs.io/"
+Code = "https://github.com/Kozea/cairocffi/"
+Issues = "https://github.com/Kozea/cairocffi/issues"
+Donation = "https://opencollective.com/courtbouillon"
+
+[project.optional-dependencies]
+doc = ["sphinx", "sphinx_rtd_theme"]
+test = ["pytest", "flake8", "isort", "numpy", "pikepdf"]
+xcb = ["xcffib >= 0.3.2"]
+
+[tool.pytest.ini_options]
+addopts = "--pyargs cairocffi"
+norecursedirs = "build dist .cache .eggs .git"
+
+[tool.isort]
+default_section = "FIRSTPARTY"
+multi_line_output = 4
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index ca6ca63..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,95 +0,0 @@
-[metadata]
-name = cairocffi
-url = https://github.com/Kozea/cairocffi
-version = file: cairocffi/VERSION
-license = BSD
-license_files = [ LICENSE ]
-description = cffi-based cairo bindings for Python
-long_description = file: README.rst
-long_description_content_type = text/x-rst
-author = Simon Sapin
-author_email = contact@courtbouillon.org
-platforms =
-  Linux
-  macOS
-  Windows
-keywords =
-  cairo
-  cffi
-  binding
-classifiers =
-  Development Status :: 5 - Production/Stable
-  Intended Audience :: Developers
-  License :: OSI Approved :: BSD License
-  Programming Language :: Python :: 3 :: Only
-  Programming Language :: Python :: 3.7
-  Programming Language :: Python :: 3.8
-  Programming Language :: Python :: 3.9
-  Topic :: Multimedia :: Graphics
-project_urls =
-  Documentation = https://cairocffi.readthedocs.io/
-  Code = https://github.com/Kozea/cairocffi/
-  Issue tracker = https://github.com/Kozea/cairocffi/issues
-  Donation = https://opencollective.com/courtbouillon
-
-[options]
-packages = find:
-setup_requires =
-  cffi >= 1.1.0
-  setuptools
-install_requires =
-  cffi >= 1.1.0
-python_requires = >= 3.7
-
-[options.package_data]
-cairocffi = VERSION
-
-[options.packages.find]
-exclude = cairocffi._generated
-
-[options.extras_require]
-doc =
-  sphinx
-  sphinx_rtd_theme
-test =
-  pytest
-  flake8
-  isort
-  numpy
-  pikepdf
-xcb =
-  xcffib >= 0.3.2
-
-[build_sphinx]
-source-dir = docs
-build-dir = docs/_build
-
-[tool:pytest]
-addopts = --pyargs cairocffi
-norecursedirs = build dist .cache .eggs .git
-
-[flake8]
-exclude =
-  .eggs/
-  build/
-  cairocffi/constants.py
-  cairocffi/_generated/*.py
-
-[isort]
-default_section = FIRSTPARTY
-multi_line_output = 4
-
-[coverage:report]
-exclude_lines =
-  pragma: no cover
-  pytest.xfail()
-  pytest.fail()
-  except OSError:
-  except ImportError:
-  raise OSError
-omit =
-  .*
-
-[coverage:run]
-branch = True
-include = cairocffi/*
diff --git a/setup.py b/setup.py
deleted file mode 100644
index a280a4c..0000000
--- a/setup.py
+++ /dev/null
@@ -1,14 +0,0 @@
-import sys
-
-from setuptools import setup
-
-if sys.version_info.major < 3:
-    raise RuntimeError(
-        'cairocffi does not support Python 2.x anymore. '
-        'Please use Python 3 or install an older version of cairocffi.')
-
-setup(
-    cffi_modules=[
-        'cairocffi/ffi_build.py:ffi',
-        'cairocffi/ffi_build.py:ffi_pixbuf']
-)
diff --git a/utils/build.py b/utils/build.py
new file mode 100644
index 0000000..8d04e3e
--- /dev/null
+++ b/utils/build.py
@@ -0,0 +1,32 @@
+import importlib.util
+import subprocess
+import sys
+from pathlib import Path
+
+from setuptools import build_meta
+from setuptools.build_meta import *  # noqa
+
+folder = Path(__file__).parent.parent / 'cairocffi'
+
+
+def build_sdist(*args, **kwargs):
+    (folder / '_generated' / 'ffi.py').unlink(missing_ok=True)
+    (folder / '_generated' / 'ffi_pixbuf.py').unlink(missing_ok=True)
+    return build_meta.build_sdist(*args, **kwargs)
+
+
+def build_wheel(*args, **kwargs):
+    # Try to install xcffib for XCB support
+    try:
+        pip = Path(sys.executable).parent / 'pip'
+        subprocess.run([str(pip), 'install', 'xcffib'])
+    except Exception:
+        pass
+
+    spec = importlib.util.spec_from_file_location(
+        'ffi_build', folder / 'ffi_build.py')
+    module = importlib.util.module_from_spec(spec)
+    sys.modules['ffi_build'] = module
+    spec.loader.exec_module(module)
+    module.compile()
+    return build_meta.build_wheel(*args, **kwargs)
diff --git a/utils/mkconstants.py b/utils/mkconstants.py
index 11bf86f..e584214 100644
--- a/utils/mkconstants.py
+++ b/utils/mkconstants.py
@@ -83,6 +83,7 @@ def generate(cairo_git_dir):
     print(textwrap.dedent('''\
         # *** Do not edit this file ***
         # Generated by utils/mkconstants.py
+        # flake8: noqa
 
         TAG_DEST = b"cairo.dest"
         TAG_LINK = b"Link"\n'''))

More details

Full run details

Historical runs