Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some meson cleanup #346

Merged
merged 5 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cairo/cairomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <cairo-pdf.h>
#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,
Expand Down
38 changes: 6 additions & 32 deletions cairo/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@ sources = [
]

foreach python_file : python_sources
configure_file(
input: python_file,
output: python_file,
copy: true,
)
fs.copyfile(python_file, python_file)
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()
Expand All @@ -47,33 +41,14 @@ 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',
copy: true,
)

install_headers(
[header_file],
'py3cairo.h',
install_dir: join_paths(python.get_install_dir(), 'cairo', 'include'),
)
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
install_headers('py3cairo.h', subdir: 'pycairo')

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,
Expand All @@ -82,9 +57,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'],
)
Expand Down
4 changes: 2 additions & 2 deletions cairo/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Python.h>

#include "pycairo.h"
#include "py3cairo.h"

#define PYCAIRO_STRINGIFY(s) PYCAIRO_STRINGIFY_ARG(s)
#define PYCAIRO_STRINGIFY_ARG(s) #s
Expand Down
File renamed without changes.
14 changes: 6 additions & 8 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -10,20 +10,18 @@ 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(
input: 'setup.cfg',
output: 'setup.cfg',
copy: true,
)
fs = import('fs')
fs.copyfile('setup.cfg', 'setup.cfg')

cc = meson.get_compiler('c')

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]),
Expand Down
3 changes: 1 addition & 2 deletions tests/cmodule/cmodule.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <Python.h>
/* not pycairo3.h because we use the one from the source directory */
#include <pycairo.h>
#include <py3cairo.h>
#include "cmodulelib.h"

static PyMethodDef CModMethods[] = {
Expand Down
2 changes: 1 addition & 1 deletion tests/cmodule/cmodulelib.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Python.h>
#define PYCAIRO_NO_IMPORT
#include <pycairo.h>
#include <py3cairo.h>
#include "cmodulelib.h"

PyObject *
Expand Down
8 changes: 2 additions & 6 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,14 @@ 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'],
)

foreach python_file : test_sources
configure_file(
input: python_file,
output: python_file,
copy: true,
)
fs.copyfile(python_file, python_file)
endforeach

test(
Expand Down
Loading