Jij-Inc / pyo3-stub-gen

Stub file (*.pyi) generator for PyO3
Apache License 2.0
61 stars 12 forks source link

Versions of pyo3 conflict when building with pyo3 0.22.0 #66

Closed cardigan1008 closed 3 months ago

cardigan1008 commented 3 months ago

In my project, I include pyo3 0.22.0 like this:

pyo3 = { version = "0.22.0", features = [
    "extension-module",
    "multiple-pymethods",
], optional = true }

I also include pyo3-stub-gen and pyo3-stub-gen-derive 0.6.0 like this:

pyo3-stub-gen = "0.6.0"
pyo3-stub-gen-derive = "0.6.0"

When I run cargo build, it turns out that the building process terminated because of version conflicts:

error: failed to select a version for pyo3.
    ... required by package numpy v0.21.0
    ... which satisfies dependency numpy = ">=0.21.0" of package pyo3-stub-gen v0.6.0
    ... which satisfies dependency pyo3-stub-gen = "^0.6.0" of package hifitime v4.0.0-alpha.1 (/path/to/myproject)
versions that meet the requirements ^0.21.0 are: 0.21.2, 0.21.1, 0.21.0

the package pyo3 links to the native library python, but it conflicts with a previous package which links to python as well:
package pyo3 v0.22.0
    ... which satisfies dependency pyo3 = "^0.22.0" of package myproject v4.0.0-alpha.1 (/path/to/myproject)
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the links = "python" value. For more information, see https://doc.rust-lang.org
/cargo/reference/resolver.html#links.

My project relies on pyo3 0.22.0 and I tried to change the version to 0.21.2 etc. as the error mentioned. However, some features are missing. So is there any solution to deal with this conflict?

termoshtt commented 3 months ago

This looks caused by numpy crate, which does not support PyO3 0.22 yet. It is required from pyo3-stub-gen with numpy feature which is enabled by default. Please try following:

pyo3-stub-gen = { version = "0.6.0", default-features = false }
cardigan1008 commented 3 months ago

This looks caused by numpy crate, which does not support PyO3 0.22 yet. It is required from pyo3-stub-gen with numpy feature which is enabled by default. Please try following:

pyo3-stub-gen = { version = "0.6.0", default-features = false }

Thanks for your prompt response. It works :)