Skip to content

BindPython ABI (#2796) #13

BindPython ABI (#2796)

BindPython ABI (#2796) #13

Workflow file for this run

name: LPython CI
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
env:
MACOSX_DEPLOYMENT_TARGET: 14.0
jobs:
Build:
name: LPython CI (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-2019"]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache conda
uses: actions/cache@v3
env:
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment.yml') }}
- uses: mamba-org/[email protected]
with:
environment-file: ci/environment.yml
create-args: >-
python=${{ matrix.python-version }}
cmake=3.30.0
- name: Install Windows Conda Packages
if: contains(matrix.os, 'windows')
shell: bash -e -l {0}
run: micromamba install --freeze-installed m2-bison=3.0.4 m2-filesystem
- name: Install Linux / macOS Conda Packages
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
shell: bash -e -l {0}
run: micromamba install --freeze-installed bison=3.4 nodejs=18
- name: Conda info
shell: bash -e -l {0}
run: |
micromamba info
micromamba list
- name: Setup Platform (Linux)
if: contains(matrix.os, 'ubuntu')
shell: bash -e -l {0}
run: |
echo "LFORTRAN_CMAKE_GENERATOR=Unix Makefiles" >> $GITHUB_ENV
echo "WIN=0" >> $GITHUB_ENV
echo "MACOS=0" >> $GITHUB_ENV
echo "ENABLE_RUNTIME_STACKTRACE=yes" >> $GITHUB_ENV
- name: Setup Platform (macOS)
if: contains(matrix.os, 'macos')
shell: bash -e -l {0}
run: |
echo "LFORTRAN_CMAKE_GENERATOR=Unix Makefiles" >> $GITHUB_ENV
echo "WIN=0" >> $GITHUB_ENV
echo "MACOS=1" >> $GITHUB_ENV
echo "ENABLE_RUNTIME_STACKTRACE=yes" >> $GITHUB_ENV
- name: Build (Linux / macOS)
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
run: |
xonsh ci/build.xsh
- name: Build (Windows)
if: contains(matrix.os, 'windows')
shell: cmd
run: |
set MAMBA_INSTALL_LOCN=C:\\Users\runneradmin\micromamba
call %MAMBA_INSTALL_LOCN%\Scripts\activate.bat
call micromamba activate lp
set LFORTRAN_CMAKE_GENERATOR=Ninja
set WIN=1
set MACOS=0
set ENABLE_RUNTIME_STACKTRACE=no
call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
xonsh ci\build.xsh
- name: Test (Linux / macOS)
shell: bash -e -l {0}
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
run: |
xonsh ci/test.xsh
- name: Test (Windows)
if: contains(matrix.os, 'windows')
shell: cmd
run: |
set MAMBA_INSTALL_LOCN=C:\\Users\runneradmin\micromamba
call %MAMBA_INSTALL_LOCN%\Scripts\activate.bat
call micromamba activate lp
set LFORTRAN_CMAKE_GENERATOR=Ninja
set WIN=1
set MACOS=0
call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
xonsh ci\test.xsh
build_to_wasm:
name: Build LPython to WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
create-args: >-
python=3.10
bison=3.4
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}
- name : Remove existing node
shell: bash -l {0}
run : |
which node
node -v
sudo rm -rf /usr/local/bin/node /usr/local/bin/npm
- name: Install Emscripten from Git
shell: bash -l {0}
run: |
mkdir $HOME/ext
cd $HOME/ext
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 3.1.35
./emsdk activate 3.1.35
./emsdk install node-14.18.2-64bit
./emsdk activate node-14.18.2-64bit
- name: Show Emscripten and Node Info
shell: bash -l {0}
run: |
set -ex
# Activate PATH and other environment variables in the current terminal
source $HOME/ext/emsdk/emsdk_env.sh
emcc -v
em++ -v
which node
node -v
- name: Build to WASM
shell: bash -l {0}
run: |
set -ex
source $HOME/ext/emsdk/emsdk_env.sh # Activate Emscripten
./build_to_wasm.sh
- name: Test built lpython.wasm
shell: bash -l {0}
run: |
set -ex
source $HOME/ext/emsdk/emsdk_env.sh # Activate Emscripten
which node
node -v
node --experimental-wasm-bigint src/lpython/tests/test_lpython.js
test_pip_pkgs:
name: Test PIP Installable Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
create-args: >-
python=3.10
bison=3.4
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}
- name: Build Linux
shell: bash -e -l {0}
run: |
./build0.sh
cmake . -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_LLVM=yes \
-DLFORTRAN_BUILD_ALL=yes \
-DWITH_STACKTRACE=no \
-DWITH_RUNTIME_STACKTRACE=yes \
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
cmake --build . -j16 --target install
- name: PIP show version
shell: bash -e -l {0}
run: |
python -m pip -V
- name: PIP install required packages
shell: bash -e -l {0}
run: |
# Package lpynn has lpython_emulation as dependency
# Hence, it should by default install lpython_emulation
python -m pip install lpython_emulation==0.0.1.9 lpynn==0.0.1.4 numpy==1.24.3
- name: PIP show installed packages
shell: bash -e -l {0}
run: |
python -m pip list
- name: Test PIP Packages with Python
shell: bash -e -l {0}
run: |
python integration_tests/test_pip_import_01.py
- name: Test PIP Packages with LPython
shell: bash -e -l {0}
run: |
pip_pkg_path=$(python -c "import site; print(site.getsitepackages()[0])")
echo $pip_pkg_path
./src/bin/lpython integration_tests/test_pip_import_01.py -I $pip_pkg_path
debug:
name: Check Debug build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
create-args: >-
python=3.10
bison=3.4
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}
- name: Build Linux
shell: bash -e -l {0}
run: |
./build0.sh
export CXXFLAGS="-Werror"
cmake . -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_LLVM=yes \
-DLFORTRAN_BUILD_ALL=yes \
-DWITH_STACKTRACE=no \
-DWITH_RUNTIME_STACKTRACE=yes \
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
cmake --build . -j16 --target install
- name: Test Linux
shell: bash -e -l {0}
run: |
ctest
./run_tests.py -s
cd integration_tests
./run_tests.py -b llvm c
./run_tests.py -b llvm c -f
release:
name: Check Release build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
create-args: >-
python=3.10
bison=3.4
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}
- name: Build Linux
shell: bash -e -l {0}
run: |
./build0.sh
export CXXFLAGS="-Werror"
cmake . -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS_RELEASE="-Wall -Wextra -O3 -funroll-loops -DNDEBUG" \
-DWITH_LLVM=yes \
-DLFORTRAN_BUILD_ALL=yes \
-DWITH_STACKTRACE=no \
-DWITH_RUNTIME_STACKTRACE=yes \
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
cmake --build . -j16 --target install
- name: Test Linux
shell: bash -e -l {0}
run: |
ctest --rerun-failed --output-on-failure
./run_tests.py -s
cd integration_tests
./run_tests.py -b llvm c
./run_tests.py -b llvm c -f
cpython_interop:
name: Test CPython Interop (@pythoncall)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
create-args: >-
python=3.10
bison=3.4
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}
- name: Build Linux
shell: bash -e -l {0}
run: |
./build0.sh
cmake . -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_LLVM=yes \
-DLFORTRAN_BUILD_ALL=yes \
-DWITH_STACKTRACE=no \
-DWITH_RUNTIME_STACKTRACE=yes \
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
cmake --build . -j16 --target install
- name: Test Linux
shell: bash -e -l {0}
run: |
cd integration_tests
./run_tests.py -b cpython c_py llvm_py
./run_tests.py -b cpython c_py llvm_py -f
sympy:
name: Run SymPy tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
create-args: >-
python=3.10
bison=3.4
symengine=0.12.0
sympy=1.11.1
- uses: hendrikmuhs/ccache-action@main
with:
key: ${{ github.job }}-${{ matrix.os }}
- name: Build
shell: bash -e -l {0}
run: |
./build0.sh
cmake . -G"Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_LLVM=yes \
-DLPYTHON_BUILD_ALL=yes \
-DWITH_STACKTRACE=no \
-DWITH_RUNTIME_STACKTRACE=no \
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build . -j16 --target install
- name: Test
shell: bash -e -l {0}
run: |
cd integration_tests
./run_tests.py -b c_sym cpython_sym llvm_sym llvm_jit
./run_tests.py -b c_sym cpython_sym llvm_sym llvm_jit -f
integration_tests_cpython:
name: Run Integration tests with Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v1
with:
environment-name: lp
condarc: |
channels:
- conda-forge
create-args: >-
llvmdev=11.1.0
bison=3.4
re2c=2.2
zlib=1.3.1
cmake=3.30.0
make=4.3
python=${{ matrix.python-version }}
numpy=1.26.4
- uses: hendrikmuhs/ccache-action@main
with:
key: ${{ github.job }}-${{ matrix.python-version }}
- name: Show Python Info
shell: bash -e -l {0}
run: |
which python
python -m pip -V
python -m pip list
python --version
- name: Build
shell: bash -e -l {0}
run: |
./build0.sh
cmake . -G"Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_LLVM=yes \
-DLPYTHON_BUILD_ALL=yes \
-DWITH_STACKTRACE=no \
-DWITH_RUNTIME_STACKTRACE=no \
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build . -j16 --target install
- name: Test
shell: bash -e -l {0}
run: |
cd integration_tests
./run_tests.py -b cpython c_py
test_llvm:
name: Test LLVM ${{ matrix.llvm-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
llvm-version: ["10", "15", "16"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: mamba-org/[email protected]
with:
environment-file: ci/environment_linux_llvm.yml
create-args: >-
llvmdev=${{ matrix.llvm-version }}
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.llvm-version }}
- name: Build Linux
shell: bash -e -l {0}
run: |
./build0.sh
export CXXFLAGS="-Werror"
cmake . -G"Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_LLVM=yes \
-DLFORTRAN_BUILD_ALL=yes \
-DWITH_STACKTRACE=no \
-DWITH_RUNTIME_STACKTRACE=yes \
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
cmake --build . -j16 --target install
- name: Test Linux LLVM ${{ matrix.llvm-version }}
shell: bash -e -l {0}
run: |
ctest --output-on-failure
cd integration_tests
./run_tests.py -b llvm llvm_jit
./run_tests.py -b llvm llvm_jit -f
build_jupyter_kernel:
name: Build Jupyter Kernel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
create-args: >-
jupyter=1.0.0
python=3.10
bison=3.4
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}
- name: Build LPython with Kernel
shell: bash -e -l {0}
run: |
./build0.sh
export CXXFLAGS="-Werror"
cmake . -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_LLVM=yes \
-DWITH_XEUS=yes \
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX"
ninja install
ctest --output-on-failure
jupyter kernelspec list --json
- name: Test Kernel
shell: bash -e -l {0}
run: |
ctest --output-on-failure
upload_tarball:
name: Upload Tarball
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
create-args: >-
python=3.10
- name: Create Source Tarball
shell: bash -e -l {0}
run: |
./build0.sh
lpython_version=$(<version)
ci/create_source_tarball.sh $lpython_version
- name: Upload Tarball to Release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
shell: bash -e -l {0}
run: |
ci/upload_tarball_to_release.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}