与Maturin的混合Python/Rust Project中的预订版本编号

发布于 2025-01-28 20:16:29 字数 982 浏览 1 评论 0原文

我正在研究一个混合锈/python项目,正在使用Maturin进行。我在弄清楚如何指定可以比PIP安装的预订版本时遇到困难。

我的货物的开始是

[package]
version = "0.0.1-test.1"

当我进行maturin build-release时,它创建my_project-0.0.0.0.1_test.1-cp39-cp39-cp39-macosx_10_10_7_x86_64.whl。请注意,版本中的0.0.1-test.1以轮子的名称更改为0.0.1_test.1。 (破折号变成了下划线。)

如果我将其发布到我的Nexus Server并尝试将其安装在单独的项目中,则pip会出现一个错误:

$ pip install  my_project==0.0.1_test.1
Looking in indexes: ...
ERROR: Could not find a version that satisfies the requirement my_project==0.0.1_test.1 (from versions: 0.0.1-test.1, 0.0.1.dev1)

如果我尝试使用dash而不是底漆:

pip install  py_mod_query_builder==0.0.1-test.1
Looking in indexes: ...
ERROR: Exception:
<stack trace>
pip._vendor.packaging.version.InvalidVersion: Invalid version: '0.0.1-test.1'

如果我将货物中的版本更改为0.0.1_troy.1,那么货物将无法解析构建文件:

$ maturin build --release

              

I am working on a mixed Rust/Python project being build with maturin. I am having trouble figuring out how I can specify a pre-release version that can than be installed by pip.

The start of my Cargo.toml is

[package]
version = "0.0.1-test.1"

When I do maturin build --release, it creates my_project-0.0.1_test.1-cp39-cp39-macosx_10_7_x86_64.whl. Note that 0.0.1-test.1 in the version was changed to 0.0.1_test.1 in the name of the wheel file. (The dash became an underscore.)

If I publish this to my Nexus server and try to install it in a separate project, pip gives an error:

$ pip install  my_project==0.0.1_test.1
Looking in indexes: ...
ERROR: Could not find a version that satisfies the requirement my_project==0.0.1_test.1 (from versions: 0.0.1-test.1, 0.0.1.dev1)

If I try it with a dash instead of an underscore:

pip install  py_mod_query_builder==0.0.1-test.1
Looking in indexes: ...
ERROR: Exception:
<stack trace>
pip._vendor.packaging.version.InvalidVersion: Invalid version: '0.0.1-test.1'

If I change the version in Cargo.toml to 0.0.1_troy.1, then Cargo fails to parse the build file:

$ maturin build --release
???? Building a mixed python/rust project
???? maturin failed
  Caused by: Cargo metadata failed. Do you have cargo in your PATH?
  Caused by: Error during execution of `cargo metadata`: error: failed to parse manifest at `/Users/me/my-project/Cargo.toml`

Caused by:
  unexpected character '_' after patch version number for key `package.version`

I did have some success with pip install path/to/my_project*.whl. However, that is difficult to incorporate into building a docker image. The wheel is outside the project with the Dockerfile, so docker will not be able to find it without jumping through a bunch of hoops, while downloading it from the server during the docker build is simple, but fails due to the dash/underscore problem.

Additionally, while both projects are being developed, I would like the CI pipeline for the development branch to use the pre-release version. Getting access to the wheel file (without having pip download it) is nearly impossible in that situation.

It seems that Cargo insists on the format being #.#.#-string and pip insists on it being #.#.#_string. Is there a way to make both of them happy?

Versions:

  • Installing project
    • pip 22.1
    • python 3.9.12
  • Building project
    • pip 20.0.4
    • python 3.9.12
    • maturin 0.8.3
    • rustc 1.56.1 (59eed8a2a 2021-11-01)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文