Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
pip-installable libres
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkwah committed Nov 4, 2020
1 parent 1f1e4d4 commit d05f2c4
Show file tree
Hide file tree
Showing 67 changed files with 790 additions and 1,311 deletions.
135 changes: 135 additions & 0 deletions .github/workflows/python-bdist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Python Binary Distribution

on: [push]

jobs:
build-test-cmake:
name: CMake

strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Install Ubuntu dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update -y
sudo apt-get install -y valgrind
- name: Build libecl
run: |
git clone https://github.com/equinor/libecl
mkdir libecl/build
cmake -S libecl -B libecl/build
sudo cmake --build libecl/build --target install
sudo rm -rf libecl
- name: Build libres
run: |
mkdir cmake-build
cmake -S . -B cmake-build \
-DBUILD_TESTS=ON \
-DRES_VERSION=1.2.3 \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build cmake-build
- name: Run tests
run: |
cd cmake-build
export PATH=$PWD/bin:$PATH
ctest --output-on-failure
build-test-wheel:
name: Python

strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest']
python: ['3.6', '3.7', '3.8']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Build Linux Wheel
uses: docker://quay.io/pypa/manylinux2010_x86_64
with:
entrypoint: /github/workspace/ci/github/build_linux_wheel.sh
args: ${{ matrix.python }}
if: matrix.os == 'ubuntu-latest'

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

- name: Build macOS Wheel
run: pip wheel . --no-deps -w dist
if: matrix.os == 'macos-latest'

