From 0eb00da352454a3534f69f576af9aea6f57e5a6a Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 20:52:22 -0600 Subject: [PATCH 01/12] Add release.yml GH --- .github/release.yml | 19 +++++++++++++++++++ .../{pythonpublish.yml => publish.yml} | 0 2 files changed, 19 insertions(+) create mode 100644 .github/release.yml rename .github/workflows/{pythonpublish.yml => publish.yml} (100%) diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..059a163 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,19 @@ +changelog: + exclude: + authors: [dependabot, github-actions] + categories: + - title: New Features 🎉 + labels: + - feature + - title: Bug Fixes 🐛 + labels: + - fix + - title: Enhancements 🛠 + labels: + - enhancement + - title: Documentation 📖 + labels: + - documentation + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/publish.yml similarity index 100% rename from .github/workflows/pythonpublish.yml rename to .github/workflows/publish.yml From cf6904551abbeb431c0da0862c251d2761124c76 Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 21:00:57 -0600 Subject: [PATCH 02/12] Update GH test to use conda-forge kim-api --- .github/workflows/testing.yml | 401 +++++++++++++++++++--------------- 1 file changed, 220 insertions(+), 181 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8f879c1..b7df8af 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -3,188 +3,227 @@ name: test on: [push] jobs: - linux: - runs-on: ubuntu-latest + test: strategy: matrix: + os: [ubuntu-latest, macos-latest] python-version: ["3.8", "3.9", "3.10"] + + runs-on: ${{ matrix.os }} + steps: - - uses: actions/checkout@v2 - - name: Install gcc - run: | - sudo apt-get update - sudo apt-get install -yq gcc - sudo apt-get install -yq gfortran - - name: Install kim-api - run: | - export KIMPY_DIR=${PWD} - export KIM_API_VERSION="2.3.0" - cd $KIMPY_DIR && cd .. - wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz - tar Jxvf kim-api-$KIM_API_VERSION.txz - cd kim-api-$KIM_API_VERSION - mkdir build && cd build - cmake .. -DCMAKE_BUILD_TYPE=Release - make -j2 - sudo make install - sudo ldconfig - cd $KIMPY_DIR - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install ase - python -m pip install pytest - - name: Install - run: | - python -m pip install . - - name: Lint with flake8 - run: | - pip install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - cd scripts - python generate_all.py - cd .. - cd tests - pytest - mac: - runs-on: macos-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10"] - compiler: [clang, gcc] - steps: - - uses: actions/checkout@v2 - - name: Install gcc - run: brew install gcc@10 - - if: matrix.compiler == 'clang' - name: Set clang env - run: | - echo "CC=clang" >> $GITHUB_ENV - echo "CXX=clang++" >> $GITHUB_ENV - echo "FC=gfortran" >> $GITHUB_ENV - - if: matrix.compiler == 'gcc' - name: Set gcc env - run: | - echo "CC=gcc-10" >> $GITHUB_ENV - echo "CXX=g++-10" >> $GITHUB_ENV - echo "FC=gfortran-10" >> $GITHUB_ENV - - name: Install kim-api - run: | - export KIMPY_DIR=${PWD} - export KIM_API_VERSION="2.3.0" - cd $KIMPY_DIR && cd .. - mkdir -p KIM_API && cd KIM_API - export KIM_API_DIR=$PWD - echo "KIM_API_DIR=$PWD" >> $GITHUB_ENV - cd .. - wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz - tar Jxvf kim-api-$KIM_API_VERSION.txz - cd kim-api-$KIM_API_VERSION - mkdir build && cd build - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$KIM_API_DIR" -DCMAKE_Fortran_COMPILER=gfortran-10 - make -j2 - make install - source "$KIM_API_DIR/bin/kim-api-activate" - cd $KIMPY_DIR - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python3 -m pip install --upgrade pip - python3 -m pip install ase - python3 -m pip install pytest - - name: Install - run: | - source "$KIM_API_DIR/bin/kim-api-activate" - python3 -m pip install . - - name: Lint with flake8 - run: | - python3 -m pip install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - cd scripts - python generate_all.py - cd .. - cd tests - pytest - windows: - runs-on: windows-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10"] - compiler: [gcc] - defaults: - run: - shell: msys2 {0} - steps: - - uses: actions/checkout@v2 - - uses: msys2/setup-msys2@v2 - with: - msystem: MINGW64 - install: git tar vim base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - if: matrix.compiler == 'clang' - name: Set clang env - run: | - pacman --noconfirm -S mingw-w64-x86_64-clang - echo "CC=clang" >> $GITHUB_ENV - echo "CXX=clang++" >> $GITHUB_ENV - echo "FC=gfortran" >> $GITHUB_ENV - - if: matrix.compiler == 'gcc' - name: Set gcc env - run: | - echo "CC=gcc" >> $GITHUB_ENV - echo "CXX=g++" >> $GITHUB_ENV - echo "FC=gfortran" >> $GITHUB_ENV - - name: Install KIM-API - run: | - export KIMPY_DIR=${PWD} - export KIM_API_VERSION="2.3.0" - cd $KIMPY_DIR && cd .. - wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz - tar Jxvf kim-api-$KIM_API_VERSION.txz - cd kim-api-$KIM_API_VERSION - mkdir build && cd build - cmake.exe -G"MSYS Makefiles" .. -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} -DCMAKE_BUILD_TYPE=Release -DCMAKE_Fortran_COMPILER=gfortran - make -j2 - make install - cd ${MINGW_PREFIX} && cd lib && cd pkgconfig - export PKG_CONFIG_PATH=${PWD} - export PKG_CONFIG_PATH=$(python -c 'import os; print(os.environ.get("PKG_CONFIG_PATH"))') - $(sed -s "s|\${pcfiledir}|${PKG_CONFIG_PATH}|g" -i ./libkim-api.pc) - echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> $GITHUB_ENV - cd $KIMPY_DIR - - name: Install dependencies - run: pacman --noconfirm -S mingw-w64-x86_64-python-pip mingw-w64-x86_64-python-pytest mingw-w64-x86_64-python-numpy mingw-w64-x86_64-python-scipy mingw-w64-x86_64-python-matplotlib - - name: Install ASE - run: pip3 install ase - - name: Install kimpy - run: | - export PATH=${MINGW_PREFIX}/bin:$PATH - export LD_LIBRARY_PATH=${MINGW_PREFIX}/lib:$LD_LIBRARY_PATH - pip3 install . - - name: Test with pytest - run: | - cd scripts - python generate_all.py - cd .. - cd tests - pytest + - uses: actions/checkout@v4 + - name: Set up micromamba + uses: mamba-org/setup-micromamba@v1.7.3 + with: + # the create command looks like this: + # `micromamba create -n test-env python= kim-api=2.3.0` + environment-name: test-env + cache-environment: true + create-args: >- + python=${{ matrix.python-version }} + kim-api=2.3.0 + + - name: Install KIM model + shell: bash -el {0} + run: | + kim-api-collections-management install user SW_StillingerWeber_1985_Si__MO_405512056662_006 + + - name: Install + shell: bash -el {0} + run: | + python -m pip install --upgrade pip + python -m pip install .[test] + + - name: Test with pytest + shell: bash -el {0} + run: | + cd tests + pytest + +# +# linux: +# runs-on: ubuntu-latest +# strategy: +# matrix: +# python-version: ["3.8", "3.9", "3.10"] +# steps: +# - uses: actions/checkout@v2 +# - name: Install gcc +# run: | +# sudo apt-get update +# sudo apt-get install -yq gcc +# sudo apt-get install -yq gfortran +# - name: Install kim-api +# run: | +# export KIMPY_DIR=${PWD} +# export KIM_API_VERSION="2.3.0" +# cd $KIMPY_DIR && cd .. +# wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz +# tar Jxvf kim-api-$KIM_API_VERSION.txz +# cd kim-api-$KIM_API_VERSION +# mkdir build && cd build +# cmake .. -DCMAKE_BUILD_TYPE=Release +# make -j2 +# sudo make install +# sudo ldconfig +# cd $KIMPY_DIR +# - name: Set up Python ${{ matrix.python-version }} +# uses: actions/setup-python@v2 +# with: +# python-version: ${{ matrix.python-version }} +# - name: Install dependencies +# run: | +# python -m pip install --upgrade pip +# python -m pip install ase +# python -m pip install pytest +# - name: Install +# run: | +# python -m pip install . +# - name: Lint with flake8 +# run: | +# pip install flake8 +# # stop the build if there are Python syntax errors or undefined names +# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics +# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide +# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics +# - name: Test with pytest +# run: | +# cd scripts +# python generate_all.py +# cd .. +# cd tests +# pytest +# mac: +# runs-on: macos-latest +# strategy: +# matrix: +# python-version: ["3.8", "3.9", "3.10"] +# compiler: [clang, gcc] +# steps: +# - uses: actions/checkout@v2 +# - name: Install gcc +# run: brew install gcc@10 +# - if: matrix.compiler == 'clang' +# name: Set clang env +# run: | +# echo "CC=clang" >> $GITHUB_ENV +# echo "CXX=clang++" >> $GITHUB_ENV +# echo "FC=gfortran" >> $GITHUB_ENV +# - if: matrix.compiler == 'gcc' +# name: Set gcc env +# run: | +# echo "CC=gcc-10" >> $GITHUB_ENV +# echo "CXX=g++-10" >> $GITHUB_ENV +# echo "FC=gfortran-10" >> $GITHUB_ENV +# - name: Install kim-api +# run: | +# export KIMPY_DIR=${PWD} +# export KIM_API_VERSION="2.3.0" +# cd $KIMPY_DIR && cd .. +# mkdir -p KIM_API && cd KIM_API +# export KIM_API_DIR=$PWD +# echo "KIM_API_DIR=$PWD" >> $GITHUB_ENV +# cd .. +# wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz +# tar Jxvf kim-api-$KIM_API_VERSION.txz +# cd kim-api-$KIM_API_VERSION +# mkdir build && cd build +# cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$KIM_API_DIR" -DCMAKE_Fortran_COMPILER=gfortran-10 +# make -j2 +# make install +# source "$KIM_API_DIR/bin/kim-api-activate" +# cd $KIMPY_DIR +# - name: Set up Python ${{ matrix.python-version }} +# uses: actions/setup-python@v2 +# with: +# python-version: ${{ matrix.python-version }} +# - name: Install dependencies +# run: | +# python3 -m pip install --upgrade pip +# python3 -m pip install ase +# python3 -m pip install pytest +# - name: Install +# run: | +# source "$KIM_API_DIR/bin/kim-api-activate" +# python3 -m pip install . +# - name: Lint with flake8 +# run: | +# python3 -m pip install flake8 +# # stop the build if there are Python syntax errors or undefined names +# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics +# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide +# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics +# - name: Test with pytest +# run: | +# cd scripts +# python generate_all.py +# cd .. +# cd tests +# pytest +# windows: +# runs-on: windows-latest +# strategy: +# matrix: +# python-version: ["3.8", "3.9", "3.10"] +# compiler: [gcc] +# defaults: +# run: +# shell: msys2 {0} +# steps: +# - uses: actions/checkout@v2 +# - uses: msys2/setup-msys2@v2 +# with: +# msystem: MINGW64 +# install: git tar vim base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake +# - name: Set up Python ${{ matrix.python-version }} +# uses: actions/setup-python@v2 +# with: +# python-version: ${{ matrix.python-version }} +# - if: matrix.compiler == 'clang' +# name: Set clang env +# run: | +# pacman --noconfirm -S mingw-w64-x86_64-clang +# echo "CC=clang" >> $GITHUB_ENV +# echo "CXX=clang++" >> $GITHUB_ENV +# echo "FC=gfortran" >> $GITHUB_ENV +# - if: matrix.compiler == 'gcc' +# name: Set gcc env +# run: | +# echo "CC=gcc" >> $GITHUB_ENV +# echo "CXX=g++" >> $GITHUB_ENV +# echo "FC=gfortran" >> $GITHUB_ENV +# - name: Install KIM-API +# run: | +# export KIMPY_DIR=${PWD} +# export KIM_API_VERSION="2.3.0" +# cd $KIMPY_DIR && cd .. +# wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz +# tar Jxvf kim-api-$KIM_API_VERSION.txz +# cd kim-api-$KIM_API_VERSION +# mkdir build && cd build +# cmake.exe -G"MSYS Makefiles" .. -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} -DCMAKE_BUILD_TYPE=Release -DCMAKE_Fortran_COMPILER=gfortran +# make -j2 +# make install +# cd ${MINGW_PREFIX} && cd lib && cd pkgconfig +# export PKG_CONFIG_PATH=${PWD} +# export PKG_CONFIG_PATH=$(python -c 'import os; print(os.environ.get("PKG_CONFIG_PATH"))') +# $(sed -s "s|\${pcfiledir}|${PKG_CONFIG_PATH}|g" -i ./libkim-api.pc) +# echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> $GITHUB_ENV +# cd $KIMPY_DIR +# - name: Install dependencies +# run: pacman --noconfirm -S mingw-w64-x86_64-python-pip mingw-w64-x86_64-python-pytest mingw-w64-x86_64-python-numpy mingw-w64-x86_64-python-scipy mingw-w64-x86_64-python-matplotlib +# - name: Install ASE +# run: pip3 install ase +# - name: Install kimpy +# run: | +# export PATH=${MINGW_PREFIX}/bin:$PATH +# export LD_LIBRARY_PATH=${MINGW_PREFIX}/lib:$LD_LIBRARY_PATH +# pip3 install . +# - name: Test with pytest +# run: | +# cd scripts +# python generate_all.py +# cd .. +# cd tests +# pytest From db9e337f606005e5106c744c441a3ff9fcfaa5ea Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 21:02:26 -0600 Subject: [PATCH 03/12] Add dependabot.yml --- .github/dependabot.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b7aaf13 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "monthly" + ignore: + - dependency-name: "numpy" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + ignore: + - dependency-name: "numpy" From c66ee0a852d83e95abcf571072118c5df14609ad Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 21:04:46 -0600 Subject: [PATCH 04/12] Simplify publish script --- .github/workflows/publish.yml | 55 +++++++++++++---------------------- 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 08228a1..75bb80b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,39 +7,24 @@ on: jobs: deploy: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v2 - - name: Install gcc - run: | - sudo apt-get update - sudo apt-get install -yq gcc - sudo apt-get install -yq gfortran - - name: Install kim-api - run: | - export KIMPY_DIR=${PWD} - export KIM_API_VERSION="2.3.0" - cd $KIMPY_DIR && cd .. - wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz - tar Jxvf kim-api-$KIM_API_VERSION.txz - cd kim-api-$KIM_API_VERSION - mkdir build && cd build - cmake .. -DCMAKE_BUILD_TYPE=Release - make -j2 - sudo make install - sudo ldconfig - cd $KIMPY_DIR - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME_OPENKIM }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD_OPENKIM }} - run: | - python setup.py sdist - twine upload dist/* + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install setuptools wheel twine + + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME_OPENKIM }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD_OPENKIM }} + run: | + python setup.py sdist + twine upload dist/* From 9735e0418f385ff1f34b788b2ea4c03991be7f13 Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 21:07:06 -0600 Subject: [PATCH 05/12] Change CHANGELOG.txt to CHANGELOG.md --- CHANGELOG.txt => CHANGELOG.md | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) rename CHANGELOG.txt => CHANGELOG.md (87%) diff --git a/CHANGELOG.txt b/CHANGELOG.md similarity index 87% rename from CHANGELOG.txt rename to CHANGELOG.md index a72f8a6..f61e628 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.md @@ -1,16 +1,12 @@ -========== -Change Log -========== +# Change Log -v2.1.0 (2022/12/06) -=================== +## v2.1.0 (2022/12/06) - Fixing inverse function bug in neighbor list, which can result in incorrect padding - Using pyproject.toml, and refactoring build and test requires -v2.0.1 (2022/08/18) -=================== +## v2.0.1 (2022/08/18) - Include generated binding and testing file in the repo, instead of generating them in the setup.py file. This means each time we modify the source template @@ -18,9 +14,7 @@ v2.0.1 (2022/08/18) - Drop python3.6 support - Update to be compatible with kim-api-2.3.0 - -v2.0.0 (2021/04/26) -=================== +## v2.0.0 (2021/04/26) This release is not backward compatible. @@ -37,9 +31,7 @@ This release is not backward compatible. of the NeighList object and calls its methods. - Find example usage at kimpy/examples/ - -v0.3.3 (2019/10/28) -================== +## v0.3.3 (2019/10/28) - Update setup.py to not explicitly use `pip` and `python` From 915a36aaf581721b4cb5a6bb07ef4392a5cac1e6 Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 21:23:11 -0600 Subject: [PATCH 06/12] Move utils to devtools --- {utils => devtools}/format_sources.py | 0 {utils => devtools}/remove_generated_files.py | 0 devtools/update_version.py | 51 +++++++++++++++ utils/update_version.py | 64 ------------------- 4 files changed, 51 insertions(+), 64 deletions(-) rename {utils => devtools}/format_sources.py (100%) rename {utils => devtools}/remove_generated_files.py (100%) create mode 100644 devtools/update_version.py delete mode 100644 utils/update_version.py diff --git a/utils/format_sources.py b/devtools/format_sources.py similarity index 100% rename from utils/format_sources.py rename to devtools/format_sources.py diff --git a/utils/remove_generated_files.py b/devtools/remove_generated_files.py similarity index 100% rename from utils/remove_generated_files.py rename to devtools/remove_generated_files.py diff --git a/devtools/update_version.py b/devtools/update_version.py new file mode 100644 index 0000000..3a4a47a --- /dev/null +++ b/devtools/update_version.py @@ -0,0 +1,51 @@ +""" +To update version: +1. update compatibility table ../api_compatibility.txt +2. $ python update_version.py +""" +from pathlib import Path + + +def get_kimpy_kimapi_versions(path=None): + """Get the latest kimpy and api version specified in the compatibility table.""" + if path is None: + this_dir = Path(__file__).resolve().parent + path = this_dir.parent / "api_compatibility.txt" + with path.open("r") as fin: + for line in fin: + line = line.strip() + if not line or line[0] == "#": + continue + versions = line.split() + return versions[0], versions[1] + + +def update_version(version, path, key, in_quotes=False, extra_space=False): + """Update version given in `key=version` structure.""" + path = Path(path) + lines = path.read_text().splitlines() + with path.open("w") as fout: + for line in lines: + if key in line: + idx = line.index("=") + line = line[: idx + 1] + if extra_space: + line += " " + v = f'"{version}"' if in_quotes else f"{version}" + fout.write(line + v + "\n") + else: + fout.write(line + "\n") + + +if __name__ == "__main__": + kimpy_v, api_v = get_kimpy_kimapi_versions() + kimpy_dir = Path(__file__).resolve().parent.parent + + path = kimpy_dir / "kimpy" / "__init__.py" + update_version(kimpy_v, path, "__version__", True, True) + + path = kimpy_dir / ".travis.yml" + update_version(api_v, path, "export KIM_API_VERSION", in_quotes=True) + + path = kimpy_dir / ".github/workflows/testing.yml" + update_version(api_v, path, "kim-api", in_quotes=False) diff --git a/utils/update_version.py b/utils/update_version.py deleted file mode 100644 index d0c56a8..0000000 --- a/utils/update_version.py +++ /dev/null @@ -1,64 +0,0 @@ -""" -To update version: -1. update compatibility table ../api_compatibility.txt -2. $ python update_version.py -""" -import os - - -def get_kimpy_kimapi_versions(path=None): - """Get the latest kimpy and api version specified the compatibility table. - - Returns - ------- - kimpy_v: str - kimpy version - api_v: str - kim-api version that kimpy targets for - """ - if path is None: - this_dir = os.path.dirname(os.path.abspath(__file__)) - path = os.path.join(os.path.dirname(this_dir), "api_compatibility.txt") - with open(path, "r") as fin: - for line in fin: - line = line.strip() - if not line or line[0] == "#": - continue - versions = line.split() - return versions[0], versions[1] - - -def update_version(version, path, key, in_quotes=False, extra_space=False): - """Update version given in `key=version` structure.""" - with open(path, "r") as fin: - lines = fin.readlines() - with open(path, "w") as fout: - for line in lines: - if key in line: - idx = line.index("=") - line = line[: idx + 1] - if extra_space: - line += " " - if in_quotes: - v = '"{}"'.format(version) - else: - v = "{}".format(version) - fout.write(line + v + "\n") - else: - fout.write(line) - - -if __name__ == "__main__": - kimpy_v, api_v = get_kimpy_kimapi_versions() - kimpy_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - - path = os.path.join(kimpy_dir, "kimpy", "__init__.py") - update_version(kimpy_v, path, "__version__", True, True) - - path = os.path.join(kimpy_dir, ".travis.yml") - update_version(api_v, path, "export KIM_API_VERSION", in_quotes=True) - - path = os.path.join(kimpy_dir, ".github/workflows/testing.yml") - update_version(api_v, path, "export KIM_API_VERSION", in_quotes=True) - path = os.path.join(kimpy_dir, ".github/workflows/pythonpublish.yml") - update_version(api_v, path, "export KIM_API_VERSION", in_quotes=True) From f74eb2e5b89aa500b21759642502f218b7499897 Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 21:23:24 -0600 Subject: [PATCH 07/12] Add a README.md --- devtools/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 devtools/README.md diff --git a/devtools/README.md b/devtools/README.md new file mode 100644 index 0000000..500b9e0 --- /dev/null +++ b/devtools/README.md @@ -0,0 +1,4 @@ +# Release steps + +1. Update api_compatibility.txt file to specify the versions +2. Update kim-api and kimpy versions in various files: `python devtools/update_versions.py` From 0162fb33bc21bc460ae7cc0eac8b87482e33eb0f Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 21:26:48 -0600 Subject: [PATCH 08/12] Add a README.md --- devtools/update_version.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/devtools/update_version.py b/devtools/update_version.py index 3a4a47a..d3b2c88 100644 --- a/devtools/update_version.py +++ b/devtools/update_version.py @@ -27,7 +27,10 @@ def update_version(version, path, key, in_quotes=False, extra_space=False): with path.open("w") as fout: for line in lines: if key in line: - idx = line.index("=") + try: + idx = line.index("=") + except ValueError: + continue line = line[: idx + 1] if extra_space: line += " " From c40785c8f5b825f0820f6e00b5b1fb2b145499c7 Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 21:29:31 -0600 Subject: [PATCH 09/12] Simplify testing GH --- .github/workflows/testing.yml | 188 +--------------------------------- devtools/update_version.py | 1 + 2 files changed, 2 insertions(+), 187 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index b7df8af..4c56740 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -17,7 +17,7 @@ jobs: uses: mamba-org/setup-micromamba@v1.7.3 with: # the create command looks like this: - # `micromamba create -n test-env python= kim-api=2.3.0` + # `micromamba create -n test-env python=` environment-name: test-env cache-environment: true create-args: >- @@ -41,189 +41,3 @@ jobs: cd tests pytest -# -# linux: -# runs-on: ubuntu-latest -# strategy: -# matrix: -# python-version: ["3.8", "3.9", "3.10"] -# steps: -# - uses: actions/checkout@v2 -# - name: Install gcc -# run: | -# sudo apt-get update -# sudo apt-get install -yq gcc -# sudo apt-get install -yq gfortran -# - name: Install kim-api -# run: | -# export KIMPY_DIR=${PWD} -# export KIM_API_VERSION="2.3.0" -# cd $KIMPY_DIR && cd .. -# wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz -# tar Jxvf kim-api-$KIM_API_VERSION.txz -# cd kim-api-$KIM_API_VERSION -# mkdir build && cd build -# cmake .. -DCMAKE_BUILD_TYPE=Release -# make -j2 -# sudo make install -# sudo ldconfig -# cd $KIMPY_DIR -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Install dependencies -# run: | -# python -m pip install --upgrade pip -# python -m pip install ase -# python -m pip install pytest -# - name: Install -# run: | -# python -m pip install . -# - name: Lint with flake8 -# run: | -# pip install flake8 -# # stop the build if there are Python syntax errors or undefined names -# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics -# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide -# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics -# - name: Test with pytest -# run: | -# cd scripts -# python generate_all.py -# cd .. -# cd tests -# pytest -# mac: -# runs-on: macos-latest -# strategy: -# matrix: -# python-version: ["3.8", "3.9", "3.10"] -# compiler: [clang, gcc] -# steps: -# - uses: actions/checkout@v2 -# - name: Install gcc -# run: brew install gcc@10 -# - if: matrix.compiler == 'clang' -# name: Set clang env -# run: | -# echo "CC=clang" >> $GITHUB_ENV -# echo "CXX=clang++" >> $GITHUB_ENV -# echo "FC=gfortran" >> $GITHUB_ENV -# - if: matrix.compiler == 'gcc' -# name: Set gcc env -# run: | -# echo "CC=gcc-10" >> $GITHUB_ENV -# echo "CXX=g++-10" >> $GITHUB_ENV -# echo "FC=gfortran-10" >> $GITHUB_ENV -# - name: Install kim-api -# run: | -# export KIMPY_DIR=${PWD} -# export KIM_API_VERSION="2.3.0" -# cd $KIMPY_DIR && cd .. -# mkdir -p KIM_API && cd KIM_API -# export KIM_API_DIR=$PWD -# echo "KIM_API_DIR=$PWD" >> $GITHUB_ENV -# cd .. -# wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz -# tar Jxvf kim-api-$KIM_API_VERSION.txz -# cd kim-api-$KIM_API_VERSION -# mkdir build && cd build -# cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$KIM_API_DIR" -DCMAKE_Fortran_COMPILER=gfortran-10 -# make -j2 -# make install -# source "$KIM_API_DIR/bin/kim-api-activate" -# cd $KIMPY_DIR -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Install dependencies -# run: | -# python3 -m pip install --upgrade pip -# python3 -m pip install ase -# python3 -m pip install pytest -# - name: Install -# run: | -# source "$KIM_API_DIR/bin/kim-api-activate" -# python3 -m pip install . -# - name: Lint with flake8 -# run: | -# python3 -m pip install flake8 -# # stop the build if there are Python syntax errors or undefined names -# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics -# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide -# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics -# - name: Test with pytest -# run: | -# cd scripts -# python generate_all.py -# cd .. -# cd tests -# pytest -# windows: -# runs-on: windows-latest -# strategy: -# matrix: -# python-version: ["3.8", "3.9", "3.10"] -# compiler: [gcc] -# defaults: -# run: -# shell: msys2 {0} -# steps: -# - uses: actions/checkout@v2 -# - uses: msys2/setup-msys2@v2 -# with: -# msystem: MINGW64 -# install: git tar vim base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python-version }} -# - if: matrix.compiler == 'clang' -# name: Set clang env -# run: | -# pacman --noconfirm -S mingw-w64-x86_64-clang -# echo "CC=clang" >> $GITHUB_ENV -# echo "CXX=clang++" >> $GITHUB_ENV -# echo "FC=gfortran" >> $GITHUB_ENV -# - if: matrix.compiler == 'gcc' -# name: Set gcc env -# run: | -# echo "CC=gcc" >> $GITHUB_ENV -# echo "CXX=g++" >> $GITHUB_ENV -# echo "FC=gfortran" >> $GITHUB_ENV -# - name: Install KIM-API -# run: | -# export KIMPY_DIR=${PWD} -# export KIM_API_VERSION="2.3.0" -# cd $KIMPY_DIR && cd .. -# wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz -# tar Jxvf kim-api-$KIM_API_VERSION.txz -# cd kim-api-$KIM_API_VERSION -# mkdir build && cd build -# cmake.exe -G"MSYS Makefiles" .. -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} -DCMAKE_BUILD_TYPE=Release -DCMAKE_Fortran_COMPILER=gfortran -# make -j2 -# make install -# cd ${MINGW_PREFIX} && cd lib && cd pkgconfig -# export PKG_CONFIG_PATH=${PWD} -# export PKG_CONFIG_PATH=$(python -c 'import os; print(os.environ.get("PKG_CONFIG_PATH"))') -# $(sed -s "s|\${pcfiledir}|${PKG_CONFIG_PATH}|g" -i ./libkim-api.pc) -# echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> $GITHUB_ENV -# cd $KIMPY_DIR -# - name: Install dependencies -# run: pacman --noconfirm -S mingw-w64-x86_64-python-pip mingw-w64-x86_64-python-pytest mingw-w64-x86_64-python-numpy mingw-w64-x86_64-python-scipy mingw-w64-x86_64-python-matplotlib -# - name: Install ASE -# run: pip3 install ase -# - name: Install kimpy -# run: | -# export PATH=${MINGW_PREFIX}/bin:$PATH -# export LD_LIBRARY_PATH=${MINGW_PREFIX}/lib:$LD_LIBRARY_PATH -# pip3 install . -# - name: Test with pytest -# run: | -# cd scripts -# python generate_all.py -# cd .. -# cd tests -# pytest diff --git a/devtools/update_version.py b/devtools/update_version.py index d3b2c88..676a87a 100644 --- a/devtools/update_version.py +++ b/devtools/update_version.py @@ -30,6 +30,7 @@ def update_version(version, path, key, in_quotes=False, extra_space=False): try: idx = line.index("=") except ValueError: + fout.write(line + "\n") continue line = line[: idx + 1] if extra_space: From b6095633aabb16729f2d29788cc66b2727d93803 Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 21:30:56 -0600 Subject: [PATCH 10/12] Remove .travis.yml --- .travis.yml | 106 ---------------------------------------------------- 1 file changed, 106 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1a54773..0000000 --- a/.travis.yml +++ /dev/null @@ -1,106 +0,0 @@ -language: python - -jobs: - include: - - os: linux - sudo: required - python: 3.6 - - os: linux - sudo: required - python: 3.7 - - os: linux - sudo: required - python: 3.8 - - os: linux - sudo: required - python: 3.9 - - os: osx - osx_image: xcode11.3 - name: "Generic Python 3.7 on macOS" - language: generic - addons: - homebrew: - packages: - - gcc@9 - env: - - MATRIX_EVAL="CC=gcc-9 && CXX=g++-9 && FC=gfortran-9" - - os: osx - osx_image: xcode12.2 - name: "Generic Python 3.8 on macOS" - language: generic - addons: - homebrew: - packages: - - gcc@10 - env: - - MATRIX_EVAL="CC=gcc-10 && CXX=g++-10 && FC=gfortran-10" - - os: osx - osx_image: xcode12.2 - name: "Generic Python 3.8 on macOS" - language: generic - addons: - homebrew: - packages: - - gcc - env: - - MATRIX_EVAL="CC=clang && CXX=clang++ && FC=gfortran" - -before_install: - # environment variable - - export KIMPY_DIR=$PWD ; - - export KIM_API_VERSION="2.3.0" - - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then - python3 --version ; - pip3 install -U pip ; - pip3 install -U pytest ; - fi - - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then - sudo apt-get install gcc ; - sudo apt-get install gfortran ; - - python --version ; - pip install -U pip ; - pip install -U pytest ; - fi - -install: - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then - cd $KIMPY_DIR && cd .. ; - mkdir -p KIM_API && cd KIM_API; - export KIM_API_DIR=$PWD ; - cd ..; - wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz ; - tar Jxvf kim-api-$KIM_API_VERSION.txz ; - cd kim-api-$KIM_API_VERSION ; - mkdir build ; - cd build ; - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$KIM_API_DIR" ; - make -j2 ; - make install ; - source "$KIM_API_DIR/bin/kim-api-activate" ; - pip3 install ase ; - cd $KIMPY_DIR ; - pip3 install -e . ; - fi - - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then - cd $KIMPY_DIR && cd .. ; - wget http://s3.openkim.org/kim-api/kim-api-$KIM_API_VERSION.txz ; - tar Jxvf kim-api-$KIM_API_VERSION.txz ; - cd kim-api-$KIM_API_VERSION ; - mkdir build ; - cd build ; - cmake .. -DCMAKE_BUILD_TYPE=Release ; - make -j2 ; - sudo make install ; - sudo ldconfig ; - pip install ase ; - cd $KIMPY_DIR ; - pip install -e . ; - fi - -script: - - cd tests - - pytest From d05be1d6d9e8ded35cbc3a83232b192935e194a1 Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 21:47:40 -0600 Subject: [PATCH 11/12] Update badge --- README.md | 112 +++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index f1bd34e..943f48a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # kimpy -[![Build Status](https://travis-ci.com/openkim/kimpy.svg?branch=master)](https://travis-ci.com/openkim/kimpy) -[![Python package](https://github.com/openkim/kimpy/workflows/Python%20package/badge.svg)](https://github.com/openkim/kimpy/actions) +![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/openkim/kimpy/testing.yml) [![Anaconda-Server Badge](https://img.shields.io/conda/vn/conda-forge/kimpy.svg)](https://anaconda.org/conda-forge/kimpy) [![PyPI](https://img.shields.io/pypi/v/kimpy.svg)](https://pypi.python.org/pypi/kimpy) [![License](https://img.shields.io/badge/license-CDDL--1.0-blue)](LICENSE.CDDL) @@ -110,78 +109,78 @@ For exampe: 1. To list all the modules in the package, do - ```sh - $ python - >>> import kimpy - >>> help(kimpy) - ``` - - and then you can find all the available modules under `PACKAGE CONTENTS` as - - ```sh - PACKAGE CONTENTS - charge_unit - collection - collection_item_type - collections - compute_argument_name - ... - temperature_unit - time_unit - ``` + ```sh + $ python + >>> import kimpy + >>> help(kimpy) + ``` + + and then you can find all the available modules under `PACKAGE CONTENTS` as + + ```sh + PACKAGE CONTENTS + charge_unit + collection + collection_item_type + collections + compute_argument_name + ... + temperature_unit + time_unit + ``` 2. To inspect the `compute_argument_name` module, do - ```sh - $ python - >>> import kimpy - >>> help(kimpy.compute_argument_name) - ``` + ```sh + $ python + >>> import kimpy + >>> help(kimpy.compute_argument_name) + ``` - All the functions are listed under `FUNCTIONS`. For example, + All the functions are listed under `FUNCTIONS`. For example, - ```sh - FUNCTIONS - get_compute_argument_data_type(...) method of builtins.PyCapsule instance - get_compute_argument_data_type(compute_argument_name: kimpy.compute_argument_name.ComputeArgumentName) -> KIM::DataType + ```sh + FUNCTIONS + get_compute_argument_data_type(...) method of builtins.PyCapsule instance + get_compute_argument_data_type(compute_argument_name: kimpy.compute_argument_name.ComputeArgumentName) -> KIM::DataType - Get the data_type of each defined standard compute_argument_name. + Get the data_type of each defined standard compute_argument_name. - Returns: - DataType: data_type - get_compute_argument_name(...) method of builtins.PyCapsule instance - get_compute_argument_name(index: int) -> kimpy.compute_argument_name.ComputeArgumentName + Returns: + DataType: data_type + get_compute_argument_name(...) method of builtins.PyCapsule instance + get_compute_argument_name(index: int) -> kimpy.compute_argument_name.ComputeArgumentName - Get the identity of each defined standard compute_argument_name. + Get the identity of each defined standard compute_argument_name. - Returns: - ComputeArgumentName: compute_argument_name + Returns: + ComputeArgumentName: compute_argument_name - get_number_of_compute_argument_names(...) method of builtins.PyCapsule instance - get_number_of_compute_argument_names() -> int + get_number_of_compute_argument_names(...) method of builtins.PyCapsule instance + get_number_of_compute_argument_names() -> int - Get the number of standard compute_argument_name's defined by the KIM-API. + Get the number of standard compute_argument_name's defined by the KIM-API. - Returns: - int: number_of_compute_arguments - ``` + Returns: + int: number_of_compute_arguments + ``` - shows that the function `get_compute_argument_name` takes an integer - `index` as input, and returns an output: `compute_argument_name`. You can - refer to `KIM API` docs for further information on the input and outputs. + shows that the function `get_compute_argument_name` takes an integer + `index` as input, and returns an output: `compute_argument_name`. You can + refer to `KIM API` docs for further information on the input and outputs. - All the attributes of the module are listed under `DATA`. For example, + All the attributes of the module are listed under `DATA`. For example, - ```sh - DATA - coordinates = coordinates - numberOfParticles = numberOfParticles - ... - particleSpeciesCodes = particleSpeciesCodes - ``` + ```sh + DATA + coordinates = coordinates + numberOfParticles = numberOfParticles + ... + particleSpeciesCodes = particleSpeciesCodes + ``` ## Copyright @@ -193,4 +192,3 @@ All Rights Reserved Contributors:\       Mingjian Wen\       Yaser Afshar - From 76fe40d6ca95687bc8e7dccea60e8926716ffe09 Mon Sep 17 00:00:00 2001 From: mjwen Date: Sat, 16 Dec 2023 21:47:45 -0600 Subject: [PATCH 12/12] Update version --- api_compatibility.txt | 8 ++++++-- devtools/update_version.py | 3 --- kimpy/__init__.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/api_compatibility.txt b/api_compatibility.txt index 5121817..93ab963 100644 --- a/api_compatibility.txt +++ b/api_compatibility.txt @@ -1,7 +1,10 @@ # -# To update kimpy version (in kimpy/__init__.py) and kim-api version (in .travis.yml), +# To update kimpy version in: +# - kimpy/__init__.py +# and kim-api version in: +# - .github/* # append to this table and then run: -# $ python utils/update_version.py +# $ python devtools/update_version.py # # kimpy-version target-api-version backward-compatible-api-version @@ -22,3 +25,4 @@ 2.0.0 2.2.1 2.2.1 2.0.1 2.3.0 2.2.1 2.1.0 2.3.0 2.2.1 + 2.1.1 2.3.0 2.2.1 diff --git a/devtools/update_version.py b/devtools/update_version.py index 676a87a..d5d1bdf 100644 --- a/devtools/update_version.py +++ b/devtools/update_version.py @@ -48,8 +48,5 @@ def update_version(version, path, key, in_quotes=False, extra_space=False): path = kimpy_dir / "kimpy" / "__init__.py" update_version(kimpy_v, path, "__version__", True, True) - path = kimpy_dir / ".travis.yml" - update_version(api_v, path, "export KIM_API_VERSION", in_quotes=True) - path = kimpy_dir / ".github/workflows/testing.yml" update_version(api_v, path, "kim-api", in_quotes=False) diff --git a/kimpy/__init__.py b/kimpy/__init__.py index 70813a5..5427140 100644 --- a/kimpy/__init__.py +++ b/kimpy/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.1.0" +__version__ = "2.1.1" # import all modules from . import model