Skip to content

Commit

Permalink
Drop Python < 3.5 support
Browse files Browse the repository at this point in the history
Packaging has been changed too, we now have a really small setup.py file.
  • Loading branch information
liZe committed Feb 6, 2019
1 parent 860538e commit c93eb81
Show file tree
Hide file tree
Showing 33 changed files with 240 additions and 277 deletions.
13 changes: 0 additions & 13 deletions .coveragerc

This file was deleted.

18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
language: python
sudo: false

python:
- 2.6
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
- pypy3
matrix:
include:
- os: linux
python: 3.5
- os: linux
python: 3.6
- os: linux
python: pypy3
- dist: xenial
python: 3.7

before_install:
- export DISPLAY=:99.0
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 by Simon Sapin.
Copyright (c) 2013-2019 by Simon Sapin.

Some rights reserved.

Expand Down
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ a set of Python bindings and object-oriented API for cairo_.
Cairo is a 2D vector graphics library with support for multiple backends
including image buffers, PNG, PostScript, PDF, and SVG file output.

Additionally, the :mod:`cairocffi.pixbuf` module uses GDK-PixBuf_
Additionally, the ``cairocffi.pixbuf`` module uses GDK-PixBuf_
to decode various image formats for use in cairo.

.. _CFFI: https://cffi.readthedocs.org/
Expand All @@ -18,7 +18,7 @@ to decode various image formats for use in cairo.
* `Source code and issue tracker <https://github.com/Kozea/cairocffi>`_
on GitHub.
* Install with ``pip install cairocffi``
* Python 2.6, 2.7 and 3.4+. `Tested with CPython, PyPy and PyPy3
* Python 3.5+. `Tested with CPython and PyPy3
<https://travis-ci.org/Kozea/cairocffi>`_.
* API partially compatible with Pycairo.
* Works with any version of cairo.
1 change: 1 addition & 0 deletions cairocffi/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0rc1
25 changes: 12 additions & 13 deletions cairocffi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# coding: utf-8
"""
cairocffi
~~~~~~~~~
CFFI-based cairo bindings for Python. See README for details.
:copyright: Copyright 2013 by Simon Sapin
:copyright: Copyright 2013-2019 by Simon Sapin
:license: BSD, see LICENSE for details.
"""

import sys
import ctypes.util
import sys
from pathlib import Path

from . import constants
from .compat import FileNotFoundError
from ._ffi import ffi
from ._generated.ffi import ffi

VERSION = '0.9.0'
VERSION = __version__ = (Path(__file__).parent / 'VERSION').read_text().strip()
# supported version of cairo, used to be pycairo version too:
version = '1.16.0'
version_info = (1, 16, 0)
Expand Down Expand Up @@ -108,17 +107,17 @@ def install_as_pycairo():

# Implementation is in submodules, but public API is all here.

