Debian doesn't pass an alternative installation layout to setup.py but instead just renames
things afterwards. Since we now write relative paths containing the python library directory name
this breaks things and we can't do anything about it.
So instead of installing one header and referencing it from the other one just install it twice.
And reference the /usr/include one in the .pc file.
This made the array resize which is slow in PyPy
https://bitbucket.org/pypy/pypy/issues/2750
The test is still skipped as it now fails with
"TypeError: expected a writeable buffer object"
We now have platform specific paths in the .pc file and can no longer
install it to /usr/share. Switch back to /usr/lib*.
The initial bug in jhbuild motivating the move is still there, so we
need to fix this in jhbuild.
Pycairo installs .pc files which work quite well where the default
prefix is used, like with distro packaging etc. In virtualenvs
the pkg-config look up path needs to be set manually, and in pip
wheels are involved, where we had to disable installing .pc files
as they can get reused for a different prefix.
To make it easier for other python modules to use the C API introduce
a new function get_include() (similar ot what numpy has) which returns
the include path that needs to be passed to the compiler.
Since we can't really get the old header install path from the module
(one could walk up the tree and look for matching files, but that's ugly)
move the header file into the package itself, so that the path can be
dervived from the package path.
To prevent code from breaking which hardcodes the old include path
install a header to the old location which includes the new header
location.
Instead of using the module state API just import the module
end fetch the error type. This lets us get rid of the PyState API
which isn't available under PyPy3 and also reduces the difference
between Python 2 and 3.
With https://cgit.freedesktop.org/cairo/commit/?id=84fc0ce91d1a57d20500f710abc0e17de82c67df
cairo has moved from using fopen, which supports ANSI paths, to _wfopen, which
supports all Windows paths. The input is changed/limited to utf-8.
To paper over this "API break" (anything outside of ASCII is different)
adjust the encoding based on the cairo library version at runtime.
When taking enum values from Python we cast the signed values to the
enum type, which in case the enum type is unsigned leads to a defined
overflow.
When going the opposite way and creating Python enum values from
C enum values we have to do the reverse. Since casts from unsigned int
to signed int are undefined for > INT_MAX we need to do the type
conversion manually.
Instead cast the parsed int explicitly to the enum type which
might be unsigned.
Still not perfect, as the enum type can be smaller, but I don't
think any compiler does that.
I've noticed the failure [1] on big-endian powerpc64 and
little-endian amd64 using python2.
The failure is simple here:
E assert 4294967295 == -1
means the ollowing:
cairo_set_operator(-1)
cairo_get_operator() = 4294967295
which is the same 'int' value in signed and unsigned forms.
The cast from 'signed' to 'unsigned' happens in
cairo_set_operator(-1)
in PyArg_ParseTuple (as python2 has no unsigned integral types).
The change amends 'cairo_get_operator' to account for
signedness flip and makes tests pass on powerpc64.
[1]:
```
================ FAILURES =============
______ test_context_get_set_operator __
@given(integers())
> def test_context_get_set_operator(value):
tests/test_hypothesis.py:183:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python2.7/site-packages/hypothesis/core.py:524: in wrapped_test
print_example=True, is_final=True
/usr/lib64/python2.7/site-packages/hypothesis/executors.py:58: in default_new_style_executor
return function(data)
/usr/lib64/python2.7/site-packages/hypothesis/core.py:111: in run
return test(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
value = -1
@given(integers())
def test_context_get_set_operator(value):
try:
op = cairo.Operator(value)
except OverflowError:
return
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
context = cairo.Context(surface)
try:
context.set_operator(op)
except OverflowError:
return
> assert context.get_operator() == op
E assert 4294967295 == -1
E + where 4294967295 = <built-in method get_operator of cairo.Context object at 0x3fff88a9d0d0>()
E + where <built-in method get_operator of cairo.Context object at 0x3fff88a9d0d0> = <cairo.Context object at 0x3fff88a9d0d0>.get_operator
tests/test_hypothesis.py:195: AssertionError
---------------- Hypothesis -----------
Falsifying example: test_context_get_set_operator(value=-1)
================ 1 failed, 258 passed, 1 skipped in 9.76 seconds
```
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>