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

Merge metadata with project table in pyproject.toml #555

Merged
merged 5 commits into from
Jun 3, 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
11 changes: 11 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 @@ -67,6 +67,7 @@ toml_edit = "0.2.0"
once_cell = "1.7.2"
scroll = "0.10.2"
target-lexicon = "0.12.0"
pyproject-toml = "0.1.0"
messense marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
indoc = "1.0.3"
Expand Down
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unrelease

* Add support for reading metadata from [PEP 621](https://www.python.org/dev/peps/pep-0621/) project table in `pyproject.toml` in [#555](https://github.com/PyO3/maturin/pull/555)
* Users should migrate away from the old `[package.metadata.maturin]` table of `Cargo.toml` to this new `[project]` table of `pyproject.toml`
* Add PEP 656 musllinux support in [#543](https://github.com/PyO3/maturin/pull/543)
* `--manylinux` is now called `--compatibility` and supports musllinux
* The pure rust install layout changed from just the shared library to a python module that reexports the shared library. This should have now observable consequences for users of the created wheel expect that `my_project.my_project` is now also importable (and equal to just `my_project`)
Expand Down
27 changes: 5 additions & 22 deletions src/build_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::Target;
use anyhow::{anyhow, bail, Context, Result};
use cargo_metadata::Metadata;
use fs_err as fs;
use std::collections::HashMap;
use std::path::{Path, PathBuf};

/// The way the rust code is used in the wheel
Expand Down Expand Up @@ -127,8 +126,6 @@ pub struct BuildContext {
pub project_layout: ProjectLayout,
/// Python Package Metadata 2.1
pub metadata21: Metadata21,
/// The `[console_scripts]` for the entry_points.txt
pub scripts: HashMap<String, String>,
/// The name of the crate
pub crate_name: String,
/// The name of the module can be distinct from the package name, mostly
Expand Down Expand Up @@ -240,13 +237,7 @@ impl BuildContext {
let platform = self.target.get_platform_tag(platform_tag, self.universal2);
let tag = format!("cp{}{}-abi3-{}", major, min_minor, platform);

let mut writer = WheelWriter::new(
&tag,
&self.out,
&self.metadata21,
&self.scripts,
&[tag.clone()],
)?;
let mut writer = WheelWriter::new(&tag, &self.out, &self.metadata21, &[tag.clone()])?;

write_bindings_module(
&mut writer,
Expand Down Expand Up @@ -301,13 +292,7 @@ impl BuildContext {
) -> Result<BuiltWheelMetadata> {
let tag = python_interpreter.get_tag(platform_tag, self.universal2);

let mut writer = WheelWriter::new(
&tag,
&self.out,
&self.metadata21,
&self.scripts,
&[tag.clone()],
)?;
let mut writer = WheelWriter::new(&tag, &self.out, &self.metadata21, &[tag.clone()])?;

write_bindings_module(
&mut writer,
Expand Down Expand Up @@ -397,8 +382,7 @@ impl BuildContext {
.target
.get_universal_tags(platform_tag, self.universal2);

let mut builder =
WheelWriter::new(&tag, &self.out, &self.metadata21, &self.scripts, &tags)?;
let mut builder = WheelWriter::new(&tag, &self.out, &self.metadata21, &tags)?;

write_cffi_module(
&mut builder,
Expand Down Expand Up @@ -436,12 +420,11 @@ impl BuildContext {
.target
.get_universal_tags(platform_tag, self.universal2);

if !self.scripts.is_empty() {
if !self.metadata21.scripts.is_empty() {
bail!("Defining entrypoints and working with a binary doesn't mix well");
}

let mut builder =
WheelWriter::new(&tag, &self.out, &self.metadata21, &self.scripts, &tags)?;
let mut builder = WheelWriter::new(&tag, &self.out, &self.metadata21, &tags)?;

match self.project_layout {
ProjectLayout::Mixed {
Expand Down
2 changes: 0 additions & 2 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ impl BuildOptions {
let metadata21 = Metadata21::from_cargo_toml(&cargo_toml, &manifest_dir)
.context("Failed to parse Cargo.toml into python metadata")?;
let extra_metadata = cargo_toml.remaining_core_metadata();
let scripts = cargo_toml.scripts();

let crate_name = &cargo_toml.package.name;

Expand Down Expand Up @@ -231,7 +230,6 @@ impl BuildOptions {
bridge,
project_layout,
metadata21,
scripts,
crate_name: crate_name.to_string(),
module_name,
manifest_path: self.manifest_path,
Expand Down
7 changes: 1 addition & 6 deletions src/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,7 @@ pub fn develop(
}
};

write_dist_info(
&mut writer,
&build_context.metadata21,
&build_context.scripts,
&tags,
)?;
write_dist_info(&mut writer, &build_context.metadata21, &tags)?;

// https://packaging.python.org/specifications/recording-installed-packages/#the-installer-file
writer.add_bytes(
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ fn pep517(subcommand: Pep517Command) -> Result<()> {
};

let mut writer = PathWriter::from_path(metadata_directory);
write_dist_info(&mut writer, &context.metadata21, &context.scripts, &tags)?;
write_dist_info(&mut writer, &context.metadata21, &tags)?;
println!("{}", context.metadata21.get_dist_info_dir().display());
}
Pep517Command::BuildWheel {
Expand Down
Loading