Skip to content

Commit

Permalink
Merge pull request #10 from ygeunkim/feature/python
Browse files Browse the repository at this point in the history
Add a python version
  • Loading branch information
ygeunkim authored Sep 14, 2024
2 parents 21b8a57 + 2a8599d commit a451039
Show file tree
Hide file tree
Showing 66 changed files with 7,811 additions and 538 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
^cran-comments\.md$
^CRAN-SUBMISSION$
^revdep$
^python$
72 changes: 72 additions & 0 deletions .github/workflows/py-conda-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
on:
push:
branches: ['feature/python', 'feature/py-*'] # change to [main, master, 'hotfix/*', 'release/*', develop, 'feature/py-*'] after finish
# pull_request:
# branches: [main, master, 'hotfix/*', 'release/*', develop]

name: py-conda-check

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

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.10', '3.11', '3.12']

defaults:
run:
working-directory: python

name: ${{ matrix.os }} (${{ matrix.python-version }})

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Set LLVM on macOS
if: runner.os == 'macOS'
run: |
brew update
brew install llvm libomp
LLVM_LOC=$(brew --prefix llvm)
OMP_LOC=$(brew --prefix libomp)
echo "LLVM_LOC=$LLVM_LOC" >> $GITHUB_ENV
echo "OMP_LOC=$OMP_LOC" >> $GITHUB_ENV
echo "CC=$LLVM_LOC/bin/clang" >> $GITHUB_ENV
echo "CXX=$LLVM_LOC/bin/clang++" >> $GITHUB_ENV
echo "CPPFLAGS=-I$LLVM_LOC/include -I$OMP_LOC/include" >> $GITHUB_ENV
echo "LDFLAGS=-L$LLVM_LOC/lib -L$OMP_LOC/lib" >> $GITHUB_ENV
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
activate-environment: bvhar-env
environment-file: python/requirements/environment.yml
python-version: ${{ matrix.python-version }}
auto-activate-base: false

- name: Verify conda
run: |
conda info
conda list
conda env list
- name: Install
run: conda run -n bvhar-env pip install -e . -v

- name: Verify installation
run: |
conda run -n bvhar-env pip list
conda run -n bvhar-env conda list
- name: OpenMP check
run: conda run -n bvhar-env python -c "from bvhar.utils import checkomp; checkomp.check_omp()"

- name: Test
run: conda run -n bvhar-env pytest
123 changes: 123 additions & 0 deletions .github/workflows/py-github-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
on:
push:
branches: ['feature/python', 'feature/py-*'] # change to [main, master, 'hotfix/*', 'release/*', develop, 'feature/py-*'] after finish
# pull_request:
# branches: [main, master, 'hotfix/*', 'release/*', develop]

name: py-github-check

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

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.10', '3.11', '3.12']

name: ${{ matrix.os }} (${{ matrix.python-version }})

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Verify git
run: git --version

