From 01102253370a90d5879d097478003b78c736847b Mon Sep 17 00:00:00 2001 From: wolfgitpr <133209402+wolfgitpr@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:48:03 +0800 Subject: [PATCH 1/5] update Related Projects: add cpp-pinyin (#325) * update Related Projects. * update README. --- README.rst | 2 ++ README_en.rst | 2 ++ README_ru.rst | 3 +++ 3 files changed, 7 insertions(+) diff --git a/README.rst b/README.rst index c51c525..090ab56 100644 --- a/README.rst +++ b/README.rst @@ -236,11 +236,13 @@ Related Projects * `hotoo/pinyin`__: 汉字拼音转换工具 Node.js/JavaScript 版。 * `mozillazg/go-pinyin`__: 汉字拼音转换工具 Go 版。 * `mozillazg/rust-pinyin`__: 汉字拼音转换工具 Rust 版。 +* `wolfgitpr/cpp-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 .. |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 7e81157..089f909 100644 --- a/README_en.rst +++ b/README_en.rst @@ -165,11 +165,13 @@ 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. __ https://github.com/hotoo/pinyin __ https://github.com/mozillazg/go-pinyin __ https://github.com/mozillazg/rust-pinyin +__ https://github.com/wolfgitpr/cpp-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 4a2aee0..0a31f38 100644 --- a/README_ru.rst +++ b/README_ru.rst @@ -91,10 +91,13 @@ Related Projects * `hotoo/pinyin`__: Утилита для пиньин конвертации китайских иероглифов Node.js/JavaScript версия. * `mozillazg/go-pinyin`__: Утилита для пиньин конвертации китайских иероглифов Go версия. * `mozillazg/rust-pinyin`__: Утилита для пиньин конвертации китайских иероглифов Rust версия. +* `wolfgitpr/cpp-pinyin`__: Утилита для пиньин конвертации китайских иероглифов Cpp версия. + __ https://github.com/hotoo/pinyin __ https://github.com/mozillazg/go-pinyin __ https://github.com/mozillazg/rust-pinyin +__ https://github.com/wolfgitpr/cpp-pinyin .. |Build| image:: https://img.shields.io/travis/mozillazg/python-pinyin/master.svg From ae570e64ecbf404c073cabb38fd73f944445c88b Mon Sep 17 00:00:00 2001 From: Shengjie Xu Date: Mon, 9 Sep 2024 10:12:24 -0400 Subject: [PATCH 2/5] =?UTF-8?q?=E8=A7=A3=E5=86=B3#326=EF=BC=9A=E4=BD=BF=20?= =?UTF-8?q?PyInstaller=20=E5=9C=A8=20Windows=20=E4=B8=8B=E6=97=A0=E9=9C=80?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E5=8A=A0=20--collect-data=20pypinyin=20?= =?UTF-8?q?=E5=B0=B1=E5=8F=AF=E6=89=93=E5=8C=85=E7=A8=8B=E5=BA=8F=20(#329)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix issue #326: now pypinyin.__pyinstaller contains hooks to collect data files automatically * Ignore pypinyin/__pyinstaller for testing --------- Co-authored-by: Shengjie Xu --- pypinyin/__pyinstaller/__init__.py | 7 +++++++ pypinyin/__pyinstaller/hook-pypinyin.py | 6 ++++++ pytest.ini | 2 +- setup.py | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 pypinyin/__pyinstaller/__init__.py create mode 100644 pypinyin/__pyinstaller/hook-pypinyin.py diff --git a/pypinyin/__pyinstaller/__init__.py b/pypinyin/__pyinstaller/__init__.py new file mode 100644 index 0000000..3ae3c37 --- /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 + +import os + +def get_hook_dirs(): + return [os.path.dirname(__file__)] + diff --git a/pypinyin/__pyinstaller/hook-pypinyin.py b/pypinyin/__pyinstaller/hook-pypinyin.py new file mode 100644 index 0000000..85f909d --- /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 + +from PyInstaller.utils.hooks import collect_data_files + +datas = collect_data_files('pypinyin', excludes=['__pyinstaller']) + diff --git a/pytest.ini b/pytest.ini index df24a90..c7b348c 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/setup.py b/setup.py index 780963c..bc37d4f 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', From 04a19ba814b20369c1446fa906efec0eb165fe16 Mon Sep 17 00:00:00 2001 From: wolfgitpr <133209402+wolfgitpr@users.noreply.github.com> Date: Sun, 15 Sep 2024 11:23:54 +0800 Subject: [PATCH 3/5] update Related Projects: add csharp-pinyin (#330) --- README.rst | 2 ++ README_en.rst | 2 ++ README_ru.rst | 2 ++ 3 files changed, 6 insertions(+) diff --git a/README.rst b/README.rst index 090ab56..5244c67 100644 --- a/README.rst +++ b/README.rst @@ -237,12 +237,14 @@ Related Projects * `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 089f909..52f3d59 100644 --- a/README_en.rst +++ b/README_en.rst @@ -166,12 +166,14 @@ Related Projects * `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 0a31f38..adfb11b 100644 --- a/README_ru.rst +++ b/README_ru.rst @@ -92,12 +92,14 @@ Related Projects * `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 From 48ec0127ef23355ffc1ddde5833ba335f1361808 Mon Sep 17 00:00:00 2001 From: mozillazg Date: Sun, 15 Sep 2024 03:47:17 +0000 Subject: [PATCH 4/5] prepare for v0.53.0 --- CHANGELOG.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e6c4b18..390cc2f 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 From c64f490b682bb63a3c4a45ff968607734ddf4b75 Mon Sep 17 00:00:00 2001 From: mozillazg Date: Sun, 15 Sep 2024 04:02:06 +0000 Subject: [PATCH 5/5] fix lint --- pypinyin/__pyinstaller/__init__.py | 4 ++-- pypinyin/__pyinstaller/__init__.pyi | 4 ++++ pypinyin/__pyinstaller/hook-pypinyin.py | 8 ++++---- requirements_dev.txt | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 pypinyin/__pyinstaller/__init__.pyi diff --git a/pypinyin/__pyinstaller/__init__.py b/pypinyin/__pyinstaller/__init__.py index 3ae3c37..6c5320a 100644 --- a/pypinyin/__pyinstaller/__init__.py +++ b/pypinyin/__pyinstaller/__init__.py @@ -1,7 +1,7 @@ -# reference: https://github.com/pyinstaller/hooksample/blob/master/src/pyi_hooksample/__pyinstaller/__init__.py +# 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 0000000..a74d06b --- /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 index 85f909d..3f9dae6 100644 --- a/pypinyin/__pyinstaller/hook-pypinyin.py +++ b/pypinyin/__pyinstaller/hook-pypinyin.py @@ -1,6 +1,6 @@ -# reference: https://github.com/pyinstaller/hooksample/blob/master/src/pyi_hooksample/__pyinstaller/hook-pyi_hooksample.py +# 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 - -datas = collect_data_files('pypinyin', excludes=['__pyinstaller']) +from PyInstaller.utils.hooks import collect_data_files # type: ignore +datas = collect_data_files( + 'pypinyin', excludes=['__pyinstaller']) diff --git a/requirements_dev.txt b/requirements_dev.txt index 0652e99..f2a20c0 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