Commit 7f05581e authored by Yuanle Song's avatar Yuanle Song
Browse files

make code work with python3.8+

in python3.8+, to link against python, you need to link against
python3-embed lib, which is supported by a newer meson module.
parent 254fd6d3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
 *
 * libpyzy - The Chinese PinYin and Bopomofo conversion library.
 *
 * Copyright (c) 2019 Yuanle Song <sylecn@gmail.com>
 * Copyright (c) 2019, 2021 Yuanle Song <sylecn@gmail.com>
 * Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
@@ -205,6 +205,7 @@ PinyinParser::parse (const String &pinyin,
                        break;
                    }
                }
		// fall through
            default:
                py = is_pinyin (p, end, -1, option);
                break;
+8 −2
Original line number Diff line number Diff line
@@ -2,7 +2,9 @@
project('pinyin_parser', ['cpp', 'c'],
  version: '1.0.0',
  license: 'EPL-2.0',
  meson_version: '>= 0.46.0',
  default_options: [
    'cpp_std=c++11',
    'warning_level=2',
    'werror=true',
    'strip=true',
@@ -12,7 +14,6 @@ add_project_arguments(
  '-Wno-unused-parameter',
  '-Wno-missing-field-initializers',
  '-DHAVE_LIBUUID',
  '-std=c++11',
  language: 'cpp')

# generate pinyin_parser_wrap.c using swig.
@@ -36,13 +37,18 @@ glib = dependency('glib-2.0')
uuid = dependency('uuid')
shared_dep = [glib, uuid]

# requires meson 0.46.0+
pymod = import('python')
py_installation = pymod.find_installation('python3')

lib_src = [
  '../PinyinParser.cc',
  'pinyin_parser.cpp',
  pinyin_parser_wrap]
shared_library('pinyin_parser',
  lib_src,
  dependencies: [shared_dep, dependency('python3')],
  dependencies: [shared_dep, py_installation.dependency(embed: true)],
  # note: to link against libpython, embed must be set to true.
  install: true, install_dir: '/home/sylecn/c/gtk-im-module/sogou/scelexport/')

main_src = [