mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
Python: build against abi3 to support multiple Python versions
- Upgrade to pyo3 0.21 to enable timedelta for chrono - Enable abi3 for multi-python support
This commit is contained in:
parent
4c1d406561
commit
6408eaf0ad
7 changed files with 15 additions and 11 deletions
|
@ -21,7 +21,7 @@ crate-type = ["cdylib"]
|
|||
i-slint-backend-selector = { workspace = true }
|
||||
i-slint-core = { workspace = true }
|
||||
slint-interpreter = { workspace = true, features = ["default", "display-diagnostics", "internal"] }
|
||||
pyo3 = { version = "0.20.0", features = ["extension-module", "indexmap", "chrono"] }
|
||||
pyo3 = { version = "0.21.0", features = ["extension-module", "indexmap", "chrono", "abi3-py310"] }
|
||||
indexmap = { version = "2.1.0" }
|
||||
chrono = "0.4"
|
||||
spin_on = "0.1"
|
||||
|
|
|
@ -224,7 +224,7 @@ impl ComponentInstance {
|
|||
Ok(self.instance.get_property(name)?.into())
|
||||
}
|
||||
|
||||
fn set_property(&self, name: &str, value: &PyAny) -> PyResult<()> {
|
||||
fn set_property(&self, name: &str, value: Bound<'_, PyAny>) -> PyResult<()> {
|
||||
let pv: PyValue = value.extract()?;
|
||||
Ok(self.instance.set_property(name, pv.0).map_err(|e| PySetPropertyError(e))?)
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ impl ComponentInstance {
|
|||
&self,
|
||||
global_name: &str,
|
||||
prop_name: &str,
|
||||
value: &PyAny,
|
||||
value: Bound<'_, PyAny>,
|
||||
) -> PyResult<()> {
|
||||
let pv: PyValue = value.extract()?;
|
||||
Ok(self
|
||||
|
@ -251,7 +251,7 @@ impl ComponentInstance {
|
|||
}
|
||||
|
||||
#[pyo3(signature = (callback_name, *args))]
|
||||
fn invoke(&self, callback_name: &str, args: &PyTuple) -> PyResult<PyValue> {
|
||||
fn invoke(&self, callback_name: &str, args: Bound<'_, PyTuple>) -> PyResult<PyValue> {
|
||||
let mut rust_args = vec![];
|
||||
for arg in args.iter() {
|
||||
let pv: PyValue = arg.extract()?;
|
||||
|
@ -265,7 +265,7 @@ impl ComponentInstance {
|
|||
&self,
|
||||
global_name: &str,
|
||||
callback_name: &str,
|
||||
args: &PyTuple,
|
||||
args: Bound<'_, PyTuple>,
|
||||
) -> PyResult<PyValue> {
|
||||
let mut rust_args = vec![];
|
||||
for arg in args.iter() {
|
||||
|
@ -339,8 +339,8 @@ impl GcVisibleCallbacks {
|
|||
let callables = callables.borrow();
|
||||
let callable = callables.get(&name).unwrap();
|
||||
Python::with_gil(|py| {
|
||||
let py_args = PyTuple::new(py, args.iter().map(|v| PyValue(v.clone())));
|
||||
let result = match callable.call(py, py_args, None) {
|
||||
let py_args = PyTuple::new_bound(py, args.iter().map(|v| PyValue(v.clone())));
|
||||
let result = match callable.call_bound(py, py_args, None) {
|
||||
Ok(result) => result,
|
||||
Err(err) => {
|
||||
eprintln!(
|
||||
|
|
|
@ -23,7 +23,7 @@ fn quit_event_loop() -> Result<(), errors::PyEventLoopError> {
|
|||
use pyo3::prelude::*;
|
||||
|
||||
#[pymodule]
|
||||
fn slint(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
||||
fn slint(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
|
||||
i_slint_backend_selector::with_platform(|_b| {
|
||||
// Nothing to do, just make sure a backend was created
|
||||
Ok(())
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import nox
|
||||
|
||||
@nox.session
|
||||
@nox.session(python="3.10")
|
||||
def python(session: nox.Session):
|
||||
session.env["MATURIN_PEP517_ARGS"] = "--profile=dev"
|
||||
session.install(".[dev]")
|
||||
|
|
|
@ -7,7 +7,8 @@ build-backend = "maturin"
|
|||
|
||||
[project]
|
||||
name = "slint"
|
||||
version = "1.6.0a3"
|
||||
version = "1.6.0a4"
|
||||
requires-python = ">= 3.10"
|
||||
authors = [
|
||||
{name = "Slint Team", email = "info@slint.dev"},
|
||||
]
|
||||
|
|
|
@ -44,7 +44,7 @@ impl<'a> ToPyObject for PyValueRef<'a> {
|
|||
slint_interpreter::Value::Struct(structval) => structval
|
||||
.iter()
|
||||
.map(|(name, val)| (name.to_string().into_py(py), PyValueRef(val).into_py(py)))
|
||||
.into_py_dict(py)
|
||||
.into_py_dict_bound(py)
|
||||
.into_py(py),
|
||||
slint_interpreter::Value::Brush(brush) => {
|
||||
crate::brush::PyBrush::from(brush.clone()).into_py(py)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue