gis-ops / pyvalhalla

High-level Python bindings to the Valhalla routing framework.
GNU General Public License v2.0
58 stars 4 forks source link

PyValhalla for mac os arm #31

Open baileyheading opened 1 year ago

baileyheading commented 1 year ago

Hi,

I managed to hack PyValhalla to run a Mac os arm valhalla build I made a week or so ago

Once the isochrone issues I encountered are sorted, I should be able to help out with the build process for PyValhalla

Can't say I know exactly what is going on in the build scripts here, but to me it looks like the main thing to change from "build_mac.sh" would be pathing to the mac os arm location

nilsnolde commented 1 year ago

That'd be really nice to have a user reporting how to do it.

Not sure we'd ever really have a pipeline to publish M1 binaries on PyPI as long as there's no easily accessible & free M1 runners on GHA. It can be done locally as well (build all minor Python versions separately and publish them manually), but it's painful and I can tell 100% that no one would commit to that long-term (or very soon un-commit after starting;)).

baileyheading commented 1 year ago

It seems this is on the GitHub roadmap for Q4 2023

https://github.com/github/roadmap/issues/528

image

kkostov commented 4 months ago

It seems GitHub has added support for ARM based distributions of macOS. It would be an amazing improvement to DX if Valhalla's python bindings work on ARM Macs.

nilsnolde commented 4 months ago

yeah, we're already using that in upstream valhalla to build.

to be clear, python bindings are working for apple silicon, they're just not distributed on pypi. fwiw, it'd be better to do the packaging directly in valhalla as part of our release workflow. but that'll need quite a bit of work, especially for linux.

if someone is really interested, over enquiry@gis-ops.com I'm open for this type of commercial enquiries.

baileyheading commented 4 months ago

I basically just pip installed PyValhalla for Mac Intel, built Valhalla for Mac ARM, then copied the PyValhalla site_packages stuff from python Intel env into a new python arm env and replaced it with the stuff I built (and renamed a few things until errors went away). Valhalla in ARM is a little faster, but the most significant gain is that you can run your regular python code in ARM.

nilsnolde commented 4 months ago

Easiest is probably to just “sudo” install all of Valhalla, which will also install the Python bindings in the right place, unless you have a strange Python setup .

baileyheading commented 4 months ago

Things can get a bit messy if you have different environments (I like to use Conda) and Rosetta intel + arm environments. I had such a hard time getting it to use the exact python version I wanted I gave up and hardcoded it into the CMake in Valhalla (pro move)

nilsnolde commented 4 months ago

Haha yeah I can imagine. In theory I guess CMake should make it easy via some variables but I can imagine it's not necessarily working as expected always.. At least Valhalla is not relying on Rosetta stuff anymore and can be installed natively now on apple silicon.