mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-07-09 21:54:59 +00:00
fix release build failures due to libpython linking (#125)
This commit is contained in:
parent
9398df6a21
commit
7ef503d866
5 changed files with 42 additions and 17 deletions
|
@ -26,22 +26,30 @@ pub fn setup_python_linking() {
|
|||
// Get the Python interpreter configuration directly
|
||||
let config = pyo3_build_config::get();
|
||||
|
||||
// Add the library search path if available
|
||||
let is_extension_module = std::env::var("CARGO_FEATURE_EXTENSION_MODULE").is_ok();
|
||||
|
||||
// Only link libpython explicitly if we are NOT building an extension module.
|
||||
if !is_extension_module {
|
||||
if let Some(lib_name) = &config.lib_name {
|
||||
println!("cargo:rustc-link-lib=dylib={}", lib_name);
|
||||
} else {
|
||||
// Warn only if linking is actually needed but we can't find the lib name
|
||||
println!("cargo:warning=Python library name not found in config (needed for non-extension module
|
||||
builds).");
|
||||
}
|
||||
}
|
||||
|
||||
// Add the library search path and RPATH if available.
|
||||
// These are needed for test executables and potential future standalone binaries,
|
||||
// and generally harmless for extension modules.
|
||||
if let Some(lib_dir) = &config.lib_dir {
|
||||
println!("cargo:rustc-link-search=native={}", lib_dir);
|
||||
|
||||
// Add RPATH linker argument for Unix-like systems (Linux, macOS)
|
||||
// This helps the test executable find the Python library at runtime.
|
||||
#[cfg(not(windows))]
|
||||
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_dir);
|
||||
} else {
|
||||
println!("cargo:warning=Python library directory not found in config.");
|
||||
}
|
||||
|
||||
// Add the library link directive if available
|
||||
if let Some(lib_name) = &config.lib_name {
|
||||
println!("cargo:rustc-link-lib=dylib={}", lib_name);
|
||||
} else {
|
||||
println!("cargo:warning=Python library name not found in config.");
|
||||
// Warn only if linking is actually needed but we can't find the lib dir
|
||||
if !is_extension_module {
|
||||
println!("cargo:warning=Python library directory not found in config.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@ name = "djls-project"
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
extension-module = []
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
pyo3 = { workspace = true }
|
||||
tower-lsp-server = { workspace = true, features = ["proposed"] }
|
||||
|
|
|
@ -3,6 +3,10 @@ name = "djls-server"
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
extension-module = []
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
djls-conf = { workspace = true }
|
||||
djls-project = { workspace = true }
|
||||
|
|
|
@ -7,11 +7,20 @@ edition = "2021"
|
|||
name = "djls"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[features]
|
||||
extension-module = [
|
||||
"djls-server/extension-module",
|
||||
"djls-project/extension-module",
|
||||
"pyo3/extension-module"
|
||||
]
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
djls-project = { workspace = true }
|
||||
djls-server = { workspace = true }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
pyo3 = { workspace = true, features = ["extension-module"] }
|
||||
pyo3 = { workspace = true }
|
||||
pyo3-async-runtimes = { workspace = true, features = ["tokio-runtime"] }
|
||||
serde_json = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue