Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
immel-f authored Oct 25, 2024
2 parents 873dbd1 + 55c1f41 commit a0439f0
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 87 deletions.
37 changes: 12 additions & 25 deletions .github/conan_dockerfile/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@ RUN sudo -E apt-get update \
libncursesw5-dev xz-utils libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

# setup python environment
ARG PY_VERSION=3.8
RUN pyenv install -s $PY_VERSION \
ARG PY_VERSION=3.12
RUN pyenv update \
&& pyenv install -s $PY_VERSION \
&& pyenv global $PY_VERSION
RUN pip install "conan==1.59.0" catkin_pkg "numpy<2.0" wheel auditwheel cmake
RUN pip install "conan~=2.8.0" catkin_pkg "numpy<2.0" wheel auditwheel cmake

# install patchelf
RUN wget https://github.com/NixOS/patchelf/releases/download/0.17.2/patchelf-0.17.2-x86_64.tar.gz \
&& tar -xzf patchelf-0.17.2-x86_64.tar.gz \
&& sudo -E ln -s $HOME/bin/patchelf /bin/patchelf \
&& patchelf --version

# setup conan for python dependencies via bincrafters remote
RUN conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan \
&& conan config set general.revisions_enabled=1


FROM lanelet2_conan_deps as lanelet2_conan_src

Expand All @@ -38,28 +35,18 @@ FROM lanelet2_conan_src as lanelet2_conan

# compile
ARG CONAN_ARGS=""
ARG PLATFORM="manylinux_2_31_x86_64"
WORKDIR /home/conan/src/lanelet2
RUN conan create . lanelet2/stable --build=missing ${CONAN_ARGS} \
&& export LANELET2_VERSION=$(conan inspect . --raw version) \
&& echo "Lanelet2 version: $LANELET2_VERSION" \
&& conan install lanelet2/$LANELET2_VERSION@lanelet2/stable --build=missing -g virtualenv
RUN conan profile detect \
&& conan create . --format=json --build=missing -o "&:build_wheel=True" -o "&:platform=${PLATFORM}" ${CONAN_ARGS} > conaninfo.json

# obtain wheel
FROM lanelet2_conan as lanelet2_conan_with_pip_wheel

SHELL ["/bin/bash", "-c"]
WORKDIR /home/conan
RUN source /home/conan/src/lanelet2/activate.sh \
&& LANELET2_PACKAGE_DIR=$(python -c "import lanelet2; from pathlib import Path; print(Path(lanelet2.__file__).parent)") \
&& cp -r $LANELET2_PACKAGE_DIR .
RUN export LANELET2_VERSION=$(conan inspect ./src/lanelet2 --raw version) \
&& echo "Lanelet2 version: $LANELET2_VERSION" \
&& sed 's/{{ version }}/'"$LANELET2_VERSION"'/' /home/conan/src/lanelet2/lanelet2_python/setup.py.template > /home/conan/setup.py

