diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e6c4b183..390cc2fd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,17 @@ Changelog --------- +`0.53.0`_ (2024-09-15) ++++++++++++++++++++++++++ + +* **[New]** 内置对 pyinstaller 打包的支持, + 避免使用 pyinstaller 打包时需要额外处理类似 `no such file or dictionary: pinyin_dict.json` 错误的问题。 + ( **未增加新的依赖包** ,仅通过在源码中增加 __pyinstaller 目录, + 支持使用 pyinstaller 打包依赖了 pypinyin 的项目时自动打包 v0.52.0 版本新引入的 json 文件) + via `#329`_ Thanks `@xushengj`_ , 详见 `#326`_ 。 + + + `0.52.0`_ (2024-08-04) +++++++++++++++++++++++++ @@ -1024,15 +1035,18 @@ __ https://github.com/mozillazg/python-pinyin/issues/8 .. _#291: https://github.com/mozillazg/python-pinyin/issues/291 .. _#319: https://github.com/mozillazg/python-pinyin/issues/319 .. _#322: https://github.com/mozillazg/python-pinyin/issues/322 +.. _#326: https://github.com/mozillazg/python-pinyin/issues/326 .. _#164: https://github.com/mozillazg/python-pinyin/pull/164 .. _#176: https://github.com/mozillazg/python-pinyin/pull/176 .. _#279: https://github.com/mozillazg/python-pinyin/pull/279 .. _#318: https://github.com/mozillazg/python-pinyin/pull/318 .. _#324: https://github.com/mozillazg/python-pinyin/pull/324 +.. _#329: https://github.com/mozillazg/python-pinyin/pull/329 .. _@hanabi1224: https://github.com/hanabi1224 .. _@yangwe1: https://github.com/yangwe1 .. _@Freed-Wu: https://github.com/Freed-Wu .. _@serfend: https://github.com/serfend +.. _@xushengj: https://github.com/xushengj .. _变调规则: https://en.wikipedia.org/wiki/Standard_Chinese_phonology#Tone_sandhi .. _0.2.0: https://github.com/mozillazg/python-pinyin/compare/v0.1.0...v0.2.0 @@ -1127,3 +1141,4 @@ __ https://github.com/mozillazg/python-pinyin/issues/8 .. _0.50.0: https://github.com/mozillazg/python-pinyin/compare/v0.49.0...v0.50.0 .. _0.51.0: https://github.com/mozillazg/python-pinyin/compare/v0.50.0...v0.51.0 .. _0.52.0: https://github.com/mozillazg/python-pinyin/compare/v0.51.0...v0.52.0 +.. _0.53.0: https://github.com/mozillazg/python-pinyin/compare/v0.52.0...v0.53.0 diff --git a/README.rst b/README.rst index c51c5254..5244c673 100644 --- a/README.rst +++ b/README.rst @@ -236,11 +236,15 @@ Related Projects * `hotoo/pinyin`__: 汉字拼音转换工具 Node.js/JavaScript 版。 * `mozillazg/go-pinyin`__: 汉字拼音转换工具 Go 版。 * `mozillazg/rust-pinyin`__: 汉字拼音转换工具 Rust 版。 +* `wolfgitpr/cpp-pinyin`__: 汉字拼音转换工具 c++ 版。 +* `wolfgitpr/csharp-pinyin`__: 汉字拼音转换工具 c# 版。 __ https://github.com/hotoo/pinyin __ https://github.com/mozillazg/go-pinyin __ https://github.com/mozillazg/rust-pinyin +__ https://github.com/wolfgitpr/cpp-pinyin +__ https://github.com/wolfgitpr/csharp-pinyin .. |Build| image:: https://img.shields.io/circleci/project/github/mozillazg/python-pinyin/master.svg diff --git a/README_en.rst b/README_en.rst index 7e81157e..52f3d597 100644 --- a/README_en.rst +++ b/README_en.rst @@ -165,11 +165,15 @@ Related Projects * `hotoo/pinyin`__: A tool for converting Chinese characters to pinyin, Node.js/JavaScript version. * `mozillazg/go-pinyin`__: A tool for converting Chinese characters to pinyin, Go version. * `mozillazg/rust-pinyin`__: A tool for converting Chinese characters to pinyin, Rust version. +* `wolfgitpr/cpp-pinyin`__: A tool for converting Chinese characters to pinyin, Cpp version. +* `wolfgitpr/csharp-pinyin`__: A tool for converting Chinese characters to pinyin, C# version. __ https://github.com/hotoo/pinyin __ https://github.com/mozillazg/go-pinyin __ https://github.com/mozillazg/rust-pinyin +__ https://github.com/wolfgitpr/cpp-pinyin +__ https://github.com/wolfgitpr/csharp-pinyin .. |Build| image:: https://img.shields.io/circleci/project/github/mozillazg/python-pinyin/master.svg diff --git a/README_ru.rst b/README_ru.rst index 4a2aee0d..adfb11bb 100644 --- a/README_ru.rst +++ b/README_ru.rst @@ -91,10 +91,15 @@ Related Projects * `hotoo/pinyin`__: Утилита для пиньин конвертации китайских иероглифов Node.js/JavaScript версия. * `mozillazg/go-pinyin`__: Утилита для пиньин конвертации китайских иероглифов Go версия. * `mozillazg/rust-pinyin`__: Утилита для пиньин конвертации китайских иероглифов Rust версия. +* `wolfgitpr/cpp-pinyin`__: Утилита для пиньин конвертации китайских иероглифов Cpp версия. +* `wolfgitpr/csharp-pinyin`__: Утилита для пиньин конвертации китайских иероглифов C# версия. + __ https://github.com/hotoo/pinyin __ https://github.com/mozillazg/go-pinyin __ https://github.com/mozillazg/rust-pinyin +__ https://github.com/wolfgitpr/cpp-pinyin +__ https://github.com/wolfgitpr/csharp-pinyin .. |Build| image:: https://img.shields.io/travis/mozillazg/python-pinyin/master.svg diff --git a/pypinyin/__pyinstaller/__init__.py b/pypinyin/__pyinstaller/__init__.py new file mode 100644 index 00000000..6c5320a1 --- /dev/null +++ b/pypinyin/__pyinstaller/__init__.py @@ -0,0 +1,7 @@ +# reference: https://github.com/pyinstaller/hooksample/blob/master/src/pyi_hooksample/__pyinstaller/__init__.py # noqa + +import os + + +def get_hook_dirs(): + return [os.path.dirname(__file__)] diff --git a/pypinyin/__pyinstaller/__init__.pyi b/pypinyin/__pyinstaller/__init__.pyi new file mode 100644 index 00000000..a74d06ba --- /dev/null +++ b/pypinyin/__pyinstaller/__init__.pyi @@ -0,0 +1,4 @@ +from typing import Text, List + + +def get_hook_dirs() -> List[Text]: ... diff --git a/pypinyin/__pyinstaller/hook-pypinyin.py b/pypinyin/__pyinstaller/hook-pypinyin.py new file mode 100644 index 00000000..3f9dae6b --- /dev/null +++ b/pypinyin/__pyinstaller/hook-pypinyin.py @@ -0,0 +1,6 @@ +# reference: https://github.com/pyinstaller/hooksample/blob/master/src/pyi_hooksample/__pyinstaller/hook-pyi_hooksample.py # noqa + +from PyInstaller.utils.hooks import collect_data_files # type: ignore + +datas = collect_data_files( + 'pypinyin', excludes=['__pyinstaller']) diff --git a/pytest.ini b/pytest.ini index df24a909..c7b348c6 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,4 +3,4 @@ python_files = test_*.py python_classes = Test python_functions = test addopts = -slv --cov-report term-missing --tb=short --durations=10 --doctest-modules -norecursedirs = .git __pycache__ +norecursedirs = .git __pycache__ pypinyin/__pyinstaller diff --git a/requirements_dev.txt b/requirements_dev.txt index 0652e998..f2a20c06 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -6,8 +6,8 @@ pygments>=2.7.4 # not directly required, pinned by Snyk to avoid a vulnerability pytest pytest-cov pytest-random-order +setuptools Sphinx>=3.0.4 tox twine wheel>=0.21 -setuptools diff --git a/setup.py b/setup.py index 780963c8..bc37d4fc 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,7 @@ 'pypinyin.seg', 'pypinyin.style', 'pypinyin.tools', + 'pypinyin.__pyinstaller', ] requirements = [] @@ -77,6 +78,9 @@ def long_description(): 'console_scripts': [ 'pypinyin = pypinyin.__main__:main', ], + 'pyinstaller40': [ + 'hook-dirs = pypinyin.__pyinstaller:get_hook_dirs' + ], }, classifiers=[ 'Development Status :: 5 - Production/Stable',