Skip to content

Commit

Permalink
Conda packaging (#88)
Browse files Browse the repository at this point in the history
- Adds meta data and build scripts for conda packaging
- Adds github action CI for conda packaging
- Adds GPL license file
- Adds VERSION file
- Adds version info that gives git-hash and date of current build
  • Loading branch information
davidrich27 authored Sep 18, 2024
1 parent b3672b8 commit fb4ebd8
Show file tree
Hide file tree
Showing 28 changed files with 1,091 additions and 61 deletions.
39 changes: 29 additions & 10 deletions .github/workflows/build-larch.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
name: Build and run tests
name: Build larch on linux and run tests

on:
workflow_dispatch:

jobs:
test:
build-larch:
runs-on: ubuntu-latest

strategy:
matrix:
environment: [build-larch-debug, build-larch-release]
environment: ${{ matrix.environment }}

steps:
- name: Check out code
uses: actions/checkout@v2
Expand All @@ -12,34 +20,45 @@ jobs:
- name: Prepare build environment
run: |
sudo apt-get update
sudo apt-get install build-essential cmake zlib1g-dev python3-pip python3-pytest
sudo apt-get install build-essential zlib1g-dev python3-pip python3-pytest git git-lfs
- name: Install conda
run: |
curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p ~/miniconda
~/miniconda/bin/conda update -n base -c defaults conda
mkdir build
- name: Create conda env
run: |
source ~/miniconda/etc/profile.d/conda.sh
conda env create -f environment.yml
conda config --prepend channels conda-forge
conda config --prepend channels bioconda
conda config --show channels
conda env create -f environment-dev.yml
- name: Build (cmake step)
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE }}
CMAKE_NUM_THREADS: ${{ vars.CMAKE_NUM_THREADS }}
USE_USHER: ${{ vars.USE_USHER }}
run: |
source ~/miniconda/etc/profile.d/conda.sh
conda activate larch-dev
mkdir build
cd build
export CMAKE_NUM_THREADS="8"
cmake -DCMAKE_BUILD_TYPE=Debug ..
export CMAKE_NUM_THREADS=${CMAKE_NUM_THREADS}
cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DUSE_USHER=${USE_USHER} ..
- name: Build (make step)
env:
MAKE_NUM_THREADS: ${{ vars.MAKE_NUM_THREADS }}
run: |
source ~/miniconda/etc/profile.d/conda.sh
conda activate larch-dev
cd build
make -j20
ln -s ../data
make VERBOSE=1 -j${MAKE_NUM_THREADS}
- name: Run tests
env:
LARCH_TEST_FLAGS: ${{ vars.LARCH_TEST_FLAGS }}
run: |
source ~/miniconda/etc/profile.d/conda.sh
conda activate larch-dev
cd build
./larch-test -tag slow
ln -s ../data
./larch-test ${LARCH_TEST_FLAGS}
43 changes: 43 additions & 0 deletions .github/workflows/conda-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build larch on linux and publish to Anaconda Cloud

on:
workflow_dispatch:

jobs:
conda-publish:
runs-on: ubuntu-latest
environment: conda-publish

steps:
- name: Check out code
uses: actions/checkout@v2
with:
submodules: true
- name: Prepare build environment
run: |
sudo apt-get update
sudo apt-get install build-essential zlib1g-dev python3-pip python3-pytest git git-lfs
- name: Install conda
run: |
curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p ~/miniconda
~/miniconda/bin/conda update -n base -c defaults conda
- name: Create conda env
run: |
source ~/miniconda/etc/profile.d/conda.sh
conda config --prepend channels conda-forge
conda config --prepend channels bioconda
conda config --show channels
conda env create -f environment-dev.yml
- name: Build conda package and upload to Anaconda Cloud
env:
ANACONDA_USER: ${{ vars.ANACONDA_USER }}
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
ANACONDA_FLAGS: ${{ vars.ANACONDA_FLAGS }}
INCLUDE_TESTS: ${{ vars.INCLUDE_TESTS }}
run: |
source ~/miniconda/etc/profile.d/conda.sh
conda activate larch-dev
export LARCH_VERSION=$(cat ./VERSION)
export INCLUDE_TESTS=${INCLUDE_TESTS}
conda build . --user ${ANACONDA_USER} --token ${ANACONDA_TOKEN} ${ANACONDA_FLAGS}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ tags
.kak*
cscope.*
*.code-workspace