- name: Set system dependencies on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libboost-all-dev libeigen3-dev
echo $(sudo apt list --installed)
echo "EIGEN_INCLUDE_DIR=/usr/include/eigen3" >> $GITHUB_ENV
echo "BOOST_INCLUDE_DIR=/usr/include/boost" >> $GITHUB_ENV
- name: Set system dependencies on macOS
if: runner.os == 'macOS'
run: |
brew update
brew install llvm libomp boost eigen
EIGEN_LOC=$(brew --prefix eigen)
BOOST_LOC=$(brew --prefix boost)
LLVM_LOC=$(brew --prefix llvm)
OMP_LOC=$(brew --prefix libomp)
echo "EIGEN_INCLUDE_DIR=$EIGEN_LOC/include/eigen3" >> $GITHUB_ENV
echo "BOOST_INCLUDE_DIR=$BOOST_LOC/include" >> $GITHUB_ENV
echo "LLVM_LOC=$LLVM_LOC" >> $GITHUB_ENV
echo "OMP_LOC=$OMP_LOC" >> $GITHUB_ENV
echo "CC=$LLVM_LOC/bin/clang" >> $GITHUB_ENV
echo "CXX=$LLVM_LOC/bin/clang++" >> $GITHUB_ENV
echo "CPPFLAGS=-I$LLVM_LOC/include -I$OMP_LOC/include" >> $GITHUB_ENV
echo "LDFLAGS=-L$LLVM_LOC/lib -L$OMP_LOC/lib" >> $GITHUB_ENV
- name: Set system dependencies on Windows
if: runner.os == 'Windows'
run: |
choco install eigen -y --no-progress
choco install boost-msvc-14.3 -y --no-progress
$eigenPath = (
Get-ChildItem -Path "C:\ProgramData\chocolatey\lib\eigen" -Recurse -Filter "Eigen" |
Select-Object -First 1
).Parent.FullName
if ($eigenPath) {
echo "eigen is installed in $eigenPath"
} else {
Write-Error "Wrong eigen path"
exit 1
}
$boostPath = $null
$boostCand = @("C:\local", "C:\ProgramData\chocolatey\lib")
foreach ($cand in $boostCand) {
$isPath = (
Get-ChildItem -Path $cand -Directory |
Where-Object { $_.Name -match "boost" } |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
).FullName
if ($isPath) {
$boostPath = $isPath
break
}
}
if ($boostPath) {
echo "boost is installed in $boostPath"
} else {
Write-Error "Wrong boost path"
exit 1
}
echo "EIGEN_INCLUDE_DIR=$eigenPath" >> $Env:GITHUB_ENV
echo "BOOST_INCLUDE_DIR=$boostPath" >> $Env:GITHUB_ENV
- name: Verify Eigen and boost on non-Windows
if: runner.os != 'Windows'
run: |
ls ${{ env.EIGEN_INCLUDE_DIR }}
ls ${{ env.BOOST_INCLUDE_DIR }}
mkdir temp-dir
- name: Verify Eigen and boost on Windows
if: runner.os == 'Windows'
run: |
dir ${{ env.EIGEN_INCLUDE_DIR }}
dir ${{ env.BOOST_INCLUDE_DIR }}
New-Item -ItemType Directory -Force -Path temp-dir
- name: Install package from github
# change branch after finishing the feature
run: |
pip install --upgrade pip
python -m pip install -e 'git+https://github.com/ygeunkim/bvhar.git@feature/python#egg=bvhar&subdirectory=python'
working-directory: temp-dir

- name: Verify installation
run: pip list
working-directory: temp-dir

- name: OpenMP check
run: python -c "from bvhar.utils import checkomp; checkomp.check_omp()"
working-directory: temp-dir
127 changes: 127 additions & 0 deletions .github/workflows/py-pip-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
on:
push:
branches: ['feature/python', 'feature/py-*'] # change to [main, master, 'hotfix/*', 'release/*', develop, 'feature/py-*'] after finish
# pull_request:
# branches: [main, master, 'hotfix/*', 'release/*', develop]

name: py-pip-check

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

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.10', '3.11', '3.12']

defaults:
run:
working-directory: python

