From e619e426d955ad3d3b6af1608dc8a699590f03c6 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sat, 21 Oct 2023 14:01:47 +0200 Subject: [PATCH 1/5] meson: don't pass a Python dependency to extension_module() This is no longer required since meson 0.63.0 --- cairo/meson.build | 11 +---------- tests/meson.build | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/cairo/meson.build b/cairo/meson.build index 3e3b2cc1..d14276b9 100644 --- a/cairo/meson.build +++ b/cairo/meson.build @@ -32,8 +32,6 @@ foreach python_file : python_sources ) endforeach -python_dep = python.dependency() - cairo_dep = dependency('cairo', version: cair_version_req, required: cc.get_id() != 'msvc') if cc.get_id() == 'msvc' and not cairo_dep.found() @@ -65,15 +63,8 @@ install_headers( ) install_headers([header_file], subdir: 'pycairo') -# https://github.com/mesonbuild/meson/issues/4117 -if host_machine.system() == 'windows' - python_ext_dep = python_dep -else - python_ext_dep = python_dep.partial_dependency(compile_args: true) -endif - pyext = python.extension_module('_cairo', sources, - dependencies : [python_ext_dep, cairo_dep], + dependencies : [cairo_dep], install: true, subdir : 'cairo', c_args: pyext_c_args + main_c_args, diff --git a/tests/meson.build b/tests/meson.build index cef8d893..553bab30 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -29,7 +29,7 @@ mod_sources = [ ] python.extension_module('cmod', mod_sources, - dependencies : [python_dep, cairo_dep], + dependencies : [cairo_dep], install: false, include_directories: include_directories('../cairo'), c_args: pyext_c_args + main_c_args + ['-DPY_SSIZE_T_CLEAN'], From d9b039afa5c72567de04ed0a71339575d0cf915d Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sat, 21 Oct 2023 14:09:09 +0200 Subject: [PATCH 2/5] meson: remove some Python 2 leftovers --- cairo/meson.build | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/cairo/meson.build b/cairo/meson.build index d14276b9..da15dde4 100644 --- a/cairo/meson.build +++ b/cairo/meson.build @@ -45,15 +45,9 @@ python.install_sources(python_sources, subdir : 'cairo' ) -if python.language_version().version_compare('>= 3.0') - pc_name = 'py3cairo' -else - pc_name = 'pycairo' -endif - header_file = configure_file( input: 'pycairo.h', - output: pc_name + '.h', + output: 'py3cairo.h', copy: true, ) @@ -73,9 +67,8 @@ pyext = python.extension_module('_cairo', sources, pkg = import('pkgconfig') pkg.generate( - name: pc_name, - description: 'Python @0@ bindings for cairo'.format( - python.language_version().split('.')[0]), + name: 'py3cairo', + description: 'Python 3 bindings for cairo', subdirs: 'pycairo', requires: ['cairo'], ) From b1ab2a619eabaf394b758863986e7d9dbdc38072 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sat, 21 Oct 2023 14:17:47 +0200 Subject: [PATCH 3/5] meson: move version requirements to one place --- meson.build | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 13bda9e0..b2c95cfa 100644 --- a/meson.build +++ b/meson.build @@ -10,13 +10,14 @@ project( ) cair_version_req = '>=1.15.10' +python_version_req = '>=3.8' pymod = import('python') python = pymod.find_installation(get_option('python')) pyver = python.language_version() -if pyver.version_compare('< 3.8') - error('Requires Python >= 3.8') +if not pyver.version_compare(python_version_req) + error('Requires Python @0@'.format(python_version_req)) endif configure_file( From 125eee11e09c2fd4b4daa496d0add8bd2a1dabd4 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sat, 21 Oct 2023 14:50:29 +0200 Subject: [PATCH 4/5] Rename pycairo.h to py3cairo.h also in the source This used to be installed as either pycairo.h or py3cairo.h depending on the Python version. Now that Python 2 is gone we can simplify it and just use py3cairo.h everywhere. --- cairo/cairomodule.c | 2 +- cairo/meson.build | 10 ++-------- cairo/private.h | 4 ++-- cairo/{pycairo.h => py3cairo.h} | 0 setup.py | 6 +++--- tests/cmodule/cmodule.c | 3 +-- tests/cmodule/cmodulelib.c | 2 +- 7 files changed, 10 insertions(+), 17 deletions(-) rename cairo/{pycairo.h => py3cairo.h} (100%) diff --git a/cairo/cairomodule.c b/cairo/cairomodule.c index f27330f4..ebe32816 100644 --- a/cairo/cairomodule.c +++ b/cairo/cairomodule.c @@ -38,7 +38,7 @@ #include #endif -/* C API. Clients get at this via Pycairo_IMPORT or import_cairo(), defined in pycairo.h. +/* C API. Clients get at this via Pycairo_IMPORT or import_cairo(), defined in py3cairo.h. */ static Pycairo_CAPI_t CAPI = { &PycairoContext_Type, diff --git a/cairo/meson.build b/cairo/meson.build index da15dde4..cba31dfe 100644 --- a/cairo/meson.build +++ b/cairo/meson.build @@ -45,17 +45,11 @@ python.install_sources(python_sources, subdir : 'cairo' ) -header_file = configure_file( - input: 'pycairo.h', - output: 'py3cairo.h', - copy: true, -) - install_headers( - [header_file], + 'py3cairo.h', install_dir: join_paths(python.get_install_dir(), 'cairo', 'include'), ) -install_headers([header_file], subdir: 'pycairo') +install_headers('py3cairo.h', subdir: 'pycairo') pyext = python.extension_module('_cairo', sources, dependencies : [cairo_dep], diff --git a/cairo/private.h b/cairo/private.h index 6bb52c95..c89877c0 100644 --- a/cairo/private.h +++ b/cairo/private.h @@ -33,13 +33,13 @@ #define _PYCAIRO_PRIVATE_H_ #ifdef _PYCAIRO_H_ -# error "don't include pycairo.h and pycairo-private.h together" +# error "don't include py3cairo.h and pycairo-private.h together" #endif #define _INSIDE_PYCAIRO_ #include -#include "pycairo.h" +#include "py3cairo.h" #define PYCAIRO_STRINGIFY(s) PYCAIRO_STRINGIFY_ARG(s) #define PYCAIRO_STRINGIFY_ARG(s) #s diff --git a/cairo/pycairo.h b/cairo/py3cairo.h similarity index 100% rename from cairo/pycairo.h rename to cairo/py3cairo.h diff --git a/setup.py b/setup.py index 2cf53637..ab01cf98 100755 --- a/setup.py +++ b/setup.py @@ -197,7 +197,7 @@ def run(self): ], depends=[ os.path.join(tests_dir, "cmodulelib.h"), - os.path.join("cairo", "pycairo.h"), + os.path.join("cairo", "py3cairo.h"), ], define_macros=[("PY_SSIZE_T_CLEAN", None)], ) @@ -371,7 +371,7 @@ def get_outputs(self): return self.outfiles def get_inputs(self): - return [os.path.join('cairo', 'pycairo.h')] + return [os.path.join('cairo', 'py3cairo.h')] def run(self): # https://github.com/pygobject/pycairo/issues/92 @@ -490,7 +490,7 @@ def main(): ], depends=[ 'cairo/private.h', - 'cairo/pycairo.h', + 'cairo/py3cairo.h', ], define_macros=[ ("PYCAIRO_VERSION_MAJOR", PYCAIRO_VERSION.split('.')[0]), diff --git a/tests/cmodule/cmodule.c b/tests/cmodule/cmodule.c index 128930cf..20f7a420 100644 --- a/tests/cmodule/cmodule.c +++ b/tests/cmodule/cmodule.c @@ -1,6 +1,5 @@ #include -/* not pycairo3.h because we use the one from the source directory */ -#include +#include #include "cmodulelib.h" static PyMethodDef CModMethods[] = { diff --git a/tests/cmodule/cmodulelib.c b/tests/cmodule/cmodulelib.c index 3854d19b..a0f84637 100644 --- a/tests/cmodule/cmodulelib.c +++ b/tests/cmodule/cmodulelib.c @@ -1,6 +1,6 @@ #include #define PYCAIRO_NO_IMPORT -#include +#include #include "cmodulelib.h" PyObject * From 04dbee91b758fb08e9356f715309ddc80d30fcc0 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sat, 21 Oct 2023 13:57:00 +0200 Subject: [PATCH 5/5] meson: use fs.copyfile everywhere In places where we just copy files to the build dir. This requires meson 0.64.0 --- cairo/meson.build | 6 +----- meson.build | 9 +++------ tests/meson.build | 6 +----- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/cairo/meson.build b/cairo/meson.build index cba31dfe..8046424b 100644 --- a/cairo/meson.build +++ b/cairo/meson.build @@ -25,11 +25,7 @@ sources = [ ] foreach python_file : python_sources - configure_file( - input: python_file, - output: python_file, - copy: true, - ) + fs.copyfile(python_file, python_file) endforeach cairo_dep = dependency('cairo', version: cair_version_req, required: cc.get_id() != 'msvc') diff --git a/meson.build b/meson.build index b2c95cfa..f2d648e1 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'pycairo', 'c', version: '1.25.1', - meson_version: '>= 0.56.0', + meson_version: '>= 0.64.0', license: 'LGPL-2.1-only OR MPL-1.1', default_options: [ 'warning_level=1', @@ -20,11 +20,8 @@ if not pyver.version_compare(python_version_req) error('Requires Python @0@'.format(python_version_req)) endif -configure_file( - input: 'setup.cfg', - output: 'setup.cfg', - copy: true, -) +fs = import('fs') +fs.copyfile('setup.cfg', 'setup.cfg') cc = meson.get_compiler('c') diff --git a/tests/meson.build b/tests/meson.build index 553bab30..4d5ba9e3 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -36,11 +36,7 @@ python.extension_module('cmod', mod_sources, ) foreach python_file : test_sources - configure_file( - input: python_file, - output: python_file, - copy: true, - ) + fs.copyfile(python_file, python_file) endforeach test(