diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 89a7684..bc212fe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,11 @@ on: push: tags: - '*' + branches: + - libosrm + +env: + osrm-tag: v5.26.0 jobs: build_sdist: @@ -22,6 +27,19 @@ jobs: with: path: dist/*.tar.gz + install_osrm: + name: "Cache OSRM" + runs-on: ubuntu-latest + steps: + - name: Install dependencies + run: sudo apt-get install libasio-dev libglpk-dev + - name: Cache OSRM + id: cache + uses: actions/cache@v2 + with: + path: ${{ github.workspace }}/osrm-backend + key: osrm-${{ env.osrm-tag }} + build_wheels: name: ${{ matrix.platform }} runs-on: ${{ matrix.image }} @@ -57,8 +75,8 @@ jobs: with: python-version: '3.x' - - name: Install Conan - if: matrix.image == 'windows-latest' && steps.cache-conan.outputs.cache-hit != 'true' + - name: Conan Install + if: matrix.platform == 'windows' && steps.cache-conan.outputs.cache-hit != 'true' run: | pip install pip --upgrade pip install conan @@ -68,6 +86,17 @@ jobs: conan config set "storage.path=$env:GITHUB_WORKSPACE/conan_data" conan install --build=openssl --install-folder conan_build . + - name: Brew Install + if: matrix.platform == 'macos' + run: brew install asio + + - name: YUM Install + if: matrix.platform == 'linux' + run: | + yum update -y + yum install -y epel-release + yum install -y openssl-devel asio-devel + - uses: pypa/cibuildwheel@v2.3.1 env: MACOSX_DEPLOYMENT_TARGET: 10.14 diff --git a/pyproject.toml b/pyproject.toml index dd703e9..9b1975f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,10 +28,19 @@ skip = "*musllinux*" archs = "native" [tool.cibuildwheel.linux] +build = "cp39-*" before-all = """ -yum update -y -yum install -y epel-release -yum install -y openssl-devel asio-devel +yum install -y scl-utils +yum install -y gcc-toolset-9 +scl enable gcc-toolset-9 bash +yum install git cmake3 zlib-devel +git clone https://github.com/Project-OSRM/osrm-backend.git +cd osrm-backend +mkdir build +cd build +cmake3 .. -DENABLE_MASON=ON -DCMAKE_CXX_COMPILER=/opt/rh/gcc-toolset-9/root/usr/bin/g++ +make +make install """ [[tool.cibuildwheel.overrides]] @@ -40,9 +49,3 @@ before-all = """ apk add asio-dev apk add openssl-dev """ - -[tool.cibuildwheel.macos] - -before-all = """ -brew install asio -""" diff --git a/setup.py b/setup.py index 70b242e..18c2c7d 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,12 @@ import json import logging import os +import shutil import platform from pathlib import Path from setuptools import setup from pybind11.setup_helpers import Pybind11Extension, build_ext +from subprocess import run, PIPE include_dirs = ["src", os.path.join("vroom", "src"), os.path.join("vroom", "include")] libraries = [] @@ -57,6 +59,18 @@ else: logging.warning("Conan not installed and/or no conan build detected. Assuming dependencies are installed.") +if shutil.which("pkg-config") and run(["pkg-config", "--exists", "libosrm"], + stdout=PIPE).stdout == "1": + extra_link_args += run(["pkg-config", "--libs", "libosrm"]).split() + extra_link_args += ["-lboost_system", "-boost_filesystem", "-lboost_iostream", "-lboost_thread -lrt -ltbb"] + extra_compile_args += run(["pkg-config", "--cflags", "libosrm"], + stdout=PIPE).stdout.split() + extra_compile_args += ["-D USE_LIBOSRM"] +else: + logging.warning("Libosrm not found. Package not included.") + + + ext_modules = [ Pybind11Extension( "_vroom", diff --git a/src/_vroom.cpp b/src/_vroom.cpp index 3a2d86d..f8e20de 100644 --- a/src/_vroom.cpp +++ b/src/_vroom.cpp @@ -132,7 +132,7 @@ PYBIND11_MODULE(_vroom, m) { py::class_(m, "Server") .def(py::init(), - py::arg("host") = "0.0.0.0", py::arg("port") = "5000"); + py::arg("host")="0.0.0.0", py::arg("port")="5000"); py::class_(m, "Violations") .def(py::init<>())