Tro*_*els 5 python version rust
我正在开发一个使用 maturin 构建的混合 Rust/Python 项目。我无法弄清楚如何指定可以通过 pip 安装的预发行版本。
我的 Cargo.toml 的开头是
[package]
version = "0.0.1-test.1"
Run Code Online (Sandbox Code Playgroud)
当我这样做时maturin build --release,它就创造了my_project-0.0.1_test.1-cp39-cp39-macosx_10_7_x86_64.whl。请注意,0.0.1-test.1在版本中更改为0.0.1_test.1wheel 文件的名称。(破折号变成了下划线。)
如果我将其发布到我的 Nexus 服务器并尝试将其安装在单独的项目中,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)
Run Code Online (Sandbox Code Playgroud)
如果我尝试使用破折号而不是下划线:
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'
Run Code Online (Sandbox Code Playgroud)
如果我将 Cargo.toml 中的版本更改为 0.0.1_troy.1,则 Cargo 无法解析构建文件:
$ 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`
Run Code Online (Sandbox Code Playgroud)
我确实取得了一些成功pip install path/to/my_project*.whl。然而,这很难融入到构建 Docker 镜像中。轮子在 Dockerfile 的项目之外,因此 docker 不经过一堆麻烦就找不到它,而在 docker 构建期间从服务器下载它很简单,但由于破折号/下划线问题而失败。
此外,虽然这两个项目都在开发中,但我希望开发分支的 CI 管道使用预发布版本。在这种情况下,访问 Wheel 文件(无需 pip 下载)几乎是不可能的。
看来 Cargo 坚持格式为#.#.#-string,pip 坚持格式为#.#.#_string。有没有什么办法可以让两个人都幸福呢?
版本: