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

maturn develop install dependencies automatically #443

Merged
merged 1 commit into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Support local path dependencies in source distribution (i.e. you can now package a workspace into an sdist)
* Set a more reasonable LC_ID_DYLIB entry on macOS by messense [#433](https://github.com/PyO3/maturin/pull/433)
* Add `--skip-existing` option to publish by messense [#444](https://github.com/PyO3/maturin/pull/444)
* maturn develop install dependencies automatically by messense [#443](https://github.com/PyO3/maturin/pull/443)

## 0.9.4 - 2021-02-18

Expand Down
22 changes: 21 additions & 1 deletion src/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use crate::Manylinux;
use crate::PythonInterpreter;
use crate::Target;
use crate::{write_dist_info, BuildOptions};
use anyhow::{anyhow, format_err, Context, Result};
use anyhow::{anyhow, bail, format_err, Context, Result};
use fs_err as fs;
use std::path::Path;
use std::process::Command;

/// Installs a crate by compiling it and copying the shared library to site-packages.
/// Also adds the dist-info directory to make sure pip and other tools detect the library
Expand Down Expand Up @@ -46,6 +47,25 @@ pub fn develop(
anyhow!("Expected `python` to be a python interpreter inside a virtualenv ಠ_ಠ")
})?;

// 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,)
}
}

let mut builder = PathWriter::venv(&target, &venv_dir, &build_context.bridge)?;

let context = "Failed to build a native library through cargo";
Expand Down
1 change: 1 addition & 0 deletions test-crates/pyo3-mixed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ classifier = [
"Programming Language :: Python",
"Programming Language :: Rust"
]
requires-dist = ["boltons"]

[dependencies]
pyo3 = { version = "0.13.2", features = ["extension-module"] }
Expand Down
3 changes: 3 additions & 0 deletions test-crates/pyo3-mixed/check_installed/check_installed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env python3

from boltons.strutils import slugify
import pyo3_mixed

assert pyo3_mixed.get_42() == 42
assert slugify("First post! Hi!!!!~1 ") == "first_post_hi_1"

print("SUCCESS")
2 changes: 1 addition & 1 deletion test-dockerfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fi

docker run --rm -v $(pwd)/test-crates/pyo3-mixed:/io maturin build --no-sdist -i python3.8

venv-docker/bin/pip install pyo3-mixed --no-index --find-links test-crates/pyo3-mixed/target/wheels/
venv-docker/bin/pip install pyo3-mixed --find-links test-crates/pyo3-mixed/target/wheels/

if [[ $(venv-docker/bin/python test-crates/pyo3-mixed/check_installed/check_installed.py) != 'SUCCESS' ]]; then
exit 1
Expand Down