Sergey
Sergey

Reputation: 21201

Rust cargo: how to use different features for a dep when a particular feature is enabled?

For example I define 2 features without dependencies:

[features]
default = []
py2 = []
py3 = []

Based on selected feature (--features py3) I want to enable different features for a dependency (cpython):

[dependencies.cpython]
default-features = false
# features = ["python27-sys"]      I want to select this if py2 is enabled
features = ["python3-sys"]
optional = true

Can I do this? Or simply can I select features for a dependency from command line as well?

Upvotes: 8

Views: 1452

Answers (1)

Sergey
Sergey

Reputation: 21201

It was discussed here. One can do it with /.

[features]
default = []
py2 = ["cpython", "cpython/python27-sys"]
py3 = ["cpython", "cpython/python3-sys"]
unstable = []

[dependencies.cpython]
# git = "https://github.com/dgrunwald/rust-cpython.git"
default-features = false
optional = true

I've seen nothing about it in documentation or official pages.

Upvotes: 8

Related Questions