diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d1af651..de2393c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -110,12 +110,12 @@ jobs: name: wheels-musllinux-${{ matrix.platform.target }} path: dist - name: pytest - if: ${{ !startsWith(matrix.platform.target, 'x86') }} + if: ${{ matrix.platform.target == 'x86_64' }} uses: uraimo/run-on-arch-action@v2 env: PYO3_USE_ABI3_FORWARD_COMPATIBILITY: 1 with: - arch: ${{ matrix.platform.target }} + arch: x86_64 distro: alpine_latest githubToken: ${{ github.token }} install: | diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..5e53f1e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,268 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "crc32c" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a47af21622d091a8f0fb295b88bc886ac74efcc613efc19f5d0b21de5c89e47" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "e57" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "463e55cebbc2333516a69f0b2980a7da2ad94f4306f51d02e6d3b3a213202c96" +dependencies = [ + "crc32c", + "roxmltree", +] + +[[package]] +name = "e57-python" +version = "0.2.1-a1" +dependencies = [ + "e57", + "numpy", + "pyo3", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "matrixmultiply" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06de3016e9fae57a36fd14dba131fccf49f74b40b7fbdb472f96e361ec71a08" +dependencies = [ + "autocfg", + "rawpointer", +] + +[[package]] +name = "memchr" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8" + +[[package]] +name = "ndarray" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb12d4e967ec485a5f71c6311fe28158e9d6f4bc4a447b474184d0f91a8fa32" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits", + "rawpointer", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "numpy" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "778da78c64ddc928ebf5ad9df5edf0789410ff3bdbf3619aed51cd789a6af1e2" +dependencies = [ + "libc", + "ndarray", + "num-complex", + "num-integer", + "num-traits", + "pyo3", + "pyo3-build-config", + "rustc-hash", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pyo3" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91fd8e38a3b50ed1167fb981cd6fd60147e091784c427b8f7183a7ee32c31c12" +dependencies = [ + "libc", + "once_cell", + "portable-atomic", + "pyo3-build-config", + "pyo3-ffi", + "pyo3-macros", +] + +[[package]] +name = "pyo3-build-config" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e368e7ddfdeb98c9bca7f8383be1648fd84ab466bf2bc015e94008db6d35611e" +dependencies = [ + "target-lexicon", +] + +[[package]] +name = "pyo3-ffi" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f29e10af80b1f7ccaf7f69eace800a03ecd13e883acfacc1e5d0988605f651e" +dependencies = [ + "libc", + "pyo3-build-config", +] + +[[package]] +name = "pyo3-macros" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df6e520eff47c45997d2fc7dd8214b25dd1310918bbb2642156ef66a67f29813" +dependencies = [ + "proc-macro2", + "pyo3-macros-backend", + "quote", + "syn", +] + +[[package]] +name = "pyo3-macros-backend" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4cdc218d835738f81c2338f822078af45b4afdf8b2e33cbb5916f108b813acb" +dependencies = [ + "heck", + "proc-macro2", + "pyo3-build-config", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "roxmltree" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1964b10c76125c36f8afe190065a4bf9a87bf324842c05701330bba9f1cacbb" +dependencies = [ + "memchr", +] + +[[package]] +name = "rustc-hash" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-lexicon" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" diff --git a/Cargo.toml b/Cargo.toml index 478defc..85bb07c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ name = "e57" crate-type = ["cdylib"] [dependencies] -pyo3 = "0.21.2" -e57 = { version = "0.11.7",features =["crc32c"]} -numpy = "0.21.0" -ndarray = "0.15.6" +pyo3 = "0.28.3" +e57 = { version = "0.11.12", features = ["crc32c"] } +numpy = "0.28.0" diff --git a/pyproject.toml b/pyproject.toml index cc8a7f2..7c8cf4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [build-system] -requires = ["maturin>=1.0,<2.0"] +requires = ["maturin>=1.13,<2.0"] build-backend = "maturin" [project] name = "e57" +version = "0.2.1a1" dependencies = [ - 'pytest', - 'numpy', + 'numpy>=2,<3', ] description = "Read e57 files to Python. E57 is a compact, non-proprietary point cloud format that's defined by the ASTM E2807 standard. This format is widely adopted by 3D design applications." authors = [ @@ -23,6 +23,11 @@ classifiers = [ "Topic :: File Formats", ] +[project.optional-dependencies] +test = [ + 'pytest>=9,<10', +] + [project.urls] repository = "https://github.com/dancergraham/e57-python" diff --git a/src/lib.rs b/src/lib.rs index a2ef5f8..1c0c79b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,18 +2,18 @@ use std::fs::File; use std::io::BufReader; use ::e57::{CartesianCoordinate, E57Reader}; -use ndarray::Ix2; -use numpy::{PyArray, PyArrayMethods}; +use numpy::ndarray::Array2; +use numpy::{IntoPyArray, PyArray2}; use pyo3::prelude::*; #[pyclass] pub struct E57 { #[pyo3(get)] - pub points: Py>, + pub points: Py>, #[pyo3(get)] - pub color: Py>, + pub color: Py>, #[pyo3(get)] - pub intensity: Py>, + pub intensity: Py>, } /// Extracts the xml contents from an e57 file. @@ -80,27 +80,24 @@ unsafe fn read_points(py: Python<'_>, filepath: &str) -> PyResult { let n_colors = color_vec.len() / 3; let n_intensities = intensity_vec.len(); let mut e57 = E57 { - points: Py::from( - PyArray::from_vec_bound(py, point_vec) - .reshape([nrows, 3]) - .unwrap(), - ), - color: Py::from(PyArray::new_bound(py, (0, 3), false)), - intensity: Py::from(PyArray::new_bound(py, (0, 1), false)), + points: Array2::from_shape_vec((nrows, 3), point_vec) + .unwrap() + .into_pyarray(py) + .unbind(), + color: Array2::::zeros((0, 3)).into_pyarray(py).unbind(), + intensity: Array2::::zeros((0, 1)).into_pyarray(py).unbind(), }; if n_colors == n_points { - e57.color = Py::from( - PyArray::from_vec_bound(py, color_vec) - .reshape([nrows, 3]) - .unwrap(), - ) + e57.color = Array2::from_shape_vec((nrows, 3), color_vec) + .unwrap() + .into_pyarray(py) + .unbind(); } if n_intensities == n_points { - e57.intensity = Py::from( - PyArray::from_vec_bound(py, intensity_vec) - .reshape([nrows, 1]) - .unwrap(), - ) + e57.intensity = Array2::from_shape_vec((nrows, 1), intensity_vec) + .unwrap() + .into_pyarray(py) + .unbind(); } Ok(e57) }