Skip to content

Commit

Permalink
Read pyproject from the parent directory for sdist
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarcireau committed Apr 24, 2024
1 parent 29d42e1 commit d6f04de
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "python"
version = "0.13.2"
version = "0.13.3"
edition = "2021"

[lib]
Expand Down
34 changes: 21 additions & 13 deletions python/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,19 +868,27 @@ fn main() {
.unwrap()
.as_str()
.unwrap();
let pyproject_toml = std::fs::read_to_string("pyproject.toml")
.unwrap()
.parse::<toml::Value>()
.unwrap();
let pyproject_version = pyproject_toml
.get("project")
.unwrap()
.get("version")
.unwrap()
.as_str()
.unwrap();
if cargo_version != pyproject_version {
panic!("the cargo version ({cargo_version}) and the pyproject version ({pyproject_version}) are different");
let pyproject_toml_contents =
std::fs::read_to_string("pyproject.toml").ok().or_else(|| {
std::fs::canonicalize("pyproject.toml")
.ok()
.map(|path| path.parent().map(|parent| parent.to_owned()))
.flatten()
.map(|parent| std::fs::read_to_string(parent.join("pyproject.toml")).ok())
.flatten()
});
if let Some(pyproject_toml_contents) = pyproject_toml_contents {
let pyproject_toml = pyproject_toml_contents.parse::<toml::Value>().unwrap();
let pyproject_version = pyproject_toml
.get("project")
.unwrap()
.get("version")
.unwrap()
.as_str()
.unwrap();
if cargo_version != pyproject_version {
panic!("the cargo version ({cargo_version}) and the pyproject version ({pyproject_version}) are different");
}
}
}
if std::env::var("TARGET").unwrap().contains("apple") {
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
{name = "International Centre for Neuromorphic Systems"},
{name = "Alexandre Marcireau"},
]
version = "0.13.2"
version = "0.13.3"
requires-python = ">=3.8"
dependencies = ["numpy>=1.24"]

Expand Down

0 comments on commit d6f04de

Please sign in to comment.