- name: Upload wheel as artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }} Python ${{ matrix.python }} wheel
path: dist/*

- name: Install libres
run: pip install dist/*

- name: Run Python tests
run: |
# pytest adds every directory up-to and including python/ into sys.path,
# meaning that "import res" will import python/res and not the installed
# one. This doesn't work because the libecl.so library only exists in
# site-packages, so we copy directories required by the tests out into its
# own temporary directory.
mkdir test-run; cd test-run
mkdir -p {.git,python}
ln -s {..,$PWD}/bin
ln -s {..,$PWD}/lib
ln -s {..,$PWD}/test-data
ln -s {..,$PWD}/share
cp -R {..,$PWD}/python/tests
# Env vars
export ECL_SKIP_SIGNAL=1
export ERT_SHOW_BACKTRACE=1
# Run tests
python -m pip install -r ../test_requirements.txt
python -m pytest python/tests
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build-test-wheel]

# If this is a tagged release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

steps:
- name: Get wheels
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Move to dist/
run: |
mkdir dist
find artifacts -name "*.whl" -exec mv '{}' dist/ \;
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.3.1
with:
user: statoil-travis
password: ${{ secrets.pypi_password }}
193 changes: 117 additions & 76 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,135 @@
name: Libres testing

on: [pull_request]
on: [push, pull_request]

env:
INSTALL_DIR: ${{ github.workspace }}/install
ERT_SHOW_BACKTRACE: 1
jobs:
build:
build-test-cmake:
name: CMake

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8]
os: [ubuntu-latest]
include:
- python-version: 3.6
os: macos-latest
os: ['ubuntu-latest', 'macos-latest']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Ubuntu dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo add-apt-repository ppa:opm/ppa
sudo apt-get update
sudo apt-get install libopm-simulators liblapack-dev valgrind
- name: Setup environment
run: |
echo "${{ env.INSTALL_DIR}}/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${{ env.INSTALL_DIR }}/lib:${{ env.INSTALL_DIR }}/lib64" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=${{ env.INSTALL_DIR }}/lib:${{ env.INSTALL_DIR }}/lib64" >> $GITHUB_ENV
echo "PYTHONPATH=${{ env.INSTALL_DIR }}/lib/python${{ matrix.python-version }}/site-packages:${{ env.INSTALL_DIR }}/lib/python${{ matrix.python-version }}/dist-packages" >> $GITHUB_ENV
- name: Install dependencies
sudo apt-get update -y
sudo apt-get install -y valgrind
- name: Build libecl
run: |
pip install -r requirements.txt
pip install -r test_requirements.txt
source .libecl_version
git clone https://github.com/equinor/libecl
pushd libecl
git fetch
git checkout tags/$LIBECL_VERSION
pip install -r requirements.txt
mkdir build
pushd build
cmake .. -DENABLE_PYTHON=ON \
-DBUILD_APPLICATIONS=ON \
-DINSTALL_CWRAP=OFF \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DCMAKE_PREFIX_PATH=$INSTALL_DIR
make
make install
popd;popd
- name: Build and install libres
git clone https://github.com/equinor/libecl
mkdir libecl/build
cmake -S libecl -B libecl/build
sudo cmake --build libecl/build --target install
sudo rm -rf libecl
- name: Build libres
run: |
mkdir build
pushd build
ulimit -n 1024
cmake .. -DBUILD_TESTS=ON \
-DENABLE_PYTHON=ON \
-DBUILD_APPLICATIONS=ON \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DCMAKE_PREFIX_PATH=$INSTALL_DIR \
-DCMAKE_INSTALL_NAME_DIR=$INSTALL_DIR/lib \
-DCMAKE_C_FLAGS="-Werror -Wall -Wno-incompatible-pointer-types" \
-DCMAKE_CXX_FLAGS="-Werror -Wall -Wno-unused-result -Wno-reorder \
-Wno-sign-compare -Wno-unknown-pragmas \
-Wno-unused-variable -Wno-parentheses \
-Wno-unused-function -Wno-unused-but-set-variable \
-Wno-unknown-warning-option -Wno-missing-braces \
-Wno-varargs -Wno-sometimes-uninitialized \
-Wno-tautological-compare"
make
make install
popd
- name: Run ctest
mkdir cmake-build
cmake -S . -B cmake-build \
-DBUILD_TESTS=ON \
-DRES_VERSION=1.2.3 \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build cmake-build
- name: Run tests
run: |
pushd build
set -e; python -c "import res"; set +e
ctest --output-on-failure $TEST_SUITE
popd
- name: Run pytest
cd cmake-build
export PATH=$PWD/bin:$PATH
ctest --output-on-failure
build-test-wheel:
name: Python

strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest']
python: ['3.6', '3.7', '3.8']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Build Linux Wheel
uses: docker://quay.io/pypa/manylinux2010_x86_64
with:
entrypoint: /github/workspace/ci/github/build_linux_wheel.sh
args: ${{ matrix.python }}
if: matrix.os == 'ubuntu-latest'

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

- name: Build macOS Wheel
run: pip wheel . --no-deps -w dist
if: matrix.os == 'macos-latest'

- name: Upload wheel as artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }} Python ${{ matrix.python }} wheel
path: dist/*

- name: Install libres
run: pip install dist/*

- name: Run Python tests
run: |
export LD_LIBRARY_PATH=${{ env.INSTALL_DIR }}/lib:${{ env.INSTALL_DIR }}/lib64"
export DYLD_LIBRARY_PATH=${{ env.INSTALL_DIR }}/lib:${{ env.INSTALL_DIR }}/lib64"
pushd python
pytest
# pytest adds every directory up-to and including python/ into sys.path,
# meaning that "import res" will import python/res and not the installed
# one. This doesn't work because the libecl.so library only exists in
# site-packages, so we copy directories required by the tests out into its
# own temporary directory.
mkdir test-run; cd test-run
mkdir -p {.git,python}
ln -s {..,$PWD}/bin
ln -s {..,$PWD}/lib
ln -s {..,$PWD}/test-data
ln -s {..,$PWD}/share
cp -R {..,$PWD}/python/tests
# Env vars
export ECL_SKIP_SIGNAL=1
export ERT_SHOW_BACKTRACE=1
# Run tests
python -m pip install -r ../test_requirements.txt
python -m pytest python/tests
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build-test-wheel]

# If this is a tagged release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

steps:
- name: Get wheels
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Move to dist/
run: |
mkdir dist
find artifacts -name "*.whl" -exec mv '{}' dist/ \;
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.3.1
with:
user: statoil-travis
password: ${{ secrets.pypi_password }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ scratch.sparsebundle
*.DS_Store
__res_lib_path.py
__res_lib_info.py

*.egg-info
/_skbuild
/python/res/_version.py
.libs
1 change: 0 additions & 1 deletion .libecl_version

This file was deleted.

Loading

0 comments on commit d05f2c4

Please sign in to comment.