2 # This file and its contents are supplied under the terms of the
3 # Common Development and Distribution License ("CDDL"), version 1.0.
4 # You may only use this file in accordance with the terms of version
7 # A full copy of the text of the CDDL should have accompanied this
8 # source. A copy of the CDDL is also available via the Internet at
9 # http://www.illumos.org/license/CDDL.
13 # Copyright 2023 Marcel Telka
17 # Force setup.py build style - see https://github.com/pygobject/pycairo/issues/312
18 BUILD_STYLE = setup.py
20 # We cannot obsolete pycairo-27 yet because it is needed by pygtk2-27 and
21 # pygtk2-27 is needed by gimp.
22 PYTHON_VERSIONS_OBSOLETING := $(filter-out 2.7, $(PYTHON_VERSIONS_OBSOLETING))
24 # Install common files to /usr
25 PYTHON_DATA = $(USRDIR)
27 # The pkgconfig file should go to proper place
28 COMPONENT_INSTALL_ARGS += install_pkgconfig --pkgconfigdir=$(PKG_CONFIG_PATH.$(BITS))
30 # Rename headers and pkgconfig files to contain version number
31 COMPONENT_POST_INSTALL_ACTION += \
32 for f in $(PROTOUSRINCDIR)/pycairo/* $(PROTO_DIR)$(PKG_CONFIG_PATH.$(BITS))/* ; do \
33 [ -f $$f ] || continue ; \
34 for v in $(PYTHON_VERSIONS) ; do \
35 [ "$$f" == "$${f%%$$v}" ] || continue 2 ; \
37 $(MV) $$f $$f-$(PYTHON_VERSION) ; \
40 # Tests are run from build directory which contains cloned copy of sdist. We
41 # try to ask Python to find tested modules in the proto area (the PYTHONPATH is
42 # set accordingly), but Python (< 3.11) always adds the current directory to
43 # sys.path and there is no known (simple) way how to avoid that. Except -I,
44 # but that would cause Python to ignore PYTHONPATH too so we would not have
45 # access to the proto area either. The -P option together with PYTHONSAFEPATH
46 # environment variable were added to Python 3.11 only so we cannot use them yet
47 # for all Python versions we support.
49 # Since sdist for this project contains the main module in the top-level
50 # directory we cannot force Python to skip it. But, unfortunately, this module
51 # does not contain built dynamic libraries, so Python cannot find them while
54 # To workaround this we rename the main module in the build directory during
55 # testing so Python will need to defer to PYTHONPATH.
56 COMPONENT_PRE_TEST_ACTION += \
57 $(MV) $(@D)/cairo $(@D)/cairo-RENAMED ;
58 COMPONENT_POST_TEST_ACTION += \
59 $(MV) $(@D)/cairo-RENAMED $(@D)/cairo ;
61 # Replace Python version in header and pkgconfig file names
62 GENERATE_EXTRA_CMD += | \
63 $(GSED) -e 's/\(py3cairo\.[hpc]*-\)3\.[0-9]*$$/\1$$(PYVER)/' | uniq
66 cat "$SOURCE_DIR/COPYING"
67 printf '\n--- COPYING-LGPL-2.1 ------------------------------------------------------\n\n'
68 cat "$SOURCE_DIR/COPYING-LGPL-2.1"
69 printf '\n--- COPYING-MPL-1.1 -------------------------------------------------------\n\n'
70 cat "$SOURCE_DIR/COPYING-MPL-1.1"
71 ) > "$DISTRIBUTION.license"
72 LICENSE="LGPL-2.1-only OR MPL-1.1"
74 # Create mediated symlinks
75 printf '<transform file path=(usr/.*/)(py3cairo.(h|pc))-(3\\.\\d+)$ -> emit link path=%%<1>%%<2> target=%%<2>-%%<4> mediator=python mediator-version=%%<4> >\n' >> "$DISTRIBUTION-PYVER.p5m"