ARG PLATFORM="manylinux_2_31_x86_64"
RUN source /home/conan/src/lanelet2/activate.sh \
&& pip wheel -w broken-dist/ . \
&& auditwheel repair -w dist/ --plat ${PLATFORM} broken-dist/*.whl
RUN LANELET2_PACKAGE_DIR=$(python3 -c "import json; f=open('src/lanelet2/conaninfo.json'); data=json.load(f); ll2=next(d for d in data['graph']['nodes'].values() if 'lanelet2' in d['ref']); print(f'{ll2[\"package_folder\"]}/wheel')") \
&& cp -r $LANELET2_PACKAGE_DIR dist

# to extract the wheel manually run:
# $ docker run -it -v /path/to/some/local/folder:/dist <image> /bin/bash
# then inside the container:
# $ sudo cp dist/lanelet2-<...>.whl /dist/.
# $ docker run --rm -v /path/to/some/local/folder:/dist <image> /bin/bash -c 'sudo cp dist/lanelet2-<...>.whl /dist/.'
19 changes: 11 additions & 8 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11"]
include:
- python-version: "3.8"
boost-version: "1.75.0"
platform-version: manylinux_2_27_x86_64
image-version: conanio/gcc7:latest
- python-version: "3.9"
boost-version: "1.75.0"
platform-version: manylinux_2_27_x86_64
image-version: conanio/gcc7:latest
- python-version: "3.10"
boost-version: "1.81.0"
platform-version: manylinux_2_31_x86_64
image-version: conanio/gcc10:latest
- python-version: "3.11"
boost-version: "1.81.0"
platform-version: manylinux_2_31_x86_64
image-version: conanio/gcc10:latest
- python-version: "3.12"
platform-version: manylinux_2_31_x86_64
image-version: conanio/gcc10:latest
runs-on: ubuntu-latest
Expand All @@ -52,7 +51,6 @@ jobs:
FROM=${{ matrix.image-version }}
PY_VERSION=${{ matrix.python-version }}
PLATFORM=${{ matrix.platform-version }}
CONAN_ARGS=--require-override=boost/${{ matrix.boost-version }}
- name: Create output directory
run: mkdir -p ${{ github.workspace }}/output
Expand Down Expand Up @@ -82,8 +80,8 @@ jobs:
strategy:
matrix:
# test only on currently supported version
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: ["ubuntu-22.04", "ubuntu-20.04"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-20.04", "ubuntu-22.04", "ubuntu-24.04"]
runs-on: ${{ matrix.os }}
steps:
- name: Restore wheel
Expand All @@ -95,8 +93,13 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install wheel 24.04
# use dist/ directory as package source instead of pypi.org
if: ${{ matrix.os == 'ubuntu-24.04' }}
run: pip install lanelet2 --break-system-packages --no-index --find-links dist/
- name: Install wheel
# use dist/ directory as package source instead of pypi.org
if: ${{ matrix.os != 'ubuntu-24.04' }}
run: pip install lanelet2 --no-index --find-links dist/
- name: Test wheel
run: python -c "import lanelet2; assert lanelet2.core.Point2d(0, 0, 0) is not None"
Expand Down Expand Up @@ -124,7 +127,7 @@ jobs:
password: ${{ secrets.PYPI_API_TOKEN }}

deploy-pages:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/master'
concurrency: deploy-${{ github.ref }}
steps:
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,18 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11"]
include:
- python-version: "3.8"
boost-version: "1.75.0"
platform-version: manylinux_2_27_x86_64
image-version: conanio/gcc7:latest
- python-version: "3.9"
boost-version: "1.75.0"
platform-version: manylinux_2_27_x86_64
image-version: conanio/gcc7:latest
- python-version: "3.10"
boost-version: "1.81.0"
platform-version: manylinux_2_31_x86_64
image-version: conanio/gcc10:latest
- python-version: "3.11"
boost-version: "1.81.0"
platform-version: manylinux_2_31_x86_64
image-version: conanio/gcc10:latest
- python-version: "3.12"
platform-version: manylinux_2_31_x86_64
image-version: conanio/gcc10:latest
runs-on: ubuntu-latest
Expand All @@ -220,4 +219,3 @@ jobs:
FROM=${{ matrix.image-version }}
PY_VERSION=${{ matrix.python-version }}
PLATFORM=${{ matrix.platform-version }}
CONAN_ARGS=--require-override=boost/${{ matrix.boost-version }}
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,23 @@ catkin build
If unsure, see the [Dockerfile](Dockerfile) or the [travis build log](https://travis-ci.org/fzi-forschungszentrum-informatik/Lanelet2). It shows the full installation process, with subsequent build and test based on a docker image with a clean Ubuntu installation.

### Manual, experimental installation using conan
**Note: Updated instructions for conan2!**
For non-catkin users, we also offer a conan based install process. Its experimental and might not work on all platforms, especially Windows.
Since conan handles installing all C++ dependencies, all you need is a cloned repository, conan itself and a few python dependencies:
```bash
pip install conan catkin_pkg numpy
conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan # required for python bindings
conan config set general.revisions_enabled=1 # requried to use bincrafters remote
git clone https://github.com/fzi-forschungszentrum-informatik/lanelet2.git
cd lanelet2
```

From here, just use the default conan build/install procedure, e.g.:
```bash
conan source .
conan create . lanelet2/stable --build=missing
conan create . --build=missing
```
Different from the conan defaults, we build lanelet2 and boost as shared libraries, because otherwise the lanelet2's plugin mechanisms as well as boost::python will fail. E.g. loading maps will not be possible and the python API will not be usable.

To be able to use the python bindings, you have to make conan export the PYTHONPATH for lanelet2:
To be able to use the python bindings, you have to make conan export the PYTHONPATH for lanelet2 after `conan create`:
```bash
conan install lanelet2/0.0.0@lanelet2/stable --build=missing -g virtualenv # replace 0.0.0 with the version shown by conan
source activate.sh
python -c "import lanelet2" # or whatever you want to do
source deactivate.sh
Expand Down
Loading

0 comments on commit a0439f0

Please sign in to comment.