from .surfaces import (Surface, ImageSurface, PDFSurface, PSSurface,
from .surfaces import (Surface, ImageSurface, PDFSurface, PSSurface, # noqa
SVGSurface, RecordingSurface, Win32Surface,
Win32PrintingSurface)
try:
from .xcb import XCBSurface
from .xcb import XCBSurface # noqa
except ImportError:
pass
from .patterns import (Pattern, SolidPattern, SurfacePattern,
from .patterns import (Pattern, SolidPattern, SurfacePattern, # noqa
Gradient, LinearGradient, RadialGradient)
from .fonts import FontFace, ToyFontFace, ScaledFont, FontOptions
from .context import Context
from .matrix import Matrix
from .fonts import FontFace, ToyFontFace, ScaledFont, FontOptions # noqa
from .context import Context # noqa
from .matrix import Matrix # noqa

from .constants import *
from .constants import * # noqa
49 changes: 0 additions & 49 deletions cairocffi/compat.py

This file was deleted.

1 change: 0 additions & 1 deletion cairocffi/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2221,4 +2221,3 @@
cairo_xcb_device_debug_get_precision (cairo_device_t *device);
"""

19 changes: 9 additions & 10 deletions cairocffi/context.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
# coding: utf-8
"""
cairocffi.context
~~~~~~~~~~~~~~~~~
Bindings for Context objects.
:copyright: Copyright 2013 by Simon Sapin
:copyright: Copyright 2013-2019 by Simon Sapin
:license: BSD, see LICENSE for details.
"""

from . import ffi, cairo, _check_status, constants, _keepref
from . import _check_status, _keepref, cairo, constants, ffi
from .fonts import FontFace, FontOptions, ScaledFont, _encode_string
from .matrix import Matrix
from .patterns import Pattern
from .surfaces import Surface
from .fonts import FontFace, ScaledFont, FontOptions, _encode_string
from .compat import xrange


PATH_POINTS_PER_TYPE = {
constants.PATH_MOVE_TO: 1,
Expand Down Expand Up @@ -52,12 +49,14 @@ def _encode_path(path_items):
header.type = path_type
header.length = 1 + len(coordinates) // 2
position += 1
for i in xrange(0, len(coordinates), 2):
for i in range(0, len(coordinates), 2):
point = data[position].point
point.x = coordinates[i]
point.y = coordinates[i + 1]
position += 1
path = ffi.new('cairo_path_t *', {'status': constants.STATUS_SUCCESS, 'data': data, 'num_data': length})
path = ffi.new(
'cairo_path_t *',
{'status': constants.STATUS_SUCCESS, 'data': data, 'num_data': length})
return path, data


Expand All @@ -77,7 +76,7 @@ def _iter_path(pointer):
path_data = data[position]
path_type = path_data.header.type
points = ()
for i in xrange(points_per_type[path_type]):
for i in range(points_per_type[path_type]):
point = data[position + i + 1].point
points += (point.x, point.y)
yield (path_type, points)
Expand Down Expand Up @@ -1660,7 +1659,7 @@ def copy_clip_rectangle_list(self):
_check_status(rectangle_list.status)
rectangles = rectangle_list.rectangles
result = []
for i in xrange(rectangle_list.num_rectangles):
for i in range(rectangle_list.num_rectangles):
rect = rectangles[i]
result.append((rect.x, rect.y, rect.width, rect.height))
cairo.cairo_rectangle_list_destroy(rectangle_list)
Expand Down
21 changes: 12 additions & 9 deletions cairocffi/ffi_build.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
# coding: utf-8
"""
cairocffi.ffi_build
~~~~~~~~~~~~~~~~~~~
Build the cffi bindings
:copyright: Copyright 2013 by Simon Sapin
:copyright: Copyright 2013-2019 by Simon Sapin
:license: BSD, see LICENSE for details.
"""

import os
import shutil
import sys
from pathlib import Path

from cffi import FFI

# Path hack to import constants when this file is exec'd by setuptools
this_file = os.path.abspath(__file__)
this_dir = os.path.dirname(this_file)
sys.path.append(this_dir)
sys.path.append(str(Path(__file__).parent))

import constants # noqa

import constants
# Create an empty _generated folder if needed
shutil.rmtree((Path(__file__).parent / '_generated'), ignore_errors=True)
(Path(__file__).parent / '_generated').mkdir(exist_ok=True)


# Primary cffi definitions
ffi = FFI()
ffi.set_source('cairocffi._ffi', None)
ffi.set_source('cairocffi._generated.ffi', None)
ffi.cdef(constants._CAIRO_HEADERS)

# include xcffib cffi definitions for cairo xcb support
Expand All @@ -37,7 +40,7 @@

# gdk pixbuf cffi definitions
ffi_pixbuf = FFI()
ffi_pixbuf.set_source('cairocffi._ffi_pixbuf', None)
ffi_pixbuf.set_source('cairocffi._generated.ffi_pixbuf', None)
ffi_pixbuf.include(ffi)
ffi_pixbuf.cdef('''
typedef unsigned long gsize;
Expand Down
10 changes: 4 additions & 6 deletions cairocffi/fonts.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# coding: utf-8
"""
cairocffi.fonts
~~~~~~~~~~~~~~~
Bindings for font-related objects.
:copyright: Copyright 2013 by Simon Sapin
:copyright: Copyright 2013-2019 by Simon Sapin
:license: BSD, see LICENSE for details.
"""

from . import ffi, cairo, _check_status, constants, _keepref
from . import _check_status, _keepref, cairo, constants, ffi
from .matrix import Matrix
from .compat import xrange


def _encode_string(string):
Expand Down Expand Up @@ -356,12 +354,12 @@ def text_to_glyphs(self, x, y, text, with_clusters):
_check_status(status)
glyphs = [
(glyph.index, glyph.x, glyph.y)
for i in xrange(num_glyphs[0])
for i in range(num_glyphs[0])
for glyph in [glyphs[i]]]
if with_clusters:
clusters = [
(cluster.num_bytes, cluster.num_glyphs)
for i in xrange(num_clusters[0])
for i in range(num_clusters[0])
for cluster in [clusters[i]]]
return glyphs, clusters, cluster_flags[0]
else:
Expand Down
5 changes: 2 additions & 3 deletions cairocffi/matrix.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# coding: utf-8
"""
cairocffi.matrix
~~~~~~~~~~~~~~~~
Transformation matrices.
:copyright: Copyright 2013 by Simon Sapin
:copyright: Copyright 2013-2019 by Simon Sapin
:license: BSD, see LICENSE for details.
"""

from . import ffi, cairo, _check_status
from . import _check_status, cairo, ffi


class Matrix(object):
Expand Down
8 changes: 3 additions & 5 deletions cairocffi/patterns.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# coding: utf-8
"""
cairocffi.patterns
~~~~~~~~~~~~~~~~~~
Bindings for the various types of pattern objects.
:copyright: Copyright 2013 by Simon Sapin
:copyright: Copyright 2013-2019 by Simon Sapin
:license: BSD, see LICENSE for details.
"""

from . import ffi, cairo, _check_status, constants, _keepref
from . import _check_status, _keepref, cairo, constants, ffi
from .matrix import Matrix
from .surfaces import Surface
from .compat import xrange


class Pattern(object):
Expand Down Expand Up @@ -277,7 +275,7 @@ def get_color_stops(self):
self._pointer, count))
stops = []
stop = ffi.new('double[5]')
for i in xrange(count[0]):
for i in range(count[0]):
_check_status(cairo.cairo_pattern_get_color_stop_rgba(
self._pointer, i,
stop + 0, stop + 1, stop + 2, stop + 3, stop + 4))
Expand Down
Loading

0 comments on commit c93eb81

Please sign in to comment.