meson support. Fixes #114
This commit is contained in:
parent
b61e3c7704
commit
f3342173c1
|
@ -3,6 +3,8 @@ include NEWS
|
|||
include README.rst
|
||||
include MANIFEST.in
|
||||
include setup.cfg
|
||||
include meson_options.txt
|
||||
recursive-include . meson.build
|
||||
recursive-include docs *.py Makefile *.rst *.css *.svg
|
||||
prune docs/_build
|
||||
recursive-include tests *.py README *.c *.h
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
python_sources = [
|
||||
'__init__.py',
|
||||
'__init__.pyi',
|
||||
'py.typed',
|
||||
]
|
||||
|
||||
sources = [
|
||||
'bufferproxy.c',
|
||||
'cairomodule.c',
|
||||
'context.c',
|
||||
'device.c',
|
||||
'enums.c',
|
||||
'error.c',
|
||||
'font.c',
|
||||
'glyph.c',
|
||||
'matrix.c',
|
||||
'misc.c',
|
||||
'path.c',
|
||||
'pattern.c',
|
||||
'rectangle.c',
|
||||
'region.c',
|
||||
'surface.c',
|
||||
'textcluster.c',
|
||||
'textextents.c',
|
||||
]
|
||||
|
||||
foreach python_file : python_sources
|
||||
configure_file(
|
||||
input: python_file,
|
||||
output: python_file,
|
||||
configuration: configuration_data(),
|
||||
)
|
||||
endforeach
|
||||
|
||||
python_dep = python.dependency()
|
||||
|
||||
cairo_dep = dependency('cairo', version: cair_version_req)
|
||||
|
||||
python.install_sources(python_sources,
|
||||
pure : false,
|
||||
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',
|
||||
configuration: configuration_data(),
|
||||
)
|
||||
|
||||
install_headers(
|
||||
[header_file],
|
||||
subdir: join_paths(python.get_install_dir(), 'cairo', 'include'),
|
||||
)
|
||||
install_headers([header_file], subdir: 'pycairo')
|
||||
|
||||
pyext = python.extension_module('_cairo', sources,
|
||||
dependencies : [python_dep, cairo_dep],
|
||||
install: true,
|
||||
subdir : 'cairo',
|
||||
c_args: pyext_c_args + main_c_args,
|
||||
)
|
||||
|
||||
pkg = import('pkgconfig')
|
||||
|
||||
pkg.generate(
|
||||
name: pc_name,
|
||||
description: 'Python @0@ bindings for cairo'.format(
|
||||
python.language_version().split('.')[0]),
|
||||
subdirs: 'pycairo',
|
||||
requires: ['cairo'],
|
||||
)
|
|
@ -0,0 +1,81 @@
|
|||
project(
|
||||
'pycairo', 'c',
|
||||
version: '1.17.1',
|
||||
meson_version: '>= 0.46.0',
|
||||
default_options: [
|
||||
'warning_level=1',
|
||||
'buildtype=debugoptimized',
|
||||
],
|
||||
)
|
||||
|
||||
cair_version_req = '>=1.13.1'
|
||||
|
||||
pymod = import('python')
|
||||
python = pymod.find_installation(get_option('python'))
|
||||
|
||||
configure_file(
|
||||
input: 'setup.cfg',
|
||||
output: 'setup.cfg',
|
||||
configuration: configuration_data(),
|
||||
)
|
||||
|
||||
main_c_args = [
|
||||
'-Wall',
|
||||
'-Warray-bounds',
|
||||
'-Wcast-align',
|
||||
'-Wconversion',
|
||||
'-Wdeclaration-after-statement',
|
||||
'-Wextra',
|
||||
'-Wformat=2',
|
||||
'-Wformat-nonliteral',
|
||||
'-Wformat-security',
|
||||
'-Wimplicit-function-declaration',
|
||||
'-Winit-self',
|
||||
'-Winline',
|
||||
'-Wmissing-format-attribute',
|
||||
'-Wmissing-noreturn',
|
||||
'-Wnested-externs',
|
||||
'-Wold-style-definition',
|
||||
'-Wpacked',
|
||||
'-Wpointer-arith',
|
||||
'-Wreturn-type',
|
||||
'-Wshadow',
|
||||
'-Wsign-compare',
|
||||
'-Wstrict-aliasing',
|
||||
'-Wundef',
|
||||
'-Wunused-but-set-variable',
|
||||
]
|
||||
|
||||
main_c_args += [
|
||||
'-Wno-missing-field-initializers',
|
||||
'-Wno-unused-parameter',
|
||||
]
|
||||
|
||||
main_c_args += [
|
||||
'-fno-strict-aliasing',
|
||||
'-fvisibility=hidden',
|
||||
]
|
||||
|
||||
if not ['3.3', '3.4'].contains(python.language_version())
|
||||
main_c_args += [
|
||||
'-Wswitch-default',
|
||||
]
|
||||
endif
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
main_c_args = cc.get_supported_arguments(main_c_args)
|
||||
|
||||
pycairo_version = meson.project_version()
|
||||
version_arr = pycairo_version.split('.')
|
||||
pycairo_version_major = version_arr[0].to_int()
|
||||
pycairo_version_minor = version_arr[1].to_int()
|
||||
pycairo_version_micro = version_arr[2].to_int()
|
||||
|
||||
pyext_c_args = [
|
||||
'-DPYCAIRO_VERSION_MAJOR=@0@'.format(pycairo_version_major),
|
||||
'-DPYCAIRO_VERSION_MINOR=@0@'.format(pycairo_version_minor),
|
||||
'-DPYCAIRO_VERSION_MICRO=@0@'.format(pycairo_version_micro),
|
||||
]
|
||||
|
||||
subdir('cairo')
|
||||
subdir('tests')
|
|
@ -0,0 +1 @@
|
|||
option('python', type : 'string', value : 'python3')
|
|
@ -0,0 +1,56 @@
|
|||
test_sources = [
|
||||
'hypothesis_fspaths.py',
|
||||
'__init__.py',
|
||||
'test_api.py',
|
||||
'test_cmod.py',
|
||||
'test_context.py',
|
||||
'test_device.py',
|
||||
'test_enums.py',
|
||||
'test_error.py',
|
||||
'test_font.py',
|
||||
'test_glyph.py',
|
||||
'test_hypothesis.py',
|
||||
'test_matrix.py',
|
||||
'test_path.py',
|
||||
'test_pattern.py',
|
||||
'test_rectangle.py',
|
||||
'test_region.py',
|
||||
'test_surface_numpy.py',
|
||||
'test_surface.py',
|
||||
'test_surface_pygame.py',
|
||||
'test_textcluster.py',
|
||||
'test_textextents.py',
|
||||
'test_typing.py',
|
||||
]
|
||||
|
||||
mod_sources = [
|
||||
join_paths('cmodule', 'cmodule.c'),
|
||||
join_paths('cmodule', 'cmodulelib.c'),
|
||||
]
|
||||
|
||||
python.extension_module('cmod', mod_sources,
|
||||
dependencies : [python_dep, 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,
|
||||
configuration: configuration_data(),
|
||||
)
|
||||
endforeach
|
||||
|
||||
test(
|
||||
'tests', python,
|
||||
workdir: meson.build_root(),
|
||||
args: ['-m', 'pytest'],
|
||||
)
|
||||
|
||||
test(
|
||||
'quality', python,
|
||||
workdir: meson.build_root(),
|
||||
args: ['-m', 'flake8'],
|
||||
)
|
Loading…
Reference in New Issue