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

How to specify extras to install optional-dependencies? #604

Closed
posutsai opened this issue Aug 5, 2021 · 8 comments · Fixed by #635
Closed

How to specify extras to install optional-dependencies? #604

posutsai opened this issue Aug 5, 2021 · 8 comments · Fixed by #635
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@posutsai
Copy link

posutsai commented Aug 5, 2021

Hi,
I would like to install the dependencies specified in "optional-dependencies" in pyproject.toml as pyO3-pure. However, I don't know how to add extras argument in maturin develop. There is no related information in help message. Thank you.

@messense
Copy link
Member

messense commented Aug 5, 2021

maturin develop doesn't support install optional dependencies yet. For now you can do maturin build and using pip to install the wheel to specify extras for example pip install path/to/pyo3-pure.whl[test]'

@Smurphy000
Copy link

I think this could be useful feature, any idea what the effort might be to add this ability?

@messense
Copy link
Member

maturin/src/develop.rs

Lines 50 to 67 in b556ed1

// Install dependencies
if !build_context.metadata21.requires_dist.is_empty() {
let mut args = vec!["-m", "pip", "install"];
args.extend(
build_context
.metadata21
.requires_dist
.iter()
.map(|x| x.as_str()),
);
let status = Command::new(&interpreter.executable)
.args(&args)
.status()
.context("Failed to run pip install")?;
if !status.success() {
bail!(r#"pip install finished with "{}""#, status)
}
}

Just need to add optional dependencies here. The question is what to install since you can specify multiple extras with multiple dependencies in pyproject.toml for example:

[project.optional-dependencies]
test = [
  "pytest < 5.0.0",
  "pytest-cov[all]"
]
web = ["flask"]

@Smurphy000
Copy link

are you referring to test / web or that pytest-cov[all] is nested in test ?

@messense
Copy link
Member

are you referring to test / web or that pytest-cov[all] is nested in test ?

test / web

@houqp
Copy link
Contributor

houqp commented Aug 27, 2021

how about passing selected extras as arguments for the develop command?

@messense
Copy link
Member

how about passing selected extras as arguments for the develop command?

I think it's ok.

@messense
Copy link
Member

Released in v0.11.4-beta.4: https://pypi.org/project/maturin/0.11.4_beta.4/#files , you can install it with pip install -U --pre maturin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants