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

Maturin, PyO3, pyo3-asyncio, pyo3-logをアップデート #664

Merged
merged 20 commits into from
Oct 29, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ jobs:
pip install --upgrade poetry
poetry install --with dev --with test
- run: cargo build -p test_util -vv # build scriptにより/crates/test_util/data/の生成
# `macos-latest`(=`macos-12`)で次の問題が発生するため、それに対するワークアラウンド
# https://github.com/VOICEVOX/voicevox_core/issues/653#issuecomment-1782108410
- if: startsWith(matrix.os, 'mac')
name: Build open_jtalk-sys
run: |
poetry run -- cargo build -p voicevox_core_python_api -vv || true
[ -n "$(find ../../target/debug/deps -name 'libopen_jtalk_sys-*.rlib')" ]
Comment on lines +283 to +284
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poetry環境でcargo buildする、なるほどです!!

ちなみに|| trueは失敗することがある感じでしょうか? 👀

Copy link
Member Author

@qryxip qryxip Oct 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

失敗の例としては、これですね。
#664 (comment)

open_jtal-sysのビルド(= Maturinの外でcargo buildする目的)はできますがdylibのリンクには失敗します。そしてdylibのリンクまでは不要です (何故ならそっちはそもそもMaturinがやるべきなので)

Copy link
Member

@Hiroshiba Hiroshiba Oct 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

へーーーなるほどです。
リンクに失敗するのも不思議感ありました。とりあえずビルドは進みきりそうなので。

ちなみに将来問題が起きたときのためにお聞きしておきたいのですが、maturinがopen_jtalk-sysのビルドに失敗する(open_jtalkのdylibのリンクに失敗する)のは、何が原因っぽい感じなんでしょう 👀
理由はわからないけどmaturinがmacos-12でビルド後のリンク処理に失敗する、みたいな・・・?

- run: poetry run maturin build --locked
- run: poetry run maturin develop --locked
- name: 必要なDLLをコピーしてpytestを実行
Expand Down
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions crates/voicevox_core_python_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ version = "0.0.0"
edition.workspace = true
publish.workspace = true

[package.metadata.maturin]
name = "voicevox_core._rust"
python-source = "python"

[lib]
crate-type = ["cdylib"]

Expand All @@ -18,9 +14,9 @@ directml = ["voicevox_core/directml"]
easy-ext.workspace = true
log = "0.4.17"
once_cell.workspace = true
pyo3 = { version = "0.18.0", features = ["abi3-py38", "extension-module"] }
pyo3-asyncio = { version = "0.18.0", features = ["tokio-runtime"] }
pyo3-log = "0.8.0"
pyo3 = { version = "0.19.2", features = ["abi3-py38", "extension-module"] }
pyo3-asyncio = { version = "0.19.0", features = ["tokio-runtime"] }
pyo3-log = "0.9.0"
serde.workspace = true
serde_json.workspace = true
tokio.workspace = true
Expand Down
8 changes: 8 additions & 0 deletions crates/voicevox_core_python_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ VOICEVOX CORE の Python バインディングです。
## サンプル実行

`maturin develop` で editable な状態でインストールした後、[example/python](../../example/python) にてサンプルを実行できます。

## トラブルシューティング

Maturinで依存クレート(例: [open\_jtalk-sys](https://github.com/VOICEVOX/open_jtalk-rs))のビルドが失敗する場合は、Maturinの外であらかじめ `cargo build` すれば解決する場合があります。リンクまでは上手くいかないかもしれませんが、該当の依存クレートまではビルドできるかもしれません。

```console
❯ cargo build -p voicevox_core_python_api [--releasee]
```
31 changes: 16 additions & 15 deletions crates/voicevox_core_python_api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions crates/voicevox_core_python_api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ classifiers = [
# readme = "README.md"

[build-system]
requires = ["maturin>=0.13.2,<0.14"]
requires = ["maturin>=1.3.1,<2"]
build-backend = "maturin"

[tool.isort]
profile = "black"

[tool.maturin]
module-name = "voicevox_core._rust"
bindings = "pyo3"
skip-auditwheel = true # Linuxでlibonnxruntime.so.*の不在を許してもらう
python-source = "python"

[tool.poetry]
# Poetryはこれがないと動かない
Expand All @@ -43,7 +45,7 @@ pydata-sphinx-theme = "0.14.1"
sphinx-autoapi = "3.0.0"

[tool.poetry.group.dev.dependencies]
maturin = "0.13.7"
maturin = "1.3.1"

[tool.poetry.group.test.dependencies]
pytest = "7.3.1"
Expand Down