File: build

package info (click to toggle)
pygobject 3.54.5-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,864 kB
  • sloc: ansic: 40,281; python: 26,363; sh: 477; makefile: 81; xml: 35; cpp: 1
file content (86 lines) | stat: -rwxr-xr-x 2,094 bytes parent folder | download | duplicates (2)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
# autopkgtest check: Build and run a program against pygobject, to verify that
# the headers and pkg-config file are installed correctly
# (C) 2012 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>

set -e

WORKDIR=$(mktemp -d)
trap 'rm -rf "$WORKDIR"' 0 INT QUIT ABRT PIPE TERM
cd "$WORKDIR"

if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
    CROSS_COMPILE="$DEB_HOST_GNU_TYPE-"
else
    CROSS_COMPILE=
fi

cat <<EOF > pytest.c
#include <Python.h>
#include <pygobject.h>
#include <assert.h>

#define AT_LEAST_PYTHON(maj, min, mic, level, ser) \
    (PY_VERSION_HEX >= ((maj << 24) | (min << 16) | (mic << 8) | (level << 4) | (ser)))

int main(void)
{
    PyObject *gobject;
#if AT_LEAST_PYTHON(3, 12, 0, 0, 0)
    PyConfig config;
    PyStatus status;

    PyConfig_InitPythonConfig (&config);
    config.buffered_stdio = 0;
    config.install_signal_handlers = 0;
    status = Py_InitializeFromConfig (&config);
    if (PyStatus_Exception (status)) {
        Py_ExitStatusException (status);
    }
    PyConfig_Clear (&config);
#else
    Py_UnbufferedStdioFlag = 1;
    Py_InitializeEx (FALSE);
    if (PyErr_Occurred ()) {
        PySys_WriteStderr ("Error in Py_InitializeEx\n");
        PyErr_Print ();
        return 1;
    }
#endif

    gobject = pygobject_init (-1, -1, -1);
    if (PyErr_Occurred ()) {
        PySys_WriteStderr ("Error in pygobject_init\n");
        PyErr_Print ();
        return 2;
    }
    assert (gobject != NULL);
    return 0;
}
EOF

failed=

for v in $(py3versions -sv); do
    pkg="python-${v}-embed"

    # Deliberately word-splitting, that's how pkg-config works:
    # shellcheck disable=SC2046
    if "${CROSS_COMPILE}gcc" -o "pytest$v" pytest.c $("${CROSS_COMPILE}pkg-config" --cflags --libs "$pkg" pygobject-3.0); then
        echo "build ($v): OK"
        [ -x "pytest$v" ]
        if ./"pytest$v"; then
            echo "run ($v): OK"
        else
            echo "run ($v): FAILED"
            failed=yes
        fi
    else
        echo "build ($v): FAILED"
        failed=yes
     fi
done
if [ -n "$failed" ]; then
    exit 1
fi