Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds workflow for manylinux wheel creation. #248

Merged
merged 8 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/wheel_generation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Wheel Generation

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

env:
PACKAGE_NAME: maliput_malidrive
COLCON_WS: maliput_ws
PYTHON_VERSION: cp38-cp38
CMAKE_COMMAND_ENV: /opt/_internal/cpython-3.8.18/bin/cmake
# Cancel previously running PR jobs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
manylinux2014:
runs-on: ubuntu-latest
container:
image: ghcr.io/maliput/manylinux2014_maliput:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
path: ${{ env.COLCON_WS }}/src/${{ env.PACKAGE_NAME }}
# clone public dependencies
- name: git clone maliput
shell: bash
working-directory: ${{ env.COLCON_WS }}/src
run: git clone https://github.com/maliput/maliput
- name: colcon graph
run: /opt/python/${PYTHON_VERSION}/bin/colcon graph
shell: bash
working-directory: ${{ env.COLCON_WS }}
# colcon build
- name: colcon build
shell: bash
working-directory: ${{ env.COLCON_WS }}
run: |
source /colcon_builds/install/setup.bash;
PATH=/opt/python/${PYTHON_VERSION}/bin:$PATH \
/opt/python/${PYTHON_VERSION}/bin/colcon build --packages-up-to ${PACKAGE_NAME} \
--cmake-args \
' -DWHEEL_GENERATION=On' \
' -DBUILD_TESTING=Off' \
' -DPython3_EXECUTABLE=/opt/python/${{ env.PYTHON_VERSION }}/bin/python3' \
--event-handlers=console_direct+
# List wheel output
- name: list wheel output
shell: bash
working-directory: ${{ env.COLCON_WS }}
run: ls build/${PACKAGE_NAME}/wheel
# Run auditwheel repair
- name: auditwheel repair
shell: bash
working-directory: ${{ env.COLCON_WS }}
run: |
source install/setup.bash;
auditwheel repair \
--plat manylinux2014_x86_64 \
--wheel-dir build/${PACKAGE_NAME}/wheel/repaired \
build/${PACKAGE_NAME}/wheel/*.whl
# List repaired wheel output
- name: list repaired wheel output
shell: bash
working-directory: ${{ env.COLCON_WS }}
run: ls build/${PACKAGE_NAME}/wheel/repaired
# Upload repaired wheel as artifact
- name: upload wheels as artifact
uses: actions/upload-artifact@v3
with:
name: maliput_malidrive_manylinux2014_x86_64
path: ${{ env.COLCON_WS }}/build/${{ env.PACKAGE_NAME }}/wheel/repaired
retention-days: 7
38 changes: 36 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
##############################################################################

cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(maliput_malidrive LANGUAGES C CXX VERSION 1.0.0)
project(maliput_malidrive LANGUAGES C CXX VERSION 0.1.4)

##############################################################################
# CMake Support
Expand All @@ -19,7 +19,6 @@ include(GNUInstallDirs)
message(STATUS "\n\n====== Finding 3rd Party Packages ======\n")

find_package(ament_cmake REQUIRED)
find_package(gflags REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be moved to src/applications/CMakelists.txt

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


find_package(maliput REQUIRED)

Expand Down Expand Up @@ -76,6 +75,41 @@ else()
message(STATUS "Doxygen generation - Disabled")
endif()


##############################################################################
# Wheel
##############################################################################

if (WHEEL_GENERATION)
include(FetchContent)
message(STATUS "Wheel generation - Enabled")
FetchContent_Declare(python-cmake-wheel
GIT_REPOSITORY "https://github.com/maliput/python-cmake-wheel"
GIT_TAG "main"
GIT_SHALLOW ON)

FetchContent_GetProperties(python-cmake-wheel)
FetchContent_MakeAvailable(python-cmake-wheel)
list(APPEND CMAKE_MODULE_PATH "${python-cmake-wheel_SOURCE_DIR}")
include(python-wheel)
set(WHEEL_DEPLOY_DIRECTORY "${CMAKE_BINARY_DIR}/wheel")

set(DEPLOY_FILES "${PROJECT_SOURCE_DIR}/maliput_malidrive/__init__.py")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we deploy the sample maps?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEPLOY_FILES accepts a list of files, I can't add a folder (in this case resources).

https://github.com/maliput/python-cmake-wheel/blob/main/python-wheel.cmake#L124-L131

I could use resources/* and that will copy all the files directly which will be a mess because they will be thrown in the wheel.

We could also extend that feature in order to accept folders. However probably it makes sense to leave it as an enhancement issue on top of this PR.

I am also thinking that probably, once that is done, we could add a method in the init file for getting a resource so it is easier to deal with.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the tooling is lacking the ability to add data-files. Perhaps we can add it in the future. I agree with deferring that to a follow up PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


add_wheel(road_network
NAME maliput_malidrive
AUTHOR "Franco Cipollone"
URL "https://github.com/maliput/maliput_malidrive"
VERSION "${PROJECT_VERSION}"
DESCRIPTION "OpenDRIVE-based maliput backend."
LICENSE_PATH "${PROJECT_SOURCE_DIR}/LICENSE"
DEPLOY_FILES ${DEPLOY_FILES}
MALIPUT_PLUGIN_ENTRY_POINT "maliput_malidrive = maliput_malidrive:get_plugin_path"
)
else()
message(STATUS "Wheel generation - Disabled")
endif()

##############################################################################
# Export
##############################################################################
Expand Down
5 changes: 5 additions & 0 deletions maliput_malidrive/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os

def get_plugin_path():
# return this location. It is expected to be the plugin located in this same location
return os.path.dirname(os.path.abspath(__file__))
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# Directories
##############################################################################

add_subdirectory(applications)
if(NOT WHEEL_GENERATION)
add_subdirectory(applications)
endif()
add_subdirectory(maliput_malidrive)
add_subdirectory(plugin)
add_subdirectory(utility)
Loading