syncstorage-rs
syncstorage-rs copied to clipboard
Commit 0675930 broke optionality of py_verifier feature
Since commit 0675930 (PR #1682) it is impossible to build syncserver without always including pyo3 and thus linking to libpython3.12 -- even if you disabled the py_verifier feature which is the only thing that requires it.
If you build with cargo install --path ./syncserver --no-default-features --features=syncstorage-db/mysql you get an error like:
error: linking with `cc` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/usr/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" VSLANG="1033" "cc" "-m64" <snip a lot of link objects> "-Wl,-Bdynamic" "-lpython3.12" "-lmysqlclient" "-lssl" "-lcrypto" "-lz" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/syncserver/syncstorage-rs/target/release/deps/syncserver-cefe4e14bea94a67" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs"
= note: /usr/bin/ld: cannot find -lpython3.12: No such file or directory
collect2: error: ld returned 1 exit status
error: could not compile `syncserver` (bin "syncserver") due to previous error
error: failed to compile `syncserver v0.18.3 (/tmp/syncserver/syncstorage-rs/syncserver)`, intermediate artifacts can be found at `/tmp/syncserver/syncstorage-rs/target`.
This is because commit 0675930 added pyo3-specific code to the tokenserver-common module, without:
- putting that code under conditional compilation
- making the
pyfeature optional
The following diff fixes the issue, and cargo install --path ./syncserver --no-default-features --features=syncstorage-db/mysql builds without any need for libpython3.12
diff --git a/syncserver/Cargo.toml b/syncserver/Cargo.toml
index 224ac74..851db18 100644
--- a/syncserver/Cargo.toml
+++ b/syncserver/Cargo.toml
@@ -60,6 +60,6 @@ woothee = "0.13"
[features]
default = ["mysql", "py_verifier"]
no_auth = []
-py_verifier = ["tokenserver-auth/py"]
+py_verifier = ["tokenserver-auth/py", "tokenserver-common/py"]
mysql = ["syncstorage-db/mysql"]
spanner = ["syncstorage-db/spanner"]
diff --git a/tokenserver-auth/Cargo.toml b/tokenserver-auth/Cargo.toml
index ed3bfa4..3e8c2c5 100644
--- a/tokenserver-auth/Cargo.toml
+++ b/tokenserver-auth/Cargo.toml
@@ -36,5 +36,4 @@ mockito = "1.4.0"
tokio = { workspace = true, features = ["macros"] }
[features]
-default = ["py"]
py = ["pyo3"]
diff --git a/tokenserver-common/Cargo.toml b/tokenserver-common/Cargo.toml
index 4ba58ff..0beaefb 100644
--- a/tokenserver-common/Cargo.toml
+++ b/tokenserver-common/Cargo.toml
@@ -15,5 +15,4 @@ pyo3 = { version = "0.24", features = ["auto-initialize"], optional = true }
syncserver-common = { path = "../syncserver-common" }
[features]
-default = ["py"]
py = ["pyo3"]
\ No newline at end of file
diff --git a/tokenserver-common/src/error.rs b/tokenserver-common/src/error.rs
index 814c4a2..5793e43 100644
--- a/tokenserver-common/src/error.rs
+++ b/tokenserver-common/src/error.rs
@@ -3,6 +3,7 @@ use std::{cmp::PartialEq, error::Error, fmt};
use actix_web::{HttpResponse, ResponseError};
use backtrace::Backtrace;
use http::StatusCode;
+#[cfg(feature = "py")]
use pyo3::prelude::PyErr;
use serde::{
ser::{SerializeMap, Serializer},
@@ -326,6 +327,7 @@ impl InternalError for TokenserverError {
}
}
+#[cfg(feature = "py")]
impl From<PyErr> for TokenserverError {
fn from(err: PyErr) -> Self {
InternalError::internal_error(err.to_string())