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

Add infrastructure for packaging and distributing maraboupy #633

Merged
merged 28 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
318fa30
Disable regression test
wenkokke Apr 15, 2023
95be4e6
Remove relative and unneccesary imports in tests
wenkokke Apr 15, 2023
adbd710
Remove codecov from test_requirements.txt
wenkokke Apr 14, 2023
f654440
Relax version bounds in test requirements
wenkokke Apr 15, 2023
c37f3ef
Add Python project and workflow for cibuildwheel
wenkokke Apr 14, 2023
be699ee
Add dependabot
wenkokke Apr 14, 2023
8fcdb3b
Clean up CI workflow
wenkokke Apr 14, 2023
9b71887
Run CI for macOS (#3)
wenkokke Apr 15, 2023
6b9ee67
Change CI workflows to have specific "on" clause
wenkokke Apr 15, 2023
6519b1a
Add test for bumpver config
wenkokke Apr 14, 2023
ada9a16
Bump pybind11 from 2.3.0 to 2.10.4
wenkokke Apr 15, 2023
8577750
Bundle Marabou CLI with maraboupy (#4)
wenkokke Apr 16, 2023
38ad2d5
Ignore __main__.py for codecov
wenkokke Apr 17, 2023
c6b5c90
Switch to SemVer
wenkokke May 16, 2023
0c10e67
Use pypa/cibuildwheel
wenkokke May 16, 2023
a55c5d0
Fix authors and description
wenkokke May 23, 2023
ffb2815
Merge branch 'master' into wheels
wenkokke May 23, 2023
c369020
Fix BumpVer test
wenkokke May 23, 2023
9fbac3d
Set authors to 'The Marabou Development Team'
wenkokke Jun 20, 2023
03320a6
Add pull_request reopened as a CI trigger
wenkokke Jun 20, 2023
d6612b9
Switch 'auto64' to 'native' to rule out cross-compilation
wenkokke Jun 20, 2023
235f2eb
Merge branch 'master' into wheels
wenkokke Jun 20, 2023
45fec26
Switch to latest OS versions for building wheels
wenkokke Jun 20, 2023
0bc2ebe
Suppress unused-arguments and deprecated-declarations for Clang
wenkokke Jun 20, 2023
a5037ae
Fix -Q -> -Wno
wenkokke Jun 20, 2023
6b6a281
Add -Wno-unused-but-set-variable
wenkokke Jun 20, 2023
17431ac
Remove std::ceil and std::floor (#16)
wenkokke Jun 20, 2023
5c3d6c8
Merge branch 'master' into wheels
wenkokke Jun 26, 2023
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
5 changes: 3 additions & 2 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ comment: false

ignore:
- "**/__init__.py"
- "maraboupy/__main__.py"
- "maraboupy/test"
- "maraboupy/test_requirements.txt"

Expand All @@ -18,8 +19,8 @@ coverage:
base: auto
paths:
- "maraboupy"
# Make sure the new added code is at least 80% covered
patch:
# Make sure the new added code is at least 80% covered
patch:
default:
target: 80%
base: auto
Expand Down
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2

updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
114 changes: 85 additions & 29 deletions .github/workflows/ci-with-production.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,91 @@
on: [push, pull_request]
name: CI

on:
# Run CI when changes are pushed to master
push:
branches:
- master

# Run CI when a PR is openend or changes are pushed to the PR
pull_request:
types:
- opened
- synchronize
- reopened

# Run CI every Monday at 7AM to catch bugs due to changes in the ecosystem
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
- cron: "0 7 * * 1"

# Run CI whenever someone with the appropriate privileges requests it
workflow_dispatch:

defaults:
run:
shell: sh

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
compiler: [g++, clang++]
build_type: [Debug, Production]
build_type: [Debug, Release]
include:
- os: macos-latest
compiler: clang++
build_type: Release

runs-on: ubuntu-latest #TODO: macos-latest
name: Debug build
runs-on: ${{ matrix.os }}
name: ${{ matrix.build_type }} build with ${{ matrix.compiler }} on ${{ matrix.os }}

steps:

- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: "3.8"

- name: Install system packages
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y \
build-essential \
ccache \
cmake \
cxxtest \
protobuf-compiler \
libprotoc-dev

- name: Install system packages
if: runner.os == 'macOS'
run: |
brew install \
ccache \
cmake \
cxxtest \
protobuf-c

- name: Install Packages
- name: Install Python packages
run: |
sudo apt-get install -y \
ccache \
cxxtest \
protobuf-compiler \
libprotoc-dev
python3 -m pip install --user --upgrade pip
python3 -m pip install --user --upgrade setuptools
python3 -m pip install --user wheel
python3 -m pip install --user -r maraboupy/test_requirements.txt --cache-dir $HOME/.pip-cache
echo "/usr/lib/ccache" >> $GITHUB_PATH
python -m pip install --user --upgrade pip
python -m pip install --user --upgrade setuptools
python -m pip install --user wheel
python -m pip install --user bumpver
python -m pip install --user -r maraboupy/test_requirements.txt --cache-dir $HOME/.pip-cache
echo "/usr/lib/ccache" >> $GITHUB_PATH

- name: Test BumpVer Configuration
run: python -m bumpver update --patch --no-fetch --dry

- name: Create Build Environment
run: cmake -E make_directory build
Expand All @@ -45,13 +101,13 @@ jobs:
# Add ${{ matrix.cache-key }}- to the key pattern if matrix grows
- name: Restore ccache
id: ccache
uses: actions/cache@v1
uses: actions/cache@v3
env:
cache-name: ccache-
with:
path: ccache-dir
key: ${{ env.cache-name }}-${{ matrix.compiler }}-${{ github.sha }}
restore-keys: ${{ env.cache-name }}-${{ matrix.compiler }}-
key: ${{ env.cache-name }}-${{ matrix.compiler }}-${{ github.sha }}
restore-keys: ${{ env.cache-name }}-${{ matrix.compiler }}-
# ---------------------------- END CACHE RESTORE -------------------------

- name: Configure ccache
Expand All @@ -67,8 +123,8 @@ jobs:
# access regardless of the host operating system
shell: bash
working-directory: build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_PYTHON=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER=${{ matrix.compiler }}

Expand All @@ -78,24 +134,24 @@ jobs:

- name: ccache statistics
run: ccache -s

- name: Run system tests
run: ctest -L system -j 2
working-directory: build

- name: Run regression tests
run: ctest -L regress[0-1] -j 2
if: runner.os == 'Linux'
run: ctest -L regress[0-1] -j 2
working-directory: build


- name: Python Bindings Install Check
run: |
export PYTHONPATH="$PYTHONPATH:$(dirname $(find $GITHUB_WORKSPACE -name "maraboupy" -type d))"
python3 -c "import maraboupy"
python -c "import maraboupy"

- name: Generate Python Code Coverage
if: ${{ ( matrix.compiler == 'g++' ) && ( matrix.build_type == 'Debug' ) }}
run: python3 -m pytest --cov=maraboupy --cov-report=xml maraboupy/test
if: ${{ ( matrix.compiler == 'g++' ) && ( matrix.build_type == 'Debug' ) }}
run: python -m pytest --cov=maraboupy --cov-report=xml maraboupy/test

- name: Upload coverage to Codecov
if: ${{ ( matrix.compiler == 'g++' ) && ( matrix.build_type == 'Debug' ) }}
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/cibuildwheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build wheels

on:
# Run CI when changes are pushed to master
push:
branches:
- master

# Run CI when a PR is openend or changes are pushed to the PR
pull_request:
types:
- opened
- synchronize
- reopened

# Run CI every Monday at 7AM to catch bugs due to changes in the ecosystem
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
- cron: "0 7 * * 1"

# Run CI whenever someone with the appropriate privileges requests it
workflow_dispatch:

defaults:
run:
shell: sh

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest

steps:
- uses: actions/checkout@v3

- name: Build wheel
uses: pypa/cibuildwheel@v2.12.3
with:
output-dir: "./wheelhouse"
config-file: "{package}/pyproject.toml"
env:
MACOSX_DEPLOYMENT_TARGET: "10.9"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
28 changes: 19 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ TAGS
*.so
*.pyc
/src/engine/marabou.elf
tools/boost_1_68_0
/tools/boost.unzipped
/tools/boost_1_68_0.tar.gz
/tools/pybind11-2.3.0
/tools/protobuf*
/tools/OpenBLAS-*/
/tools/OpenBLASv*.tar.gz
/tools/onnx-*/
/cpp_interface_example/example.elf
/src/input_parsers/mps_example/mps.elf

/* CMAKE */
# CMAKE
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
Expand All @@ -38,7 +30,25 @@ install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
/tools/boost_1_68_0
/tools/boost.unzipped
/tools/boost_1_68_0.tar.gz
/tools/pybind11-2.3.0
/tools/pybind11_2_3_0.tar.gz
/tools/pybind11-2.10.4
/tools/pybind11_2_10_4.tar.gz
/tools/protobuf*
/tools/OpenBLAS-*/
/tools/OpenBLASv*.tar.gz
/tools/onnx-*/

build
/.idea/
cmake-build-debug/

# Python
*.egg-info/
/dist/
/build/
/wheelhouse/
.mypy_cache/
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ set(DEPS_DIR "${PROJECT_SOURCE_DIR}/deps")
set(TOOLS_DIR "${PROJECT_SOURCE_DIR}/tools")
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(PYTHON_API_DIR "${PROJECT_SOURCE_DIR}/maraboupy")
if (NOT PYTHON_LIBRARY_OUTPUT_DIRECTORY)
set(PYTHON_LIBRARY_OUTPUT_DIRECTORY "${PYTHON_API_DIR}")
endif()
set(RESOURCES_DIR "${PROJECT_SOURCE_DIR}/resources")
set(REGRESS_DIR "${PROJECT_SOURCE_DIR}/regress")

set(ENGINE_DIR "${SRC_DIR}/engine")
set(PYBIND11_DIR "${TOOLS_DIR}/pybind11-2.3.0")
set(PYBIND11_DIR "${TOOLS_DIR}/pybind11-2.10.4")
set(BOOST_DIR "${TOOLS_DIR}/boost_1_80_0")
set(ONNX_DIR "${TOOLS_DIR}/onnx-1.12.0")
set(OPENBLAS_DEFAULT_DIR "${TOOLS_DIR}/OpenBLAS-0.3.19")
Expand Down Expand Up @@ -100,6 +103,7 @@ endif()

set(PROTOBUF_LIB protobuf)
add_library(${PROTOBUF_LIB} SHARED IMPORTED)
set_property(TARGET ${PROTOBUF_LIB} PROPERTY POSITION_INDEPENDENT_CODE ON)
set_target_properties(${PROTOBUF_LIB} PROPERTIES IMPORTED_LOCATION ${PROTOBUF_DIR}/installed/lib/libprotobuf.a)
target_include_directories(${PROTOBUF_LIB} INTERFACE ${PROTOBUF_DIR}/installed/include)
list(APPEND LIBS ${PROTOBUF_LIB})
Expand Down Expand Up @@ -140,7 +144,7 @@ ProcessorCount(CTEST_NTHREADS)
if(CTEST_NTHREADS EQUAL 0)
set(CTEST_NTHREADS 1)
endif()

# --------------- set build type ----------------------------
set(BUILD_TYPES Release Debug MinSizeRel RelWithDebInfo)

Expand Down Expand Up @@ -191,10 +195,10 @@ if(${BUILD_PYTHON})
endif()

if (NOT MSVC)
if (CMAKE_BUILD_TYPE MATCHES "Release")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(COMPILE_FLAGS -Wall -Wextra -Werror -MMD -Qunused-arguments -Wno-deprecated-declarations -Wno-unused-but-set-variable )
elseif (CMAKE_BUILD_TYPE MATCHES "Release")
set(COMPILE_FLAGS -Wall )
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(COMPILE_FLAGS -Wall -Wextra -Werror -MMD -Qunused-arguments ) #-Wno-deprecated
else()
set(COMPILE_FLAGS -Wall -Wextra -Werror -MMD ) #-Wno-deprecated
endif()
Expand Down Expand Up @@ -324,7 +328,7 @@ if (${BUILD_PYTHON})
target_include_directories(${MARABOU_PY} PRIVATE ${LIBS_INCLUDES})

set_target_properties(${MARABOU_PY} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${PYTHON_API_DIR})
LIBRARY_OUTPUT_DIRECTORY ${PYTHON_LIBRARY_OUTPUT_DIRECTORY})
if(NOT MSVC)
target_compile_options(${MARABOU_LIB} PRIVATE -fPIC ${RELEASE_FLAGS})
endif()
Expand Down Expand Up @@ -423,7 +427,7 @@ execute_process(
)

# Marabou Version
set(MARABOU_VERSION 1.0.+)
set(MARABOU_VERSION 1.0.0)
add_definitions("-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
add_definitions("-DGIT_BRANCH=\"${GIT_BRANCH}\"")
add_definitions("-DMARABOU_VERSION=\"${MARABOU_VERSION}\"")
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include AUTHORS
include THANKS

exclude maraboupy/build_python_x86.sh
exclude maraboupy/README.md
exclude maraboupy/test_requirements.txt

prune maraboupy/docs/
prune maraboupy/examples/
prune maraboupy/test/
Loading