core: convenient function for custom hamiltonian #504
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: [ master ] | |
tags: | |
- v* | |
- p* | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
jobs: | |
test: | |
name: test ${{ matrix.python }} ${{ matrix.os }} ${{ matrix.plat }} ${{ matrix.parallel }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-20.04, macos-11 ] | |
python: [ 3.9 ] | |
plat: [ x86_64 ] | |
parallel: [ mpi, serial, serial-pytest, any-symm-pytest ] | |
exclude: | |
- os: macos-11 | |
parallel: mpi | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: install requirements | |
env: | |
MKLROOT: ~/.local | |
run: | | |
export PYT=$(which python) | |
python -m pip install pip build twine --upgrade | |
python -m pip install mkl==2021.4 mkl-include intel-openmp numpy 'cmake>=3.19' pybind11==2.10.1 | |
- name: install requirements (linux / mpi) | |
if: matrix.parallel == 'mpi' && matrix.os == 'ubuntu-20.04' | |
run: | | |
sudo apt-get install libopenmpi-dev | |
python -m pip install mpi4py | |
- name: build gtest (linux) | |
if: matrix.os == 'ubuntu-20.04' | |
run: | | |
lscpu | |
sudo apt-get install libgtest-dev | |
cd /usr/src/gtest | |
sudo cmake CMakeLists.txt | |
sudo make | |
sudo cp lib/*.a /usr/lib | |
- name: build gtest (macos) | |
if: matrix.os == 'macos-11' | |
run: | | |
git clone -b release-1.8.0 https://github.com/google/googletest | |
cd googletest | |
cmake CMakeLists.txt | |
make | |
make install | |
brew update | |
brew install libomp | |
cp /usr/local/opt/libomp/include/*.h /usr/local/include/ | |
- name: build test (serial-pytest) | |
if: matrix.parallel == 'serial-pytest' | |
env: | |
MKLROOT: ~/.local | |
MACOSX_DEPLOYMENT_TARGET: '10.9' | |
run: | | |
mkdir build | |
cd build | |
cmake --version | |
cmake .. -DUSE_MKL=ON -DBUILD_LIB=ON -DLARGE_BOND=ON -DUSE_COMPLEX=ON -DUSE_SG=ON | |
make -j 2 | |
- name: build test (any-symm-pytest) | |
if: matrix.parallel == 'any-symm-pytest' | |
env: | |
MKLROOT: ~/.local | |
MACOSX_DEPLOYMENT_TARGET: '10.9' | |
run: | | |
mkdir build | |
cd build | |
cmake --version | |
cmake .. -DUSE_MKL=ON -DBUILD_LIB=ON -DLARGE_BOND=ON -DUSE_COMPLEX=ON -DUSE_SU2SZ=OFF -DUSE_SANY=ON | |
make -j 2 | |
- name: build test (serial, linux) | |
if: matrix.parallel == 'serial' && matrix.os == 'ubuntu-20.04' | |
env: | |
MKLROOT: ~/.local | |
run: | | |
mkdir build_test | |
cd build_test | |
cmake --version | |
cmake .. -DUSE_MKL=ON -DBUILD_TEST=ON -DLARGE_BOND=ON -DUSE_COMPLEX=ON -DUSE_SINGLE_PREC=ON -DUSE_SG=ON | |
make -j 2 | |
- name: build test (serial, macos) | |
if: matrix.parallel == 'serial' && matrix.os == 'macos-11' | |
env: | |
MKLROOT: ~/.local | |
MACOSX_DEPLOYMENT_TARGET: '10.9' | |
run: | | |
mkdir build_test | |
cd build_test | |
cmake --version | |
cmake .. -DUSE_MKL=ON -DBUILD_TEST=ON -DLARGE_BOND=ON -DUSE_COMPLEX=ON -DUSE_SINGLE_PREC=ON -DUSE_SG=ON | |
make -j 2 | |
- name: run test (serial) | |
if: matrix.parallel == 'serial' | |
run: | | |
cd build_test | |
./block2_tests | |
- name: run test (serial-pytest, linux) | |
if: matrix.parallel == 'serial-pytest' && matrix.os == 'ubuntu-20.04' | |
run: | | |
python -m pip install pytest 'pyscf==2.1.0' 'scipy==1.10.1' | |
export PYTHONPATH=$(pwd)/build:$(pwd):${PYTHONPATH} | |
py.test -s pyblock2/unit_test/*.py | |
- name: run test (serial-pytest, macos) | |
if: matrix.parallel == 'serial-pytest' && matrix.os == 'macos-11' | |
run: | | |
python -m pip install pytest 'pyscf==2.0.1' 'scipy==1.10.1' | |
export PYTHONPATH=$(pwd)/build:$(pwd):${PYTHONPATH} | |
py.test -s pyblock2/unit_test/*.py | |
- name: run test (any-symm-pytest, linux) | |
if: matrix.parallel == 'any-symm-pytest' && matrix.os == 'ubuntu-20.04' | |
run: | | |
python -m pip install pytest 'pyscf==2.1.0' 'scipy==1.10.1' | |
export PYTHONPATH=$(pwd)/build:$(pwd):${PYTHONPATH} | |
py.test -s pyblock2/unit_test/*.py --symm sany | |
- name: run test (any-symm-pytest, macos) | |
if: matrix.parallel == 'any-symm-pytest' && matrix.os == 'macos-11' | |
run: | | |
python -m pip install pytest 'pyscf==2.0.1' 'scipy==1.10.1' | |
export PYTHONPATH=$(pwd)/build:$(pwd):${PYTHONPATH} | |
py.test -s pyblock2/unit_test/*.py --symm sany | |
- name: build test (mpi) | |
if: matrix.parallel == 'mpi' | |
env: | |
MKLROOT: ~/.local | |
run: | | |
sed -i "s|unit_test/test_|unit_test/mpi/test_|" CMakeLists.txt | |
mkdir build_test | |
cd build_test | |
cmake .. -DUSE_MKL=ON -DBUILD_TEST=ON -DLARGE_BOND=ON -DMPI=ON -DUSE_COMPLEX=ON -DUSE_SINGLE_PREC=ON -DUSE_SG=ON | |
make -j 1 # memory issue of mpi compiler | |
- name: run test (mpi) | |
if: matrix.parallel == 'mpi' | |
run: | | |
cd build_test | |
mpirun -n 2 ./block2_tests | |
build: | |
name: build ${{ matrix.python }} ${{ matrix.os }} ${{ matrix.plat }} ${{ matrix.parallel }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-20.04, macos-11 ] | |
python: [ '3.7', '3.8', '3.9', '3.10', '3.11' ] | |
manylinux: [ 2014 ] | |
plat: [ x86_64, arm64 ] | |
parallel: [ mpi, serial ] | |
exclude: | |
- os: macos-11 | |
parallel: mpi | |
- os: ubuntu-20.04 | |
plat: arm64 | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: install requirements | |
env: | |
MKLROOT: ~/.local | |
run: | | |
export PYT=$(which python) | |
python -m pip install pip build twine --upgrade | |
python -m pip install mkl==2021.4 mkl-include intel-openmp numpy 'cmake>=3.19' pybind11==2.10.1 | |
- name: build wheels (macos-x86_64) | |
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'macos-11' && matrix.plat == 'x86_64' | |
env: | |
TAG_STRING: ${{ github.event.ref }} | |
MACOSX_DEPLOYMENT_TARGET: '10.9' | |
run: | | |
brew update | |
brew install libomp | |
cp /usr/local/opt/libomp/include/*.h /usr/local/include/ | |
brew install gnu-sed | |
export PATH=/usr/local/opt/gnu-sed/bin:$PATH | |
echo ${TAG_STRING:11} | |
gsed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py | |
# if use mkl, will need iomp5 | |
gsed -i "/DUSE_MKL/a \ '-DOMP_LIB=OMP'," setup.py | |
gsed -i "/mkl/d" setup.py | |
gsed -i "/intel-openmp/d" setup.py | |
gsed -i "/DUSE_MKL/c \ '-DUSE_MKL=OFF'," setup.py | |
export OMPROOT=$(brew --prefix libomp) | |
echo ${OMPROOT} | |
cmake --version | |
python -m pip install wheel delocate | |
python -m pip wheel . -w ./dist --no-deps | |
export DYLD_LIBRARY_PATH=$(python -c "import site;print(':'.join(x+'/../..' for x in site.getsitepackages()))") | |
# prevent delocating libomp | |
export DELO_PY=$(cat $(which delocate-wheel) | head -1 | awk -F'!' '{print $2}') | |
export DELO_DE=$(${DELO_PY} -c "from delocate import delocating;print(delocating.__file__)") | |
gsed -i '/r_ed_base = base/a \ if "libomp" in required: needs_delocating.add(required); continue' ${DELO_DE} | |
gsed -i '/new_install_name =/a \ if "libomp" in required: new_install_name = "/usr/local/opt/libomp/lib/libomp.dylib"' ${DELO_DE} | |
delocate-wheel -k dist/*.whl | |
- name: build wheels (macos-arm64) | |
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'macos-11' && matrix.plat == 'arm64' | |
env: | |
TAG_STRING: ${{ github.event.ref }} | |
MACOSX_DEPLOYMENT_TARGET: '11.0' | |
run: | | |
brew update | |
brew install libomp | |
cp /usr/local/opt/libomp/include/*.h /usr/local/include/ | |
brew install gnu-sed | |
export PATH=/usr/local/opt/gnu-sed/bin:$PATH | |
echo ${TAG_STRING:11} | |
gsed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py | |
gsed -i "/DUSE_MKL/a \ '-DOMP_LIB=OMP'," setup.py | |
gsed -i "/DUSE_MKL/a \ '-DARCH_ARM64=ON'," setup.py | |
gsed -i "/mkl/d" setup.py | |
gsed -i "/intel-openmp/d" setup.py | |
gsed -i "/DUSE_MKL/c \ '-DUSE_MKL=OFF'," setup.py | |
git clone https://github.com/Homebrew/brew arm-brew | |
cd arm-brew && git checkout 3.6.16 && cd .. | |
./arm-brew/bin/brew update | |
OMPGZ=$(./arm-brew/bin/brew fetch --force --bottle-tag=arm64_big_sur libomp | grep "Downloaded to" | awk '{print $3}') | |
./arm-brew/bin/brew install ${OMPGZ} | |
export OMPROOT=$(./arm-brew/bin/brew --prefix libomp) | |
echo ${OMPROOT} | |
cmake --version | |
python -m pip install wheel delocate | |
export _PYTHON_HOST_PLATFORM="macosx-12.0-arm64" | |
export SDKROOT=/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk | |
export CROSS_COMPILE=1 | |
export PLAT="arm64" | |
python -m pip wheel . -w ./dist --no-deps | |
delocate-wheel --require-archs=arm64 -k dist/*.whl | |
- name: prepare build wheels (manylinux) | |
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-20.04' | |
env: | |
TAG_STRING: ${{ github.event.ref }} | |
run: | | |
echo ${TAG_STRING:11} | |
sed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py | |
cp ./.github/actions/build-wheel/Dockerfile.manylinux${{ matrix.manylinux }} ./.github/actions/build-wheel/Dockerfile | |
- name: build wheels (manylinux) | |
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-20.04' | |
uses: ./.github/actions/build-wheel | |
with: | |
python-version: ${{ matrix.python }} | |
parallel: ${{ matrix.parallel }} | |
- name: release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: dist/* | |
- name: upload artifacts | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist-${{ matrix.parallel }} | |
path: dist | |
retention-days: 2 | |
pypi: | |
name: pypi | |
needs: [build, test] | |
runs-on: ubuntu-20.04 | |
if: startsWith(github.ref, 'refs/tags/') | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: build source dist (serial) | |
env: | |
TAG_STRING: ${{ github.event.ref }} | |
run: | | |
echo ${TAG_STRING:11} | |
sed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py | |
python -m pip install pip build twine --upgrade | |
python -m build --sdist | |
- name: release (serial) | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: dist/* | |
- name: build source dist (mpi) | |
env: | |
TAG_STRING: ${{ github.event.ref }} | |
run: | | |
rm -r dist | |
echo ${TAG_STRING:11} | |
sed -i "/DUSE_MKL/a \ '-DMPI=ON'," setup.py | |
sed -i "s/name=\"block2\"/name=\"block2-mpi\"/g" setup.py | |
sed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py | |
python -m build --sdist | |
mv dist/block2{-,_}mpi-${TAG_STRING:11}.tar.gz | |
- name: release (mpi) | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: dist/* | |
- name: build index | |
env: | |
REPO: ${{ github.repository }} | |
run: | | |
python .github/workflows/build_pypi.py ${REPO} ./idx-dist/pypi | |
- name: setup pages | |
uses: actions/configure-pages@v2 | |
- name: upload artifacts | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: './idx-dist' | |
- name: deploy to gitHub pages | |
id: deployment | |
uses: actions/deploy-pages@v1 | |
publish: | |
name: publish | |
needs: [build, test] | |
runs-on: ubuntu-20.04 | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: build source dist (serial) | |
env: | |
TAG_STRING: ${{ github.event.ref }} | |
run: | | |
echo ${TAG_STRING:11} | |
sed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py | |
python -m pip install pip build twine --upgrade | |
python -m build --sdist | |
- name: download wheels (serial) | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-serial | |
path: dist | |
- name: publish to pypi (serial) | |
uses: pypa/gh-action-pypi-publish@v1.4.2 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
- name: build source dist (mpi) | |
env: | |
TAG_STRING: ${{ github.event.ref }} | |
run: | | |
rm -r dist | |
echo ${TAG_STRING:11} | |
sed -i "/DUSE_MKL/a \ '-DMPI=ON'," setup.py | |
sed -i "s/name=\"block2\"/name=\"block2-mpi\"/g" setup.py | |
sed -i "s/version=.*/version='${TAG_STRING:11}',/" setup.py | |
python -m build --sdist | |
- name: download wheels (mpi) | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-mpi | |
path: dist | |
- name: publish to pypi (mpi) | |
uses: pypa/gh-action-pypi-publish@v1.4.2 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_MPI_TOKEN }} |