Skip to content

Commit

Permalink
Update recipe conda forge (#27)
Browse files Browse the repository at this point in the history
* Add manual triggering option for build

* Fix version regex in recipe

* Use SSH to clone the MATLAB headers

This should be more secure than the password.

* Prefer ruamel.yaml dependency

* Fix complaints about unsatisfied dependency on ruamel.yaml

* Don't fail if there's nothing to delete

* Whoops the MATLAB headers need the SSH key

* WIP updates to the recipe SKIP CI

* Try these config settings

* Bump Python 3.10 to NumPy 1.21

* Try to work around Accelerate failures on macOS

* Try to fix missing Python on Linux

* Update Windows scripts as well

* Debug SSH failures

* Fix some syntax errors

* Move debugging

* Bump python for Matlab builds

* Try to fix the builds

* Debugging

* Typo

* Typo

* >_<

* Remove rpath linking from SCons

* More debugging!

* Fix Windows wheel install

* Try to fix cloning the matlab headers

* Figure out why scons is rebuilding

* Try rsync for the matlab headers

* Update recipe dependencies to avoid rebuild

* Fix libcantera tests

* Bit more debugging

* Don't run tests on Python 3.10

Pytest is too old from the main channel

* Fix the matlab recipe yaml

* Split the library build

* Fix Windows rsync

* Fix Matlab Windows/macOS builds

* Fix libcantera/Python builds

* Fixes for Windows

* Fixes for Matlab

* Fixes for missing deps

* Fixes and fixes!

* Try to remove some dependencies

I'm not sure why these would be required for the lib* recipe.

* Remove Windows rename_shared_libs option

Let's see how this breaks now

* Use Python to set MW_HEADERS on Win

rsync needs a /cygdrive style path

* Linux/macOS building updates

* Try again to fix Matlab Windows rsync

* Another try at Windows

* Another rsync try

* I'm just guessing at this point

* A separate rsync for Windows

* Another rsync try

* Debug

* Debug!

* Need a bindir

* Single quotes?

* Only run the POSIX rsync on POSIX

* Gotta use a different name for the rsync dir

* Move rpath rewrite above interface build

* Try Windows 2022 runner

* Switch to MSVC 14.2

* Build the interface first

* Cut alpha and beta off the PKG_VERSION

* Also cut rc from version

* Try modern compilers settting on Windows

* Try different dependency versions

To avoid rebuilding quite so many times

* Remove `path` source

* Add input to workflow dispatch for uploading [skip ci]

Co-authored-by: Ray Speth <speth@mit.edu>
  • Loading branch information
bryanwweber and speth authored Feb 16, 2022
1 parent 5c13711 commit 6b7f509
Show file tree
Hide file tree
Showing 14 changed files with 234 additions and 158 deletions.
4 changes: 2 additions & 2 deletions .ci_support/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
python:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
numpy:
- '1.16'
- '1.16'
- '1.16'
- '1.19'
- '1.21'
zip_keys:
- - python
- numpy
Expand Down
58 changes: 49 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,25 @@ on:
# Build when a pull request targets main
branches:
- main
workflow_dispatch:
inputs:
upload:
description: Attempt to upload to Anaconda
required: true
default: "false"

env:
MW_HEADERS_DIR: ${{ github.workspace }}/../mw_headers
MACOSX_DEPLOYMENT_TARGET: "10.9"

jobs:
build-x64:
name: ${{ matrix.os }}-x64 with MATLAB=${{ matrix.MATLAB }}
build:
name: ${{ matrix.os }} with MATLAB=${{ matrix.MATLAB }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
MATLAB: [0, 1]
os: [windows-2016, ubuntu-latest, macos-latest]
os: [windows-2019, ubuntu-latest, macos-latest]
fail-fast: false
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -63,12 +70,45 @@ jobs:
shell: bash -l {0}
run: conda build ./cantera -m ./.ci_support/conda_build_config.yaml
if: matrix.MATLAB == 0
- name: Get the MATLAB headers
# The known_hosts key is generated with `ssh-keygen -F cantera.org` from a
# machine that has previously logged in to cantera.org and trusts
# that it logged in to the right machine
- name: Set up SSH key and host for cloning MATLAB
if: matrix.MATLAB == 1
run: git clone https://cantera:${GIT_PW}@cantera.org/mw_headers.git "${MW_HEADERS_DIR}"
env:
GIT_PW: ${{ secrets.GIT_PW }}
shell: bash -l {0}
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.CTDEPLOY_SSH_KEY }}
known_hosts: ${{ secrets.CTDEPLOY_KNOWN_HOSTS }}
# If the version of rsync is changed, the directories below have to be updated
- name: Install rsync on Windows
if: matrix.MATLAB == 1 && runner.os == 'Windows'
run: choco install rsync --version 6.2.4
# This seems like overkill, but rsync on Windows requires a POSIX-style path
- name: Display the path
run: |
import os
from pathlib import Path, PurePosixPath
mw_headers_dir = Path(os.environ["MW_HEADERS_DIR"]).resolve()
mw_headers_dir = PurePosixPath(
"/cygdrive",
mw_headers_dir.drive[0],
PurePosixPath(*mw_headers_dir.parts[1:])
)
with Path(os.environ["GITHUB_ENV"]).open(mode="a") as gh_env:
gh_env.write(f"CYG_MW_HEADERS_DIR={mw_headers_dir}")
shell: python
if: runner.os == 'Windows' && matrix.MATLAB == 1
- name: Get the MATLAB headers
if: matrix.MATLAB == 1 && runner.os == 'Windows'
run: |
rsync -azvP -e `
'C:\ProgramData\chocolatey\lib\rsync\tools\cwrsync_6.2.4_x64_free\bin\ssh.exe -i C:\Users\runneradmin\.ssh\id_rsa -o UserKnownHostsFile=C:\Users\runneradmin\.ssh\known_hosts' `
ctdeploy@cantera.org:. $Env:CYG_MW_HEADERS_DIR
shell: powershell
- name: Get the MATLAB headers
if: matrix.MATLAB == 1 && runner.os != 'Windows'
run: "rsync -azvP ctdeploy@cantera.org:. ${MW_HEADERS_DIR}"
shell: bash
- name: Build the MATLAB recipe
shell: bash -l {0}
run: conda build ./cantera-matlab -m ./.ci_support/conda_build_config.yaml
Expand All @@ -77,4 +117,4 @@ jobs:
run: |
anaconda --token ${{ secrets.ANACONDA_TOKEN }} upload --force --label dev $CONDA/conda-bld/*/*cantera*.tar.bz2
shell: bash -l {0}
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
if: github.event.inputs.upload == 'true'
14 changes: 1 addition & 13 deletions cantera-matlab/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,8 @@ echo ****************************
echo MATLAB BUILD STARTED
echo ****************************

REM IF %ARCH% EQU 64 (
REM CALL "%VS140COMNTOOLS%"\..\..\VC\bin\amd64\vcvars64.bat
REM ) ELSE (
REM CALL "%VS140COMNTOOLS%"\..\..\VC\bin\vcvars32.bat
REM )

:: Have to use CALL to prevent the script from exiting after calling SCons
CALL scons clean
IF ERRORLEVEL 1 EXIT 1

DEL /F cantera.conf

COPY "%RECIPE_DIR%\..\.ci_support\cantera_base.conf" cantera.conf
ECHO msvc_version='14.1' >> cantera.conf
ECHO msvc_version='14.2' >> cantera.conf

SET "STAGE_DIR=stage"
ECHO stage_dir="%STAGE_DIR%" >> cantera.conf
Expand Down
28 changes: 19 additions & 9 deletions cantera-matlab/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ echo "****************************"
echo "MATLAB BUILD STARTED"
echo "****************************"

if [[ "$DIRTY" != "1" ]]; then
scons clean
fi

rm -f cantera.conf

cp "${RECIPE_DIR}/../.ci_support/cantera_base.conf" cantera.conf

echo "prefix = ''" >> cantera.conf
Expand All @@ -22,19 +16,35 @@ echo "stage_dir = '${STAGE_DIR}'" >> cantera.conf
if [[ "${OSX_ARCH}" == "" ]]; then
echo "CC = '${CC}'" >> cantera.conf
echo "CXX = '${CXX}'" >> cantera.conf
echo "cc_flags = '${CFLAGS}'" >> cantera.conf
echo "cxx_flags = '${CPPFLAGS}'" >> cantera.conf
echo "optimize_flags = ''" >> cantera.conf
echo "debug = False" >> cantera.conf
echo "use_rpath_linkage = False" >> cantera.conf
echo "no_debug_linker_flags = '${LDFLAGS}'" >> cantera.conf
echo "renamed_shared_libraries = False" >> cantera.conf
echo "VERBOSE = True" >> cantera.conf
else
echo "CC = '${CLANG}'" >> cantera.conf
echo "CXX = '${CLANGXX}'" >> cantera.conf
echo "cc_flags = '-isysroot ${CONDA_BUILD_SYSROOT} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}'" >> cantera.conf
echo "cc_flags = '-isysroot ${CONDA_BUILD_SYSROOT} ${CFLAGS}'" >> cantera.conf
echo "cxx_flags = '${CPPFLAGS}'" >> cantera.conf
echo "optimize_flags = ''" >> cantera.conf
echo "debug = False" >> cantera.conf
echo "no_debug_linker_flags = '${LDFLAGS} -isysroot ${CONDA_BUILD_SYSROOT}'" >> cantera.conf
echo "env_vars = 'LD'" >> cantera.conf
echo "VERBOSE = True" >> cantera.conf
echo "renamed_shared_libraries = False" >> cantera.conf
echo "use_rpath_linkage = False" >> cantera.conf
fi

echo "matlab_toolbox = 'y'" >> cantera.conf
echo "matlab_path = '${MW_HEADERS_DIR}'" >> cantera.conf

set -xe

scons build -j${CPU_COUNT}
scons install
${BUILD_PREFIX}/bin/python `which scons` build -j${CPU_COUNT}
${BUILD_PREFIX}/bin/python `which scons` install

# "Install" just the Matlab interface. This method should
# prevent this package from clobbering any existing
Expand Down
20 changes: 9 additions & 11 deletions cantera-matlab/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
{% set data = load_file_regex(load_file='SConstruct', regex_pattern="env\\['cantera_version'\\] = .([\d.abrc]+).") %}
{% set data = load_file_regex(load_file='SConstruct', regex_pattern="env\\[.cantera_version.\\] = .([\d.abrc]+).") %}

package:
name: cantera-matlab
version: {{ data.group(1) }}

source:
git_url: https://github.com/Cantera/cantera.git
git_tag: main
git_tag: add-package-workflow

requirements:
build:
- {{ compiler('c') }} # [not win]
- {{ compiler('cxx') }} # [not win]
- vs2017_win-64 ==19.15.* # [win64]
- vs2017_win-32 ==19.15.* # [win32]
- scons >=3.1
- python >=3.5
- numpy
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- scons >=4.1
host:
- libboost
run:
- vs2015_runtime # [win]
- pywin32 # [win]

build:
number: 0
include_recipe: True
script_env:
- MW_HEADERS_DIR
ignore_run_exports_from:
# Only the header version of this library is used
- libboost

about:
home: https://cantera.org
Expand Down
16 changes: 2 additions & 14 deletions cantera/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,15 @@ echo ****************************
echo BUILD STARTED
echo ****************************

REM IF %ARCH% EQU 64 (
REM CALL "%VS141COMNTOOLS%"\..\..\VC\bin\amd64\vcvars64.bat
REM ) ELSE (
REM CALL "%VS150COMNTOOLS%"\..\..\VC\bin\vcvars32.bat
REM )

:: Have to use CALL to prevent the script from exiting after calling SCons
CALL scons clean
IF ERRORLEVEL 1 EXIT 1

DEL /F cantera.conf

COPY "%RECIPE_DIR%\..\.ci_support\cantera_base.conf" cantera.conf
ECHO msvc_version='14.1' >> cantera.conf
ECHO msvc_version='14.2' >> cantera.conf

:: Set the number of CPUs to use in building
SET /A CPU_USE=%CPU_COUNT% / 2
IF %CPU_USE% EQU 0 SET CPU_USE=1

SET "ESC_PREFIX=%PREFIX:\=/%"
ECHO prefix="%ESC_PREFIX%" >> cantera.conf
ECHO prefix="%ESC_PREFIX%/Library" >> cantera.conf
ECHO boost_inc_dir="%ESC_PREFIX%/Library/include" >> cantera.conf

CALL scons build -j%CPU_USE%
Expand Down
42 changes: 26 additions & 16 deletions cantera/build.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
set +x

echo "****************************"
echo "LIBRARY BUILD STARTED"
echo "****************************"

if [[ "$DIRTY" != "1" ]]; then
scons clean
fi

rm -f cantera.conf
echo "******************"
echo "MAIN BUILD STARTED"
echo "******************"

cp "${RECIPE_DIR}/../.ci_support/cantera_base.conf" cantera.conf

Expand All @@ -20,18 +13,35 @@ if [[ "${OSX_ARCH}" == "" ]]; then
echo "CXX = '${CXX}'" >> cantera.conf
echo "blas_lapack_libs = 'mkl_rt,dl'" >> cantera.conf
echo "blas_lapack_dir = '${PREFIX}/lib'" >> cantera.conf
echo "cc_flags = '${CFLAGS}'" >> cantera.conf
echo "cxx_flags = '${CPPFLAGS}'" >> cantera.conf
echo "optimize_flags = ''" >> cantera.conf
echo "debug = False" >> cantera.conf
echo "use_rpath_linkage = False" >> cantera.conf
echo "no_debug_linker_flags = '${LDFLAGS}'" >> cantera.conf
echo "renamed_shared_libraries = False" >> cantera.conf
echo "VERBOSE = True" >> cantera.conf
else
echo "CC = '${CLANG}'" >> cantera.conf
echo "CXX = '${CLANGXX}'" >> cantera.conf
echo "cc_flags = '-isysroot ${CONDA_BUILD_SYSROOT} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}'" >> cantera.conf
echo "blas_lapack_libs = 'openblas'" >> cantera.conf
echo "blas_lapack_dir = '${PREFIX}/lib'" >> cantera.conf
echo "cc_flags = '-isysroot ${CONDA_BUILD_SYSROOT} ${CFLAGS}'" >> cantera.conf
echo "cxx_flags = '${CPPFLAGS}'" >> cantera.conf
echo "optimize_flags = ''" >> cantera.conf
echo "debug = False" >> cantera.conf
echo "no_debug_linker_flags = '${LDFLAGS} -isysroot ${CONDA_BUILD_SYSROOT}'" >> cantera.conf
echo "VERBOSE = True" >> cantera.conf
echo "renamed_shared_libraries = False" >> cantera.conf
echo "use_rpath_linkage = False" >> cantera.conf
fi

set -xe

scons build -j${CPU_COUNT}

${BUILD_PREFIX}/bin/python `which scons` build -j${CPU_COUNT}
cp cantera.conf cantera.conf.pre-py
set +xe

echo "****************************"
echo "BUILD COMPLETED SUCCESSFULLY"
echo "****************************"
echo "********************"
echo "MAIN BUILD COMPLETED"
echo "********************"
5 changes: 0 additions & 5 deletions cantera/build_devel.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ ECHO ************************
ECHO DEVEL BUILD STARTED
ECHO ************************

DEL /F cantera.conf

COPY "%RECIPE_DIR%\..\.ci_support\cantera_base.conf" cantera.conf
ECHO msvc_version='14.1' >> cantera.conf

CALL scons install

ECHO ************************
Expand Down
31 changes: 7 additions & 24 deletions cantera/build_devel.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
echo "****************************"
echo "DEVEL LIBRARY INSTALL STARTED"
echo "****************************"
echo "***************************"
echo "DEVEL LIBRARY BUILD STARTED"
echo "***************************"

set -e
rm -f cantera.conf

cp "${RECIPE_DIR}/../.ci_support/cantera_base.conf" cantera.conf

echo "prefix = '${PREFIX}'" >> cantera.conf
echo "boost_inc_dir = '${PREFIX}/include'" >> cantera.conf

if [[ "${OSX_ARCH}" == "" ]]; then
echo "CC = '${CC}'" >> cantera.conf
echo "CXX = '${CXX}'" >> cantera.conf
echo "blas_lapack_libs = 'mkl_rt,dl'" >> cantera.conf
echo "blas_lapack_dir = '${PREFIX}/lib'" >> cantera.conf
else
echo "CC = '${CLANG}'" >> cantera.conf
echo "CXX = '${CLANGXX}'" >> cantera.conf
echo "cc_flags = '-isysroot ${CONDA_BUILD_SYSROOT} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}'" >> cantera.conf
fi

scons install
${BUILD_PREFIX}/bin/python `which scons` install
set +e

echo "****************************"
echo "DEVEL LIBRARY INSTALL COMPLETED SUCCESSFULLY"
echo "****************************"
echo "*****************************"
echo "DEVEL LIBRARY BUILD COMPLETED"
echo "*****************************"
7 changes: 7 additions & 0 deletions cantera/build_lib.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
call %RECIPE_DIR%/build_devel.bat
echo "****************************"
echo "DELETING files from devel except shared libraries"
echo "****************************"

rd /s /q %PREFIX%\Library\share
rd /s /q %PREFIX%\Library\include\cantera
18 changes: 18 additions & 0 deletions cantera/build_lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
source $RECIPE_DIR/build_devel.sh
echo "****************************"
echo "DELETING files from devel except shared libraries"
echo "****************************"

rm -rf $PREFIX/share
rm -rf $PREFIX/include/cantera
rm -rf $PREFIX/bin
rm -rf $PREFIX/lib/pkg-config
rm -rf $PREFIX/lib/libcantera.a

if [[ "$target_platform" == osx-* ]]; then
${OTOOL:-otool} -L $PREFIX/lib/libcantera.dylib
fi

echo "************************"
echo "DELETING files COMPLETED"
echo "************************"
3 changes: 1 addition & 2 deletions cantera/build_py.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ echo ****************************
echo PYTHON %PYTHON% BUILD COMPLETED SUCCESSFULLY
echo ****************************

cd interfaces/cython
"%PYTHON%" setup.py build --build-lib=../../build/python install
"%PYTHON%" -m pip install --no-deps --find-links=build\python\dist\ cantera
IF ERRORLEVEL 1 EXIT 1
Loading

0 comments on commit 6b7f509

Please sign in to comment.