diff --git a/pyproject.toml b/pyproject.toml index a432909..30863ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["maturin>=0.14,<0.15"] +requires = ["maturin~=1.3.0"] build-backend = "maturin" [project] name = "pyoxipng" -requires-python = ">=3.7" +requires-python = ">=3.8" version = "8.0.0" description = "Python wrapper for multithreaded .png image file optimizer oxipng" readme = "README.md" diff --git a/src/lib.rs b/src/lib.rs index 31d3709..0e4b99b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,8 +13,8 @@ create_exception!(oxipng, PngError, PyException); /// Optimize the png file at the given input location. Optionally send it to the /// given output location. #[pyfunction] -#[pyo3(text_signature = "(input, output, **kwargs)")] -fn optimize(input: &PyAny, output: Option<&PyAny>, kwds: Option<&PyDict>) -> PyResult<()> { +#[pyo3(signature = (input, output=None, **kwargs))] +fn optimize(input: &PyAny, output: Option<&PyAny>, kwargs: Option<&PyDict>) -> PyResult<()> { let inpath = PathBuf::from(input.str()?.to_str()?); let outpath = if let Some(out) = output { Some(PathBuf::from(out.str()?.to_str()?)) @@ -25,15 +25,15 @@ fn optimize(input: &PyAny, output: Option<&PyAny>, kwds: Option<&PyDict>) -> PyR let inpath = op::InFile::Path(inpath); let outpath = op::OutFile::Path(outpath); - op::optimize(&inpath, &outpath, &parse::parse_kw_opts(kwds)?) + op::optimize(&inpath, &outpath, &parse::parse_kw_opts(kwargs)?) .or_else(|err| Err(PngError::new_err(parse::png_error_to_string(&err))))?; Ok(()) } #[pyfunction] -#[pyo3(text_signature = "(data, **kwargs)")] -fn optimize_from_memory(data: &PyBytes, kwds: Option<&PyDict>) -> PyResult> { - let output = op::optimize_from_memory(data.as_bytes(), &parse::parse_kw_opts(kwds)?) +#[pyo3(signature = (data, **kwargs))] +fn optimize_from_memory(data: &PyBytes, kwargs: Option<&PyDict>) -> PyResult> { + let output = op::optimize_from_memory(data.as_bytes(), &parse::parse_kw_opts(kwargs)?) .or_else(|err| Err(PngError::new_err(parse::png_error_to_string(&err))))?; Python::with_gil(|py| { let bytes: Py = PyBytes::new(py, &*output).into();