tools/version.hpp
39 changes: 30 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
cmake_minimum_required(VERSION 3.16)
project(larch)

option(USE_USHER "Use matOptimize" yes)

if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()

set(CMAKE_INTERPROCEDURAL_OPTIMIZATION yes)
set(CMAKE_EXPORT_COMPILE_COMMANDS yes)

include(FetchContent)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build (Debug, Release, RelWithDebInfo, MinSizeRel)" FORCE)
endif()
option(USE_USHER "Use matOptimize" yes)

if(USE_USHER)
set(TBB_VERSION "2019_U9")
else()
set(TBB_VERSION "v2021.11.0")
endif()

message("cmake system architecture: ${CMAKE_SYSTEM_PROCESSOR}")
message("build type: ${CMAKE_BUILD_TYPE}")
message("using usher: ${USE_USHER}")

include(FetchContent)
if(USE_USHER)
FetchContent_Declare(oneTBB-src
GIT_REPOSITORY https://github.com/oneapi-src/oneTBB
GIT_TAG 2019_U9
GIT_TAG ${TBB_VERSION}
GIT_PROGRESS true
)
FetchContent_MakeAvailable(oneTBB-src)

include(${onetbb-src_SOURCE_DIR}/cmake/TBBBuild.cmake)
tbb_build(TBB_ROOT ${onetbb-src_SOURCE_DIR} CONFIG_DIR TBB_DIR MAKE_ARGS tbb_cpf=1 CFLAGS="-w")

find_package(TBB REQUIRED tbbmalloc tbbmalloc_proxy tbb_preview)
find_package(MPI REQUIRED)
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
else()
FetchContent_Declare(oneTBB
GIT_REPOSITORY https://github.com/oneapi-src/oneTBB
GIT_TAG v2021.11.0
GIT_TAG ${TBB_VERSION}
GIT_SHALLOW true
GIT_PROGRESS true
UPDATE_DISCONNECTED true
Expand Down Expand Up @@ -86,6 +100,12 @@ if(${USE_HTSLIB})
)
endif()

add_custom_target(generate_version_h ALL
COMMAND cd ${CMAKE_SOURCE_DIR} && ${CMAKE_COMMAND} -DBUILD_TYPE=${CMAKE_BUILD_TYPE} -P version.cmake
COMMENT "Generating version.hpp with version information"
VERBATIM
)

find_package(ZLIB)

set(STRICT_WARNINGS -Werror -fno-common -Wno-unknown-warning-option -Wno-pragmas -Wall -Wextra -pedantic -Wold-style-cast -Wshadow -Wconversion -Wcast-align -Wcast-qual -Wlogical-op -Wlogical-not-parentheses -Wredundant-decls -Wunreachable-code -Wparentheses -Wno-dangling-reference -Wno-ignored-optimization-argument)
Expand Down Expand Up @@ -181,6 +201,7 @@ function(larch_executable PRODUCT)
target_compile_options(${PRODUCT} PRIVATE ${STRICT_WARNINGS})
larch_link_opts(${PRODUCT})
target_link_libraries(${PRODUCT} PUBLIC larch)
add_dependencies(${PRODUCT} generate_version_h)
endfunction()

add_library(larch
Expand Down Expand Up @@ -271,11 +292,11 @@ if(${USE_USHER})
)
endif()

larch_executable(dag-util
tools/dag-util.cpp)
larch_executable(larch-dagutil
tools/larch-dagutil.cpp)

larch_executable(dag2dot
tools/dag2dot.cpp)
larch_executable(larch-dag2dot
tools/larch-dag2dot.cpp)

if(${USE_USHER})
larch_executable(larch-usher
Expand Down
Loading

0 comments on commit fb4ebd8

Please sign in to comment.