mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-08-05 10:38:06 +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
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
|
@ -48,7 +48,7 @@ jobs:
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
args: --release --out dist --find-interpreter
|
args: --release --out dist --find-interpreter --features extension-module
|
||||||
sccache: "true"
|
sccache: "true"
|
||||||
manylinux: auto
|
manylinux: auto
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ jobs:
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
args: --release --out dist --find-interpreter
|
args: --release --out dist --find-interpreter --features extension-module
|
||||||
manylinux: musllinux_1_2
|
manylinux: musllinux_1_2
|
||||||
|
|
||||||
- name: Upload wheels
|
- name: Upload wheels
|
||||||
|
@ -112,7 +112,7 @@ jobs:
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
args: --release --out dist --find-interpreter
|
args: --release --out dist --find-interpreter --features extension-module
|
||||||
sccache: "true"
|
sccache: "true"
|
||||||
|
|
||||||
- name: Upload wheels
|
- name: Upload wheels
|
||||||
|
@ -141,7 +141,7 @@ jobs:
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
args: --release --out dist --find-interpreter
|
args: --release --out dist --find-interpreter --features extension-module
|
||||||
sccache: "true"
|
sccache: "true"
|
||||||
|
|
||||||
- name: Upload wheels
|
- name: Upload wheels
|
||||||
|
|
|
@ -26,22 +26,30 @@ pub fn setup_python_linking() {
|
||||||
// Get the Python interpreter configuration directly
|
// Get the Python interpreter configuration directly
|
||||||
let config = pyo3_build_config::get();
|
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 {
|
if let Some(lib_dir) = &config.lib_dir {
|
||||||
println!("cargo:rustc-link-search=native={}", 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))]
|
#[cfg(not(windows))]
|
||||||
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_dir);
|
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_dir);
|
||||||
} else {
|
} else {
|
||||||
println!("cargo:warning=Python library directory 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.");
|
||||||
// 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.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@ name = "djls-project"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
extension-module = []
|
||||||
|
default = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
pyo3 = { workspace = true }
|
pyo3 = { workspace = true }
|
||||||
tower-lsp-server = { workspace = true, features = ["proposed"] }
|
tower-lsp-server = { workspace = true, features = ["proposed"] }
|
||||||
|
|
|
@ -3,6 +3,10 @@ name = "djls-server"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
extension-module = []
|
||||||
|
default = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
djls-conf = { workspace = true }
|
djls-conf = { workspace = true }
|
||||||
djls-project = { workspace = true }
|
djls-project = { workspace = true }
|
||||||
|
|
|
@ -7,11 +7,20 @@ edition = "2021"
|
||||||
name = "djls"
|
name = "djls"
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
extension-module = [
|
||||||
|
"djls-server/extension-module",
|
||||||
|
"djls-project/extension-module",
|
||||||
|
"pyo3/extension-module"
|
||||||
|
]
|
||||||
|
default = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
djls-project = { workspace = true }
|
||||||
djls-server = { workspace = true }
|
djls-server = { workspace = true }
|
||||||
|
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
pyo3 = { workspace = true, features = ["extension-module"] }
|
pyo3 = { workspace = true }
|
||||||
pyo3-async-runtimes = { workspace = true, features = ["tokio-runtime"] }
|
pyo3-async-runtimes = { workspace = true, features = ["tokio-runtime"] }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue