Skip to content

Commit

Permalink
Unify the Rust python module and feature setup (#7663)
Browse files Browse the repository at this point in the history
Some AOT work to support a PyO3 upgrade and start on the way to a more optimal, monolithic Rust library to provide python services.

 - Start work on upgrading pyo3 by unifying the pyo3 and tokio versions into the workspace root.
 - Create a universal `python_extension` feature for all modules (older modules turn this on by default and the entire module is disabled if using `--no-default-features`). This feature may be adjusted in the future as we upgrade `pyo3` further.
 - Ensure that `cargo test`, `cargo test --all-features`, and `cargo test --no-default-features` all work.
 - The `wasm-bindgen` feature of `edgeql-parser` had rotted and has been removed entirely.
  • Loading branch information
mmastrac authored Aug 23, 2024
1 parent 0342e22 commit ac57c56
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .github/workflows.src/tests.tpl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
CARGO_TARGET_DIR: ${{ env.BUILD_TEMP }}/rust/extensions
CARGO_HOME: ${{ env.BUILD_TEMP }}/rust/extensions/cargo_home
run:
cargo test
cargo test --all-features

python-test:
needs: build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml

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

120 changes: 8 additions & 112 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ members = [
]
resolver = "2"

[workspace.dependencies]
pyo3 = { version = "0.20.2", features = ["extension-module", "serde"] }
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros", "time", "sync", "net", "io-util"] }

[profile.release]
debug = true
lto = true
Expand Down
7 changes: 2 additions & 5 deletions edb/edgeql-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ edition = "2021"
workspace = true

[dependencies]
pyo3 = { workspace = true, optional = true }

base32 = "0.4.0"
bigdecimal = { version = "0.3.0", features = ["serde"] }
num-bigint = { version = "0.3.0", features = ["serde"] }
sha2 = "0.10.2"
snafu = "0.8.1"
memchr = "2.5.0"
wasm-bindgen = { version = "0.2", features = [
"serde-serialize"
], optional = true }
serde = { version = "1.0.106", features = ["derive"], optional = true }
thiserror = "1.0.23"
unicode-width = "0.1.8"
edgeql-parser-derive = { path = "edgeql-parser-derive", optional = true }
pyo3 = { version = "0.20.2", optional = true }
indexmap = "1.9.3"
serde_json = { version = "1.0", features = ["preserve_order"] }
bumpalo = { version = "3.13.0", features = ["collections"] }
Expand All @@ -31,7 +29,6 @@ append-only-vec = "0.1.2"

[features]
default = []
wasm-lexer = ["wasm-bindgen", "serde"]
python = ["pyo3", "serde", "edgeql-parser-derive"]

[lib]
7 changes: 6 additions & 1 deletion edb/edgeql-parser/edgeql-parser-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ edition = "2021"
[lints]
workspace = true

[features]
python_extension = ["pyo3/extension-module"]
default = ["python_extension"]

[dependencies]
pyo3 = { workspace = true, optional = true }

edgeql-parser = { path = "..", features = ["serde"] }
bytes = "1.0.1"
num-bigint = "0.4.3"
Expand All @@ -18,7 +24,6 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
indexmap = "1.9.3"
once_cell = "1.18.0"
pyo3 = { version = "0.20.2", features = ["extension-module"] }
bincode = { version = "1.3.3" }

[dependencies.edgedb-protocol]
Expand Down
1 change: 1 addition & 0 deletions edb/edgeql-parser/edgeql-parser-python/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "python_extension")]
mod errors;
mod hash;
mod keywords;
Expand Down
1 change: 1 addition & 0 deletions edb/edgeql-parser/edgeql-parser-python/tests/normalize.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "python_extension")]
use edgeql_parser::tokenizer::Value;
use edgeql_rust::normalize::{normalize, Variable};
use num_bigint::BigInt;
Expand Down
2 changes: 0 additions & 2 deletions edb/edgeql-parser/src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ impl Error {
}
}

#[cfg_attr(feature="wasm-bindgen",
wasm_bindgen::prelude::wasm_bindgen(js_name=TokenKind))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
pub enum Kind {
Expand Down
10 changes: 6 additions & 4 deletions edb/graphql-rewrite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ edition = "2021"
[lints]
workspace = true

[features]
python_extension = ["pyo3/extension-module"]
default = ["python_extension"]

[dependencies]
pyo3 = { workspace = true, optional = true }

combine = "3.8"
thiserror = "1.0.11"
num-bigint = "0.4.3"
num-traits = "0.2.11"
edb-graphql-parser = { git="https://github.com/edgedb/graphql-parser" }

[dependencies.pyo3]
version = "0.20.2"
features = ["extension-module"]

[dev-dependencies]
pretty_assertions = "1.2.0"

Expand Down
1 change: 1 addition & 0 deletions edb/graphql-rewrite/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "python_extension")]
mod py_entry;
mod py_exception;
mod py_token;
Expand Down
1 change: 1 addition & 0 deletions edb/graphql-rewrite/tests/rewrite.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "python_extension")]
use std::collections::BTreeMap;

use edb_graphql_parser::Pos;
Expand Down
16 changes: 6 additions & 10 deletions edb/server/conn_pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ python_extension = ["pyo3/extension-module"]
optimizer = []

[dependencies]
pyo3 = { workspace = true, optional = true }
tokio.workspace = true

futures = "0"
scopeguard = "1"
pyo3 = "0"
itertools = "0"
thiserror = "1"
tracing = "0"
Expand All @@ -24,28 +26,22 @@ strum = { version = "0.26", features = ["derive"] }
consume_on_drop = "0"
smart-default = "0"

[dependencies.tokio]
version = "1"
features = ["rt", "time", "sync", "net"]

[dependencies.derive_more]
version = "1.0.0-beta.6"
features = ["full"]

[dev-dependencies]
tokio = { workspace = true, features = ["test-util"] }

pretty_assertions = "1.2.0"
test-log = { version = "0", features = ["trace"] }
anyhow = "1"
rstest = "0"
rand = "0"
statrs = "0"
genetic_algorithm = "0"
genetic_algorithm = "0.7.2"
lru = "0"

[dev-dependencies.tokio]
version = "1"
features = ["macros", "rt-multi-thread", "time", "test-util"]

[lib]
crate-type = ["lib", "cdylib"]
name = "conn_pool"
Expand Down
Loading

0 comments on commit ac57c56

Please sign in to comment.