urschrei / polylabel-rs

A Rust implementation of the Polylabel algorithm, with FFI.
https://docs.rs/polylabel
Other
54 stars 8 forks source link

Python wheel #3

Open elocke opened 4 years ago

elocke commented 4 years ago

Hello,

Are you planning on creating a python wheel to utilize this binary? I have a use and was looking at the steps of creating one when I saw that you are making python packages for many of your rust implementations.

Thanks!

urschrei commented 4 years ago

I don't think so, because https://shapely.readthedocs.io/en/latest/manual.html#polylabel exists already. The only reason to use the Rust version is performance, since the Shapely Polylabel is a pure Python implementation.

elocke commented 4 years ago

Wow, prompt reply! Thanks!

The only reason to use the Rust version is performance, since the Shapely Polylabel is a pure Python implementation.

This would be why I'm currently searching for a low-level implementation.

urschrei commented 4 years ago

Ah, gotcha. One thing you could do (before I build a wheel, which will be post-Christmas), is use the existing Python implementation at https://github.com/urschrei/polylabel-rs/blob/master/ffi.py.

  1. Clone the repo
  2. Install Rust using rustup.rs
  3. cd into the repo
  4. Create a virtualenv inside, activate it, and install Shapely.
  5. Run cargo build --release
  6. Still in the repo, write a Python script that processes your Polygons – just have a from ffi import label_position line, and call label_position(polygon, tolerance) on each one.

It's not the most robust solution, especially if you need to run on a server, but for locally processing your geometries it should do just fine. Let me know if you need a wheel, but it'll most likely be the weekend before I get to it.

elocke commented 4 years ago

Oh nice, I'll give it a shot at this problem I'm currently experiencing. Shouldn't be too hard to add to my Dockerfile. I would absolutely appreciate a wheel at some point in the future. Thanks again for the fast (and detailed) response!

urschrei commented 4 years ago

No prob – doing it in Docker might be annoying, so ping me if you need a wheel.

elocke commented 4 years ago

Yeah, I can't have this in my production containers (security) so at some point it will be required, perhaps after the holiday. This is my first time working with Rust, and it's making want to dig in more.

elocke commented 4 years ago

I've run some tests using the ffi module directly and it is a great improvement over the Shapely methods. A wheel would definitely be the next step. Any idea of when you could do that? Thanks!

elocke commented 4 years ago

Just an update: I ended up hacking up a solution to bake a wheel locally for my container. I used your simplification python package as an example. I'll shoot ya an email to see where you want to go from here. Thanks!

ahirner commented 2 years ago

@elocke You might find https://github.com/MoonVision/polylabel-pyo3 helpful. It supports exterior only for now.

urschrei commented 2 years ago

@ahirner This is great!