Skip to content

Commit

Permalink
pip-package. MPV. MME (#16)
Browse files Browse the repository at this point in the history
* manylinux-wheel

* Set build tests OFF by default

* Added dependency to map_metrics_cpp target

* [quickfix] Allowed git to run scripts from /scripts

* Added chmod line in workflow

* Specified cpp standard in script

* quickfix syntax error

* Removed parallel jobs

* Explicitly set std=c++17 flag

* Updated gcc in script

* Try to pass init value into reduce

* Replaced reduce with std::accumulate

* configured setup.py

* fixed name in setup.cfg

* Fixes in setup.py

* Try to specify package_data lib

* __init__.py workaround

* set build shared cilantro off

* MORE workaround setup.py

* Filled init.py and fixed path to data in python tests

* quickfix initpy

* quickfix for quickfix

* Fixed tests

* I will squash. Every. Commit. In this branch.

* v0.0.3 linux

* Added windows and osx into wheels.yml

* Added build wheels scripts for windows and osx

* Modified setup.py

* macos fix build whee;

* Specified std=c++17 for macos

* quickfix wheels.yml

* fixed typo in cmake_cxx_standard_required

* try to specify cxx flag in script

* changed macosx deployment target 10.14

* Set root_is_pure=False for OSX

* Added auditwheel into macOS script, try to repair

* once again try mrob setup.py

* fixed setup error

* Fixed macos target version in test_wheel_macos

* Returned linux build tests

* Returned windows build tests

* Fixed readme

Co-authored-by: Arthur_Ch <56088401+ArthurChains@users.noreply.github.com>
  • Loading branch information
achains and achains committed Dec 12, 2021
1 parent 42ad9fb commit 0bee315
Show file tree
Hide file tree
Showing 42 changed files with 754 additions and 134 deletions.
284 changes: 284 additions & 0 deletions .github/workflows/wheels.yml
@@ -0,0 +1,284 @@
# # # # # # # # #
# Source: https://github.com/miloserdova-l/mrob/blob/feature/windows-wheel/.github/workflows/wheels.yml
# # # # # # # # #
name: Build wheels

on: [push, pull_request, workflow_dispatch]

jobs:
build:
name: Build map_metrics project
runs-on: ubuntu-latest
env:
PYTHONPATH: ./lib
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2

- name: Install required packages from distro
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends git build-essential g++ cmake python3-distutils python3-dev python3-numpy python3-pip
python3 -m pip install pytest
- name: Configure and build native map_metrics library with Python bindings
run: |
mkdir -p build
cmake -S $PWD -B $PWD/build \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$PWD/bin \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$PWD/lib \
-DCMAKE_BUILD_TYPE=RELEASE \
&& cmake --build build -j $(nproc)
build_wheel_linux:
name: Build wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
container: quay.io/pypa/manylinux2010_x86_64
needs: build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- name: Install additional utils
run: yum install -y git openssh-clients

- uses: actions/checkout@v1

- name: Install fresh CMake into ManyLinux container
run: |
env pybin=$(LANG=C ls -d1r /opt/python/cp3*/bin | head -n 1) bash -c '$pybin/python -m pip install cmake && mkdir -p /usr/local/bin && ln -svf $pybin/cmake /usr/local/bin/cmake'
cmake --version
- name: Build Python wheel
run: |
chmod -R +x scripts/* \
&& scripts/build-wheels-linux.sh
- uses: actions/upload-artifact@v1
with:
name: artifact
path: ./wheelhouse

build_wheel_macOS:
name: Build wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: build
strategy:
fail-fast: false
matrix:
os: [ macos-10.15 ]
steps:
- uses: actions/checkout@v2

- name: Git fetch
run: git fetch --prune --unshallow --recurse-submodules=no

- name: Install packages
run: |
brew install coreutils \
&& brew install gcc
- name: Build wheel
run: ./scripts/build-wheels-macOS.sh

- uses: actions/upload-artifact@v2
with:
path: ./dist

build_wheel_windows:
name: Build wheel on ${{ matrix.os }} ${{ matrix.arch }}
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-2019 ]
arch: [ x64, x86 ]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Git fetch
run: git fetch --prune --unshallow --recurse-submodules=no

- name: Setup Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
architecture: ${{ matrix.arch }}
- name: Setup Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
architecture: ${{ matrix.arch }}
- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
architecture: ${{ matrix.arch }}
- name: Setup Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: ${{ matrix.arch }}
- name: Setup Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
architecture: ${{ matrix.arch }}

- name: Build wheel
run: .\scripts\build-wheels-windows.cmd ${{ matrix.arch }}
- uses: actions/upload-artifact@v2
with:
path: .\dist

test_wheel_linux:
name: Test Python ${{ matrix.python }} wheel on Linux
runs-on: ubuntu-latest
needs: build_wheel_linux
strategy:
fail-fast: false
matrix:
python: ['3.6', '3.7', '3.8', '3.9', '3.10']
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

- name: Download artifacts
uses: actions/download-artifact@v2

- name: Install map_metrics & numpy
run: |
python -m pip install ./artifact/map_metrics-*-manylinux*.whl numpy pytest
- name: "Python unit tests"
run: |
python -m pytest python
test_wheel_macos:
name: Test Python ${{ matrix.python }} wheel on macOS
runs-on: macos-latest
needs: build_wheel_macos
strategy:
fail-fast: false
matrix:
python: ['3.6', '3.7', '3.8', '3.9', '3.10']
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

- name: Download artifacts
uses: actions/download-artifact@v2

- name: Install map_metrics & numpy
run: |
python -m pip install ./artifact/map_metrics-*-macosx_10_14_x86_64.whl numpy pytest
- name: "Python unit tests"
run: |
python -m pytest python
test_wheel_windows64:
name: Test Python ${{ matrix.python }} wheel on Windows 64bit
runs-on: windows-latest
needs: build_wheel_windows
strategy:
fail-fast: false
matrix:
python: ['3.6', '3.7', '3.8', '3.9', '3.10']
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

- name: Download artifacts
uses: actions/download-artifact@v2

- name: Install map_metrics & numpy
run: |
python -m pip install .\artifact\$(dir artifact -Name | findstr map_metrics-.*-win_amd64.whl) numpy pytest
- name: "Python unit tests"
run: |
python -m pytest python
test_wheel_windows32:
name: Test Python ${{ matrix.python }} wheel on Windows 32bit
runs-on: windows-latest
needs: build_wheel_windows
strategy:
fail-fast: false
matrix:
python: ['3.6', '3.7', '3.8', '3.9', '3.10']
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
architecture: x86

- name: Download artifacts
uses: actions/download-artifact@v2

- name: Install map_metrics & numpy
run: |
python -m pip install .\artifact\$(dir artifact -Name | findstr map_metrics-.*-win32.whl) numpy
- name: "Python unit tests"
run: |
$files = Get-ChildItem -Path python_examples -Include *.py
foreach ($f in $files){
python $f.FullName || EXIT /B !ERRORLEVEL!
}
publish_pypi:
name: Publish wheels to PyPI
needs:
- test_wheel_linux
- test_wheel_macos
- test_wheel_windows64
- test_wheel_windows32
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v2

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: artifact/

publish-github-release:
name: Publish wheels to GitHub Releases
needs:
- test_wheel_linux
- test_wheel_macos
- test_wheel_windows64
- test_wheel_windows32
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v2

- uses: softprops/action-gh-release@v1
with:
files: artifact/*.whl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion AUTHORS.rst
Expand Up @@ -10,4 +10,4 @@ Development Lead
Contributors
------------

None yet. Why not be the first?
* Arthur Saliou a.k.a. "achains" <arthur.salio@gmail.com>
10 changes: 5 additions & 5 deletions CMakeLists.txt
Expand Up @@ -3,12 +3,12 @@ project(map-metrics)

# Compiler prerequisites
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# # # # # # OPTIONS # # # # # #
option(GLIBCXX_USE_CXX11_ABI "Set -D_GLIBCXX_USE_CXX11_ABI=1" OFF)
# Set this flag ON if you want to build tests
option(BUILD_TESTS "Build an executable with tests" ON)
option(BUILD_TESTS "Build an executable with tests" OFF)
# Set this flag ON if you want to build Python library interface
option(BUILD_PYTHON_MODULE "Build the python module" ON)

Expand All @@ -18,10 +18,10 @@ if (WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()

# By default select Debug build
# By default select Release build
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "No CMAKE_BUILD_TYPE specified, default to Debug.")
set(CMAKE_BUILD_TYPE "Debug")
message(STATUS "No CMAKE_BUILD_TYPE specified, default to Release.")
set(CMAKE_BUILD_TYPE "Release")
endif()

# If Build type is Release, then turn on optimizations
Expand Down
11 changes: 0 additions & 11 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -35,7 +35,7 @@ Features
Our toolkit provides implementation of the next metrics:

* Mean Map Entropy (MME), Mean Plane Variance(MPV) [#]_ [#]_
* Mutually Orthogonal Metric (MOM) [#]_ -- has strong correlation with RPE
* Mutually Orthogonal Metric (MOM) [#]_ -- has strong correlation with RPE **(IN PROGRESS, SEE PREVIOUS VERSIONS)**


Citation
Expand Down

0 comments on commit 0bee315

Please sign in to comment.