name: ${{ matrix.os }} (${{ matrix.python-version }})

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Set system dependencies on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libboost-all-dev libeigen3-dev
echo $(sudo apt list --installed)
echo "EIGEN_INCLUDE_DIR=/usr/include/eigen3" >> $GITHUB_ENV
echo "BOOST_INCLUDE_DIR=/usr/include/boost" >> $GITHUB_ENV
- name: Set system dependencies on macOS
if: runner.os == 'macOS'
run: |
brew update
brew install llvm libomp boost eigen
EIGEN_LOC=$(brew --prefix eigen)
BOOST_LOC=$(brew --prefix boost)
LLVM_LOC=$(brew --prefix llvm)
OMP_LOC=$(brew --prefix libomp)
echo "EIGEN_INCLUDE_DIR=$EIGEN_LOC/include/eigen3" >> $GITHUB_ENV
echo "BOOST_INCLUDE_DIR=$BOOST_LOC/include" >> $GITHUB_ENV
echo "LLVM_LOC=$LLVM_LOC" >> $GITHUB_ENV
echo "OMP_LOC=$OMP_LOC" >> $GITHUB_ENV
echo "CC=$LLVM_LOC/bin/clang" >> $GITHUB_ENV
echo "CXX=$LLVM_LOC/bin/clang++" >> $GITHUB_ENV
echo "CPPFLAGS=-I$LLVM_LOC/include -I$OMP_LOC/include" >> $GITHUB_ENV
echo "LDFLAGS=-L$LLVM_LOC/lib -L$OMP_LOC/lib" >> $GITHUB_ENV
- name: Set system dependencies on Windows
if: runner.os == 'Windows'
run: |
choco install eigen -y --no-progress
choco install boost-msvc-14.3 -y --no-progress
$eigenPath = (
Get-ChildItem -Path "C:\ProgramData\chocolatey\lib\eigen" -Recurse -Filter "Eigen" |
Select-Object -First 1
).Parent.FullName
if ($eigenPath) {
echo "eigen is installed in $eigenPath"
} else {
Write-Error "Wrong eigen path"
exit 1
}
$boostPath = $null
$boostCand = @("C:\local", "C:\ProgramData\chocolatey\lib")
foreach ($cand in $boostCand) {
$isPath = (
Get-ChildItem -Path $cand -Directory |
Where-Object { $_.Name -match "boost" } |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
).FullName
if ($isPath) {
$boostPath = $isPath
break
}
}
if ($boostPath) {
echo "boost is installed in $boostPath"
} else {
Write-Error "Wrong boost path"
exit 1
}
echo "EIGEN_INCLUDE_DIR=$eigenPath" >> $Env:GITHUB_ENV
echo "BOOST_INCLUDE_DIR=$boostPath" >> $Env:GITHUB_ENV
- name: Verify Eigen and boost on non-Windows
if: runner.os != 'Windows'
run: |
ls ${{ env.EIGEN_INCLUDE_DIR }}
ls ${{ env.BOOST_INCLUDE_DIR }}
- name: Verify Eigen and boost on Windows
if: runner.os == 'Windows'
run: |
dir ${{ env.EIGEN_INCLUDE_DIR }}
dir ${{ env.BOOST_INCLUDE_DIR }}
- name: Install requirements
run: |
pip install --upgrade pip
pip install -r requirements/requirements.txt
- name: Verify pip
run: pip list

- name: Install
run: pip install -e . -v

- name: Verify installation
run: pip list

- name: OpenMP check
run: python -c "from bvhar.utils import checkomp; checkomp.check_omp()"

- name: Test
run: pytest
51 changes: 51 additions & 0 deletions .github/workflows/py-test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on:
push:
branches: ['feature/python', 'feature/py-*'] # change to [main, master, 'hotfix/*', 'release/*', develop, 'feature/py-*'] after finish
# pull_request:
# branches: [main, master, 'hotfix/*', 'release/*', develop]

name: py-test-coverage

jobs:
py-test-coverage:
runs-on: ubuntu-latest

defaults:
run:
working-directory: python

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
activate-environment: bvhar-dev
environment-file: python/requirements/environment-dev.yml
python-version: '3.11'
auto-activate-base: false

- name: Install dependencies
run: conda run -n bvhar-dev pip install -e . -v

- name: Test coverage
run: conda run -n bvhar-dev pytest --cov=./ --cov-report=xml | tee pytest_output.txt

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
working-directory: python
codecov_yml_path: ../codecov.yml
flags: python

- name: Show pytest output
if: always()
run: |
## --------------------------------------------------------------------
find . -name 'pytest_output.txt' -exec cat '{}' \; || true
shell: bash
Loading

0 comments on commit a451039

Please sign in to comment.