Skip to content

Commit

Permalink
Upgrade py03 to 0.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seddonym committed Jun 10, 2024
1 parent 99a10b5 commit fb71cc7
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 99 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ latest
------

* Include wheel for Python 3.13.0-beta.1 in release.
* Upgrade PyO3 to 0.21.

3.2 (2024-1-8)
--------------
Expand Down
51 changes: 33 additions & 18 deletions rust/Cargo.lock

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

4 changes: 2 additions & 2 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
log = "0.4.19"
pyo3-log = "0.8.3"
pyo3-log = "0.10.0"
serde_json = "1.0.103"

[dependencies.pyo3]
version = "0.19.1"
version = "0.21.2"

[features]
extension-module = ["pyo3/extension-module"]
Expand Down
3 changes: 1 addition & 2 deletions rust/src/containers.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::importgraph::ImportGraph;
use std::collections::HashSet;


pub fn check_containers_exist<'a>(
graph: &'a ImportGraph,
containers: &'a HashSet<&'a str>,
containers: &'a HashSet<String>,
) -> Result<(), String> {
for container in containers {
if !graph.contains_module(container) {
Expand Down
62 changes: 39 additions & 23 deletions rust/src/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use std::time::Instant;

/// A group of layers at the same level in the layering.
#[derive(PartialEq, Eq, Hash, Debug)]
pub struct Level<'a> {
pub layers: Vec<&'a str>,
pub struct Level {
pub layers: Vec<String>,
pub independent: bool,
}

pub fn find_illegal_dependencies<'a>(
graph: &'a ImportGraph,
levels: &'a Vec<Level>,
containers: &'a HashSet<&'a str>,
containers: &'a HashSet<String>,
) -> Vec<PackageDependency> {
let mut dependencies: Vec<PackageDependency> = vec![];
let layers = _layers_from_levels(levels);
Expand Down Expand Up @@ -50,7 +50,7 @@ pub fn find_illegal_dependencies<'a>(
fn _generate_module_permutations<'a>(
graph: &'a ImportGraph,
levels: &'a [Level],
containers: &'a HashSet<&'a str>,
containers: &'a HashSet<String>,
) -> Vec<(String, String, Option<String>)> {
let mut permutations: Vec<(String, String, Option<String>)> = vec![];

Expand All @@ -71,7 +71,7 @@ fn _generate_module_permutations<'a>(
continue;
}

// Build the layers that mustn't import this higher layer.
// Build the layers that mustn't import this higher layer.
// That includes:
// * lower layers.
// * sibling layers, if the layer is independent.
Expand Down Expand Up @@ -164,7 +164,7 @@ fn _search_for_package_dependency<'a>(
fn _layers_from_levels<'a>(levels: &'a Vec<Level>) -> Vec<&'a str> {
let mut layers: Vec<&str> = vec![];
for level in levels {
layers.extend(level.layers.iter());
layers.extend(level.layers.iter().map(|s| s.as_str()));
}
layers
}
Expand Down Expand Up @@ -341,15 +341,19 @@ mod tests {
let levels = vec![
Level {
independent: true,
layers: vec!["high"],
layers: vec!["high".to_string()],
},
Level {
independent: true,
layers: vec!["mid_a", "mid_b", "mid_c"],
layers: vec![
"mid_a".to_string(),
"mid_b".to_string(),
"mid_c".to_string(),
],
},
Level {
independent: true,
layers: vec!["low"],
layers: vec!["low".to_string()],
},
];
let containers = HashSet::new();
Expand Down Expand Up @@ -416,14 +420,14 @@ mod tests {
let levels = vec![
Level {
independent: true,
layers: vec!["high"],
layers: vec!["high".to_string()],
},
Level {
independent: true,
layers: vec!["low"],
layers: vec!["low".to_string()],
},
];
let containers = HashSet::from(["mypackage"]);
let containers = HashSet::from(["mypackage".to_string()]);

let dependencies = find_illegal_dependencies(&graph, &levels, &containers);

Expand Down Expand Up @@ -473,18 +477,22 @@ mod tests {
let levels = vec![
Level {
independent: true,
layers: vec!["high"],
layers: vec!["high".to_string()],
},
Level {
independent: true,
layers: vec!["mid_a", "mid_b", "mid_c"],
layers: vec![
"mid_a".to_string(),
"mid_b".to_string(),
"mid_c".to_string(),
],
},
Level {
independent: true,
layers: vec!["low"],
layers: vec!["low".to_string()],
},
];
let containers = HashSet::from(["mypackage"]);
let containers = HashSet::from(["mypackage".to_string()]);

let perms = _generate_module_permutations(&graph, &levels, &containers);

Expand Down Expand Up @@ -593,18 +601,22 @@ mod tests {
let levels = vec![
Level {
independent: true,
layers: vec!["high"],
layers: vec!["high".to_string()],
},
Level {
independent: false,
layers: vec!["mid_a", "mid_b", "mid_c"],
layers: vec![
"mid_a".to_string(),
"mid_b".to_string(),
"mid_c".to_string(),
],
},
Level {
independent: true,
layers: vec!["low"],
layers: vec!["low".to_string()],
},
];
let containers = HashSet::from(["mypackage"]);
let containers = HashSet::from(["mypackage".to_string()]);

let perms = _generate_module_permutations(&graph, &levels, &containers);

Expand Down Expand Up @@ -663,15 +675,19 @@ mod tests {
let levels = vec![
Level {
independent: true,
layers: vec!["high"],
layers: vec!["high".to_string()],
},
Level {
independent: true,
layers: vec!["medium_a", "medium_b", "medium_c"],
layers: vec![
"medium_a".to_string(),
"medium_b".to_string(),
"medium_c".to_string(),
],
},
Level {
independent: true,
layers: vec!["low"],
layers: vec!["low".to_string()],
},
];

Expand Down
Loading

0 comments on commit fb71cc7

Please sign in to comment.