diff --git a/src/develop.rs b/src/develop.rs index a1da79637..9d9357980 100644 --- a/src/develop.rs +++ b/src/develop.rs @@ -44,6 +44,7 @@ pub fn develop( venv_dir: &Path, release: bool, strip: bool, + extras: Vec, ) -> Result<()> { let target = Target::from_target_triple(None)?; @@ -71,14 +72,17 @@ pub fn develop( // 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 mut args = vec!["-m".to_string(), "pip".to_string(), "install".to_string()]; + args.extend(build_context.metadata21.requires_dist.iter().map(|x| { + let mut pkg = x.clone(); + // Remove extra marker to make it installable with pip + for extra in &extras { + pkg = pkg + .replace(&format!(" and extra == '{}'", extra), "") + .replace(&format!("; extra == '{}'", extra), ""); + } + pkg + })); let status = Command::new(&interpreter.executable) .args(&args) .status() diff --git a/src/main.rs b/src/main.rs index 76383fc3b..843202627 100644 --- a/src/main.rs +++ b/src/main.rs @@ -244,6 +244,11 @@ enum Opt { /// Use as `--rustc-extra-args="--my-arg"` #[structopt(long = "rustc-extra-args")] rustc_extra_args: Vec, + /// Install extra requires aka. optional dependencies + /// + /// Use as `--extras=extra1,extra2` + #[structopt(long, use_delimiter = true, multiple = false)] + extras: Vec, }, /// Build only a source distribution (sdist) without compiling. /// @@ -549,6 +554,7 @@ fn run() -> Result<()> { rustc_extra_args, release, strip, + extras, } => { let venv_dir = match (env::var_os("VIRTUAL_ENV"), env::var_os("CONDA_PREFIX")) { (Some(dir), None) => PathBuf::from(dir), @@ -574,6 +580,7 @@ fn run() -> Result<()> { &venv_dir, release, strip, + extras, )?; } Opt::SDist { manifest_path, out } => { diff --git a/tests/common/develop.rs b/tests/common/develop.rs index fa304cf71..dee0c46e1 100644 --- a/tests/common/develop.rs +++ b/tests/common/develop.rs @@ -70,6 +70,7 @@ pub fn test_develop(package: impl AsRef, bindings: Option) -> Resu &venv_dir, false, cfg!(feature = "faster-tests"), + vec![], )?; check_installed(&package.as_ref(), &python)?;