Skip to content

Commit

Permalink
Merge pull request #1099 from messense/fix-sdist
Browse files Browse the repository at this point in the history
Fix sdist when `pyproject.toml` isn't in the same dir of `Cargo.toml`
  • Loading branch information
messense authored Sep 12, 2022
2 parents d7d9d52 + 0780b4d commit 30e55a3
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 40 deletions.
44 changes: 44 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ native-tls-crate = { package = "native-tls", version = "0.2.8", optional = true

[dev-dependencies]
indoc = "1.0.3"
pretty_assertions = "1.3.0"

[features]
default = ["log", "upload", "rustls", "human-panic"]
Expand Down
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* auditwheel: find dylibs in Cargo target directory in [#1092](https://github.com/PyO3/maturin/pull/1092)
* Add library search paths in Cargo target directory to rpath in editable mode on Linux in [#1094](https://github.com/PyO3/maturin/pull/1094)
* Remove default manifest path for `maturin sdist` command in [#1097](https://github.com/PyO3/maturin/pull/1097)
* Fix sdist when `pyproject.toml` isn't in the same dir of `Cargo.toml` in [#1099](https://github.com/PyO3/maturin/pull/1099)

## [0.13.2] - 2022-08-14

Expand Down
1 change: 1 addition & 0 deletions src/auditwheel/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ pub fn relpath(to: &Path, from: &Path) -> PathBuf {
#[cfg(test)]
mod test {
use crate::auditwheel::audit::relpath;
use pretty_assertions::assert_eq;
use std::path::Path;

#[test]
Expand Down
1 change: 1 addition & 0 deletions src/auditwheel/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl Policy {
#[cfg(test)]
mod test {
use super::{Arch, Policy, MANYLINUX_POLICIES, MUSLLINUX_POLICIES};
use pretty_assertions::assert_eq;

#[test]
fn test_load_policy() {
Expand Down
15 changes: 4 additions & 11 deletions src/build_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ pub struct BuildContext {
pub bridge: BridgeModel,
/// Whether this project is pure rust or rust mixed with python
pub project_layout: ProjectLayout,
/// The path to pyproject.toml. Required for the source distribution
pub pyproject_toml_path: PathBuf,
/// Parsed pyproject.toml if any
pub pyproject_toml: Option<PyProjectToml>,
/// Python Package Metadata 2.1
Expand Down Expand Up @@ -176,19 +178,10 @@ impl BuildContext {
fs::create_dir_all(&self.out)
.context("Failed to create the target directory for the source distribution")?;

let include_cargo_lock = self.cargo_options.locked || self.cargo_options.frozen;
match self.pyproject_toml.as_ref() {
Some(pyproject) => {
let sdist_path = source_distribution(
&self.out,
&self.metadata21,
&self.manifest_path,
&self.cargo_metadata,
pyproject.sdist_include(),
include_cargo_lock,
self.project_layout.data.as_deref(),
)
.context("Failed to build source distribution")?;
let sdist_path = source_distribution(self, pyproject)
.context("Failed to build source distribution")?;
Ok(Some((sdist_path, "source".to_string())))
}
None => Ok(None),
Expand Down
3 changes: 3 additions & 0 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ impl BuildOptions {
project_layout,
cargo_toml_path,
cargo_toml,
pyproject_toml_path,
pyproject_toml,
module_name,
metadata21,
Expand Down Expand Up @@ -690,6 +691,7 @@ impl BuildOptions {
target,
bridge,
project_layout,
pyproject_toml_path,
pyproject_toml,
metadata21,
crate_name,
Expand Down Expand Up @@ -1175,6 +1177,7 @@ impl CargoOptions {
#[cfg(test)]
mod test {
use cargo_metadata::MetadataCommand;
use pretty_assertions::assert_eq;
use std::path::Path;

use super::*;
Expand Down
1 change: 1 addition & 0 deletions src/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ pub struct RemainingCoreMetadata {
mod test {
use super::*;
use indoc::indoc;
use pretty_assertions::assert_eq;

#[test]
fn test_metadata_from_cargo_toml() {
Expand Down
1 change: 1 addition & 0 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ fn fold_header(text: &str) -> String {
mod test {
use super::*;
use indoc::indoc;
use pretty_assertions::assert_eq;
use std::io::Write;

fn assert_metadata_from_cargo_toml(readme: &str, cargo_toml: &str, expected: &str) {
Expand Down
3 changes: 3 additions & 0 deletions src/project_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub struct ProjectResolver {
pub cargo_toml_path: PathBuf,
/// Parsed Cargo.toml
pub cargo_toml: CargoToml,
/// pyproject.toml path
pub pyproject_toml_path: PathBuf,
/// Parsed pyproject.toml
pub pyproject_toml: Option<PyProjectToml>,
/// Rust module name
Expand Down Expand Up @@ -143,6 +145,7 @@ impl ProjectResolver {
project_layout,
cargo_toml_path: manifest_file,
cargo_toml,
pyproject_toml_path: pyproject_file,
pyproject_toml,
module_name,
metadata21,
Expand Down
1 change: 1 addition & 0 deletions src/pyproject_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ impl PyProjectToml {
mod tests {
use crate::PyProjectToml;
use fs_err as fs;
use pretty_assertions::assert_eq;
use std::path::Path;
use tempfile::TempDir;

Expand Down
1 change: 1 addition & 0 deletions src/python_interpreter/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ suppress_build_script_link_lines=false"#,
#[cfg(test)]
mod test {
use super::*;
use pretty_assertions::assert_eq;

#[test]
fn test_load_sysconfig() {
Expand Down
Loading

0 comments on commit 30e55a3

Please sign in to comment.