File: c_build.rst

package info (click to toggle)
pycairo 1.27.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,984 kB
  • sloc: ansic: 8,873; python: 3,688; makefile: 32; sh: 4
file content (57 lines) | stat: -rw-r--r-- 1,730 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
.. currentmodule:: cairo

Build Integration
=================

To compile a Python extension using Pycairo you need to know where Pycairo and
cairo are located and what flags to pass to the compiler and linker.

1. Variant:

    Similar to variant 2 but doesn't require pycairo to be loaded, which can be
    problematic on Windows where by default cairo isn't in the dll search path
    since Python 3.8.

    .. code:: python

        def get_include_path():
            import os
            from importlib.util import find_spec
            spec = find_spec("cairo")
            assert spec is not None
            return os.path.join(os.path.dirname(spec.origin), 'include')

    Compiler Flags:
        * ``python -c "get_include_path()"``
        * ``pkg-config --cflags cairo``

    Linker Flags:
        * ``pkg-config --libs cairo``

2. Variant:

    Only available since version 1.16.0.

    While Pycairo installs a pkg-config file, in case of virtualenvs,
    installation to the user directory or when using wheels/eggs, pkg-config
    will not be able to locate the .pc file. The :func:`get_include` function
    should work in all cases, as long as Pycairo is in your Python search path.

    Compiler Flags:
        * ``python -c "import cairo; print(cairo.get_include())"``
        * ``pkg-config --cflags cairo``

    Linker Flags:
        * ``pkg-config --libs cairo``

3. Variant:

    This works with older versions, but with the limitations mentioned above.
    Use it as a fallback if you want to support older versions or if your
    module does not require virtualenv/pip support.

    Compiler Flags:
        * ``pkg-config --cflags py3cairo``

    Linker Flags:
        * ``pkg-config --libs py3cairo``