diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index e42bfad..7eb2e0b 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -15,7 +15,7 @@ jobs: get_commit_message: name: Get commit message - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 outputs: message: ${{ steps.commit_message.outputs.message }} steps: @@ -29,11 +29,12 @@ jobs: run: | set -xe COMMIT_MSG=$(git log --no-merges -1 --oneline) - echo "::set-output name=message::$COMMIT_MSG" + echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT + echo github.ref ${{ github.ref }} trexio_ubuntu: - name: x86 Ubuntu 20.04 - runs-on: ubuntu-20.04 + name: x86 Ubuntu + runs-on: ubuntu-22.04 needs: get_commit_message steps: @@ -53,8 +54,8 @@ jobs: - name: install dependencies run: | - sudo add-apt-repository ppa:kelleyk/emacs - sudo apt-get install libhdf5-dev emacs26 + sudo apt-get update + sudo apt-get install libhdf5-dev emacs - name: configure with autotools run: | @@ -69,24 +70,29 @@ jobs: - name: Archive test log file if: failure() - uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: test-report-ubuntu path: test-suite.log - - name: create virtual environment + - name: create venv run: | - python3 -m venv --clear pytrexio-venv - source pytrexio-venv/bin/activate + python3 -m venv trexio-venv + source trexio-venv/bin/activate - name: install Python API - run: make python-install + run: | + source trexio-venv/bin/activate + make python-install - name: check Python API - run: make python-test + run: | + source trexio-venv/bin/activate + make python-test - name: build and move Python API distribution run: | + source trexio-venv/bin/activate make python-sdist cp python/dist/trexio-*.tar.gz . @@ -94,38 +100,42 @@ jobs: if: >- contains(needs.get_commit_message.outputs.message, '[wheel build]') || github.event_name == 'release' - uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: pytrexio-source path: ./trexio-*.tar.gz - name: maintainer clean run: make maintainer-clean - + - name: reconfigure with clang and AddressSanitizer run: | ./autogen.sh - ./configure CC=clang-11 CFLAGS="-O2 -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address" --enable-silent-rules - + ./configure CC=clang-15 CFLAGS="-O2 -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address" --enable-silent-rules + - name: recompile TREXIO run: make -j2 - + - name: recheck TREXIO for memory leaks run: make -j2 check - + - name: Archive test log file if: failure() - uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: - name: test-report-ubuntu-2 + name: test-report-ubuntu-memory path: test-suite.log - + - name: maintainer clean run: make maintainer-clean trexio_macos: - name: x86 MacOS 12 - runs-on: macos-12 + name: x86 and arm64 MacOS + strategy: + # macos-13 = x86_64 ; macos-14 = aarch64 + matrix: + os: [macos-13, macos-14] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 @@ -133,14 +143,16 @@ jobs: - name: install dependencies run: | brew install emacs - brew install hdf5 + brew install hdf5@1.14 brew install automake + brew install libtool + brew install swig brew --prefix hdf5 - name: configure with autotools run: | ./autogen.sh - ./configure FC=gfortran-12 --enable-silent-rules + ./configure CC=gcc-12 FC=gfortran-12 --enable-silent-rules - name: compile TREXIO run: make -j3 @@ -148,20 +160,28 @@ jobs: - name: check TREXIO run: make -j3 check + - name: create venv + run: | + python3 -m venv trexio-venv + source trexio-venv/bin/activate + - name: compile Python API run: | export H5_CFLAGS="-I$(brew --prefix hdf5)/include" export H5_LDFLAGS="-L$(brew --prefix hdf5)/lib" + source trexio-venv/bin/activate make python-install - name: test Python API - run: make python-test + run: | + source trexio-venv/bin/activate + make python-test - name: Archive test log file if: failure() - uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: - name: test-report-macos + name: test-report-${{ matrix.os }} path: test-suite.log - name: clean diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 7cda44a..7f571fb 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -16,12 +16,12 @@ jobs: get_commit_message: if: ${{ github.event.workflow_run.conclusion == 'success' }} name: Get commit message - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 outputs: message: ${{ steps.commit_message.outputs.message }} steps: - name: Checkout the repo - uses: actions/checkout@v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Gets the correct commit message for pull request with: ref: ${{ github.event.pull_request.head.sha }} @@ -30,38 +30,135 @@ jobs: run: | set -xe COMMIT_MSG=$(git log --no-merges -1 --oneline) - echo "::set-output name=message::$COMMIT_MSG" + echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT + echo github.ref ${{ github.ref }} - build_linux_wheels: - name: Build Linux wheels for different versions of CPython on manylinux_x86_64 + build_macos_wheels: + name: build wheels for different versions of cpython on macos needs: get_commit_message if: >- contains(needs.get_commit_message.outputs.message, '[wheel build]') || - (github.repository == 'TREX-CoE/trexio' && startsWith(github.ref, 'refs/tags/v')) - runs-on: ubuntu-20.04 + (github.repository == 'trex-coe/trexio' && startswith(github.ref, 'refs/tags/v')) + runs-on: ${{ matrix.buildplat[0] }} + env: + HDF5_INSTALLDIR: "/Users/runner/work/trexio/trexio/hdf5" strategy: + # Ensure that a wheel builder finishes even if another fails + fail-fast: false matrix: - manylinux_tag: [2014_x86_64, 2_24_x86_64] + # Github Actions doesn't support pairing matrix values together, let's improvise + # https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 + buildplat: + - [macos-13, macosx_x86_64] + - [macos-14, macosx_arm64] + # test config + python: ["cp38", "cp39", "cp310", "cp311", "cp312"] + exclude: + - buildplat: [macos-14, macosx_arm64] + python: "cp38" steps: - - name: Checkout the branch - uses: actions/checkout@v3 + - uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1 with: - python-version: '3.9' + python-version: "3.x" + - name: install dependencies + run: | + brew install emacs + brew install automake + brew install libtool + brew install swig + + - uses: actions/cache@v3 + id: cache-hdf5 + with: + path: $HDF5_INSTALLDIR + key: ${{ matrix.buildplat[0] }}-hdf5 + + - name: install hdf5 + if: ${{ steps.cache-hdf5.outputs.cache-hit != 'true' }} + run: | + wget https://github.com/HDFGroup/hdf5/archive/refs/tags/hdf5-1_12_3.tar.gz + tar -xzf hdf5-1_12_3.tar.gz + cd hdf5-hdf5-1_12_3 + if [[ "$ARCH" == "arm64" ]]; then + export MACOSX_DEPLOYMENT_TARGET="11.0" + else + export MACOSX_DEPLOYMENT_TARGET="10.9" + fi + ./autogen.sh + ./configure CC=gcc-12 --prefix $HDF5_INSTALLDIR --enable-build-mode=production --with-szlib + make -j3 + make install + + - name: configure with autotools + run: | + ./autogen.sh + export PATH=${PATH}:${HDF5_INSTALLDIR}/bin + ./configure FC=gfortran-12 --enable-silent-rules + make -j3 + + - name: prepare python + run: | + make python-install + + - name: cleanup python + run: | + rm -rf src/ tools/ + mv python/* . + + - name: Build wheels + uses: pypa/cibuildwheel@bd033a44476646b606efccdd5eed92d5ea1d77ad # v2.20.0 + env: + CIBW_PRERELEASE_PYTHONS: False + CIBW_FREE_THREADED_SUPPORT: False + CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} + CIBW_BUILD_VERBOSITY: 1 + CIBW_BUILD_FRONTEND: "build" + CIBW_ENVIRONMENT: H5_CFLAGS="-I/Users/runner/work/trexio/trexio/hdf5/include" H5_LDFLAGS="-L/Users/runner/work/trexio/trexio/hdf5/lib" + # disable pytest-ing for now - does not work as expected via CIBW on MacOS --> Ask Anthony to test locally + #CIBW_TEST_REQUIRES: pytest + #CIBW_TEST_COMMAND: "python3 -m pytest -v test/test_api.py" + + + - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + with: + name: pytrexio-${{ matrix.python }}-${{ matrix.buildplat[1] }}-wheels + path: ./wheelhouse/*.whl + + + build_linux_wheels: + name: build wheels for different versions of cpython on manylinux_x86_64 + needs: get_commit_message + if: >- + contains(needs.get_commit_message.outputs.message, '[wheel build]') || + (github.repository == 'trex-coe/trexio' && startswith(github.ref, 'refs/tags/v')) + runs-on: ubuntu-22.04 + strategy: + matrix: + manylinux_tag: [2014_x86_64, 2_28_x86_64] + + steps: + - name: Checkout the branch + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + + - name: Set up Python + uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f + with: + python-version: '3.10' + - name: Install build dependencies run: python -m pip install -U setuptools - + - name: Compute the PYTREXIO_VERSION environment variable run: echo "PYTREXIO_VERSION=$(grep __version__ python/pytrexio/_version.py | cut -d\ -f3 | tr -d '"')" >> $GITHUB_ENV - + - name: Print the PYTREXIO_VERSION run: echo ${{ env.PYTREXIO_VERSION }} - + # Conventional download-artifact action does not work for artifact produced in a different workflow, # which is the case here (TREXIO CI produced the Python API distribution tarball) - name: Download the Python API distribution tarball @@ -72,12 +169,12 @@ jobs: workflow_conclusion: success name: pytrexio-source path: python - + # at the moment we have to pull the custom container with pre-installed HDF5 # the containers are built and stored in GitHub container registry ghcr.io/q-posev - name: Pull the manylinux Docker container with HDF5 run: docker pull ghcr.io/q-posev/hdf5_1_12_on_${{ matrix.manylinux_tag }}:latest - + - name: Build wheels for different versions of CPython inside the Docker container run: > docker run --rm @@ -87,36 +184,39 @@ jobs: ghcr.io/q-posev/hdf5_1_12_on_${{ matrix.manylinux_tag }} /bin/bash build_manylinux_wheels.sh trexio-${{ env.PYTREXIO_VERSION }}.tar.gz working-directory: python - + - name: Upload produced wheels as artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: - name: pytrexio-manylinux-${{ matrix.manylinux_tag }} + name: pytrexio-manylinux-${{ matrix.manylinux_tag }}-wheels path: ./python/wheelhouse/*.whl - - + + publish_wheels: name: Publish all wheels on PyPI - needs: [build_linux_wheels] - runs-on: ubuntu-20.04 - + needs: [build_linux_wheels, build_macos_wheels] + runs-on: ubuntu-22.04 + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: - name: Checkout the branch - uses: actions/checkout@v3 - + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f with: - python-version: '3.9' - + python-version: '3.10' + - name: Install build dependencies run: python -m pip install -U setuptools twine - + - name: Download the build artifacts (wheels) of this workflow - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: path: dist - + - name: Download the Python API distribution tarball uses: dawidd6/action-download-artifact@v2 with: @@ -124,26 +224,24 @@ jobs: workflow_conclusion: success name: pytrexio-source path: dist - + # The artifacts have to be in dist/ directory so that # pypa/gh-action-pypi-publish action can discover them - name: Display and rearrange the downloaded artifacts run: | ls -R - mv pytrexio-manylinux-*/trexio-*.whl ./ - rm -rf -- pytrexio-manylinux-*/ + mv pytrexio-*-wheels/trexio-*.whl ./ + rm -rf -- pytrexio-*-wheels/ ls -sh -w 1 working-directory: dist - + #- name: Publish distribution 📦 to Test PyPI - # uses: pypa/gh-action-pypi-publish@master + # uses: pypa/gh-action-pypi-publish@release/v1 # with: - # password: ${{ secrets.TEST_PYPI_API_TOKEN }} # repository_url: https://test.pypi.org/legacy/ - #verbose: true + # verbose: true + # ##verify-metadata: false - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.PYPI_API_TOKEN }} - #if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 + ##if: startsWith(github.ref, 'refs/tags') diff --git a/CMakeLists.txt b/CMakeLists.txt index e48e917..ebe305b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16) # Initialize the CMake project. project(Trexio - VERSION 2.5.0 + VERSION 2.5.1 DESCRIPTION "TREX I/O library" LANGUAGES C Fortran ) diff --git a/README.md b/README.md index 97bb930..4c0953c 100644 --- a/README.md +++ b/README.md @@ -15,31 +15,30 @@ which enables fast read and write operations. It is compatible with a variety of platforms and has interfaces for the Fortran, Python, OCaml and Rust programming languages. -* [TREXIO](#trexio) - * [Installation](#installation) - * [Installation using a package manager](#installation-using-a-package-manager) - * [Conda](#conda) - * [Spack](#spack) - * [Guix](#guix) - * [Debian/Ubuntu](#debianubuntu) - * [Installation from source](#installation-from-source) - * [Minimal requirements (for users):](#minimal-requirements-for-users) - * [Recommended: Installation from the release tarball](#recommended-installation-from-the-release-tarball) - * [Compilation without the HDF5 library](#compilation-without-the-hdf5-library) - * [For TREXIO developers: from the GitHub repo clone](#for-trexio-developers-from-the-github-repo-clone) - * [Using CMake instead of Autotools](#using-cmake-instead-of-autotools) - * [Using TREXIO](#using-trexio) - * [Naming convention](#naming-convention) - * [Tutorial](#tutorial) - * [Documentation](#documentation) - * [Linking to your program](#linking-to-your-program) - * [Distributing TREXIO with your code](#distributing-trexio-with-your-code) - * [APIs for other languages](#apis-for-other-languages) - * [Python](#python) - * [Rust](#rust) - * [OCaml](#ocaml) - * [Citation](#citation) - * [Miscellaneous](#miscellaneous) +* [Installation](#installation) + * [Installation using a package manager](#installation-using-a-package-manager) + * [Conda](#conda) + * [Spack](#spack) + * [Guix](#guix) + * [Debian/Ubuntu](#debianubuntu) + * [Installation from source](#installation-from-source) + * [Minimal requirements (for users):](#minimal-requirements-for-users) + * [Recommended: Installation from the release tarball](#recommended-installation-from-the-release-tarball) + * [Compilation without the HDF5 library](#compilation-without-the-hdf5-library) + * [For TREXIO developers: from the GitHub repo clone](#for-trexio-developers-from-the-github-repo-clone) + * [Using CMake instead of Autotools](#using-cmake-instead-of-autotools) +* [Using TREXIO](#using-trexio) + * [Naming convention](#naming-convention) + * [Tutorial](#tutorial) + * [Documentation](#documentation) + * [Linking to your program](#linking-to-your-program) + * [Distributing TREXIO with your code](#distributing-trexio-with-your-code) +* [APIs for other languages](#apis-for-other-languages) + * [Python](#python) + * [Rust](#rust) + * [OCaml](#ocaml) +* [Citation](#citation) + * [Miscellaneous](#miscellaneous) ## Installation diff --git a/configure.ac b/configure.ac index 6b467c2..06ae3de 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) -AC_INIT([trexio],[2.5.0],[https://github.com/TREX-CoE/trexio/issues]) +AC_INIT([trexio],[2.5.1],[https://github.com/TREX-CoE/trexio/issues]) AC_CONFIG_SRCDIR([Makefile.in]) AC_CONFIG_HEADERS([include/config.h]) diff --git a/ocaml/trexio/trexio.opam b/ocaml/trexio/trexio.opam index 5d41dca..ccc8043 100644 --- a/ocaml/trexio/trexio.opam +++ b/ocaml/trexio/trexio.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "2.4.2" +version: "2.5.1" synopsis: "Binding for the TREXIO Input/Output library" description: "TREXIO is a file format and library for storing wave functions and integrals for quantum chemistry." diff --git a/python/README.md b/python/README.md index 8c95b88..de1749b 100644 --- a/python/README.md +++ b/python/README.md @@ -11,8 +11,8 @@ can be used to convert data from one input/output file format into another. ## Requirements -- python3 (>= 3.6) -- numpy (>= 1.17.3) +- python3 (>= 3.8) +- numpy (>= 1.17.3) ## Installation from PyPI @@ -27,10 +27,6 @@ However, it is good practice to first check for updates of the build-system pack **Note: we highly recommend to use virtual environments to avoid compatibility issues and to improve reproducibility.** For more details, see the corresponding part of the [Python documentation](https://docs.python.org/3/library/venv.html#creating-virtual-environments). -**Note: our build farm (GitHub Actions) does not support ARM64 architectures (including the Mac M1/M2 chips). Therefore, `pip install trexio` does not work on an ARM64-based machine. Thus, we recommend to install TREXIO from source on an ARM64-based machine. If one uses a Mac where HDF5 is installed with brew (i.e., `brew install hdf5`), a workaround is to execute the following 2 lines before doing `pip install trexio`:** - -- `export H5_CFLAGS="-I$(brew --prefix hdf5)/include"` -- `export H5_LDFLAGS="-L$(brew --prefix hdf5)/lib"` ## Additional requirements (for installation from source) @@ -50,6 +46,9 @@ For more details, see the corresponding part of the [Python documentation](https The following two steps can be skipped if HDF5 is properly configured for `pkg-config` (i.e. if executing `pkg-config --libs hdf5` returns a list of options). - `export H5_CFLAGS=-I/path/to/hdf5/include` - `export H5_LDFLAGS=-L/path/to/hdf5/lib` +On MacOS where HDF5 is installed with homebrew (i.e. `brew install hdf5`), one can use the following: + - `export H5_CFLAGS="-I$(brew --prefix hdf5)/include"` + - `export H5_LDFLAGS="-L$(brew --prefix hdf5)/lib"` 6. `pip install .` (this installs `trexio` in your environment) 7. `cd test && python -m pytest -v test_api.py` (this executes several tests that verify the installation) diff --git a/python/build_manylinux_wheels.sh b/python/build_manylinux_wheels.sh index 1da66ea..a45d960 100755 --- a/python/build_manylinux_wheels.sh +++ b/python/build_manylinux_wheels.sh @@ -46,22 +46,9 @@ function build_wheel_for_py() PYVERSION=${1} # derive manylinux glibc tag from the PLAT env variable provided to docker run - # this is needed to avoid building wheel for 2010_x86_64 with CPython 3.10 - # because NumPy does not have wheels for it MANYLINUX_TAG=${PLAT:9:4} - if [[ ${PYVERSION} -eq 310 ]] && [[ ${MANYLINUX_TAG} -eq 2010 ]]; then - echo "Skip build of the wheel for CPython 3.10 on manylinux2010_x86_64" - return - fi - # python versions <= 3.7 required additional "m" in the platform tag, e.g. cp37-cp37m - if [[ ${PYVERSION} -eq 36 ]] || [[ ${PYVERSION} -eq 37 ]]; then - PYM="m" - else - PYM="" - fi - - CPYTHON="cp${PYVERSION}-cp${PYVERSION}${PYM}" + CPYTHON="cp${PYVERSION}-cp${PYVERSION}" # create and activate a virtual environment based on CPython version ${PYVERSION} /opt/python/${CPYTHON}/bin/python3 -m venv --clear trexio-manylinux-py${PYVERSION} @@ -88,7 +75,7 @@ function build_wheel_for_py() pytest -v test/test_api.py # cleaning - rm -rf -- dist/ build/ trexio.egg-info/ + rm -rf -- dist/ build/ trexio.egg-info/ #rm -- test_file_py.h5 unsafe_test_file_py.h5 # deactivate the current environment @@ -103,7 +90,7 @@ function build_wheel_for_py() # build wheels for all versions of CPython in this container -for CPYVERSION in 37 38 39 310 +for CPYVERSION in 38 39 310 311 312 313 do build_wheel_for_py ${CPYVERSION} done diff --git a/python/install_pytrexio.sh b/python/install_pytrexio.sh index d6a0767..9f21dbc 100755 --- a/python/install_pytrexio.sh +++ b/python/install_pytrexio.sh @@ -63,8 +63,9 @@ else export H5_CFLAGS=${H5_CFLAGS_LOCAL} fi + # Install/upgrade packages required for the installation -python3 -m pip install --upgrade setuptools build pip +python3 -m pip install build python3 -m pip install -r requirements.txt python3 -m pip install pytest diff --git a/python/pyproject.toml b/python/pyproject.toml index b8ca0a0..95513f0 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -3,6 +3,6 @@ requires = [ "setuptools>=42", "wheel", "pkgconfig", - "oldest-supported-numpy" + "numpy", ] build-backend = "setuptools.build_meta" diff --git a/python/pytrexio/_version.py b/python/pytrexio/_version.py index 50062f8..7a2056f 100644 --- a/python/pytrexio/_version.py +++ b/python/pytrexio/_version.py @@ -1 +1 @@ -__version__ = "2.5.0" +__version__ = "2.5.1" diff --git a/python/requirements.txt b/python/requirements.txt index eddf522..e7bbedf 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,4 +1,3 @@ setuptools>=42 pkgconfig -numpy<1.27.0 -numpy>=1.17.3 +numpy diff --git a/rust/trexio/Cargo.toml b/rust/trexio/Cargo.toml index 12c2258..32d34b6 100644 --- a/rust/trexio/Cargo.toml +++ b/rust/trexio/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trexio" -version = "2.5.0" +version = "2.5.1" edition = "2021" license = "BSD-3-Clause" authors = ["Anthony Scemama ", "Evgeny Posenitskiy"] diff --git a/src/numpy.i b/src/numpy.i index 36bb55c..c8c26cb 100644 --- a/src/numpy.i +++ b/src/numpy.i @@ -48,7 +48,7 @@ %fragment("NumPy_Backward_Compatibility", "header") { -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION %#define NPY_ARRAY_DEFAULT NPY_DEFAULT %#define NPY_ARRAY_FARRAY NPY_FARRAY %#define NPY_FORTRANORDER NPY_FORTRAN @@ -69,7 +69,7 @@ { /* Macros to extract array attributes. */ -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION %#define is_array(a) ((a) && PyArray_Check((PyArrayObject*)a)) %#define array_type(a) (int)(PyArray_TYPE((PyArrayObject*)a)) %#define array_numdims(a) (((PyArrayObject*)a)->nd) @@ -114,17 +114,12 @@ if (py_obj == NULL ) return "C NULL value"; if (py_obj == Py_None ) return "Python None" ; if (PyCallable_Check(py_obj)) return "callable" ; - if (PyString_Check( py_obj)) return "string" ; - if (PyInt_Check( py_obj)) return "int" ; + if (PyBytes_Check( py_obj)) return "string" ; + if (PyLong_Check( py_obj)) return "int" ; if (PyFloat_Check( py_obj)) return "float" ; if (PyDict_Check( py_obj)) return "dict" ; if (PyList_Check( py_obj)) return "list" ; if (PyTuple_Check( py_obj)) return "tuple" ; -%#if PY_MAJOR_VERSION < 3 - if (PyFile_Check( py_obj)) return "file" ; - if (PyModule_Check( py_obj)) return "module" ; - if (PyInstance_Check(py_obj)) return "instance" ; -%#endif return "unknown type"; } @@ -170,13 +165,11 @@ return PyArray_EquivTypenums(actual_type, desired_type); } -%#ifdef SWIGPY_USE_CAPSULE - void free_cap(PyObject * cap) +void free_cap(PyObject * cap) { void* array = (void*) PyCapsule_GetPointer(cap,SWIGPY_CAPSULE_NAME); if (array != NULL) free(array); } -%#endif } @@ -298,7 +291,7 @@ Py_INCREF(array_descr(ary)); result = (PyArrayObject*) PyArray_FromArray(ary, array_descr(ary), -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION NPY_FORTRANORDER); %#else NPY_ARRAY_F_CONTIGUOUS); @@ -529,7 +522,7 @@ return success; } - /* Require the given PyArrayObject to to be Fortran ordered. If the + /* Require the given PyArrayObject to be Fortran ordered. If the * the PyArrayObject is already Fortran ordered, do nothing. Else, * set the Fortran ordering flag and recompute the strides. */ @@ -545,7 +538,7 @@ const npy_intp *dims = array_dimensions(ary); for (i=0; i < nd; ++i) n_non_one += (dims[i] != 1) ? 1 : 0; - if (n_non_one > 1) + if (n_non_one > 1) array_clearflags(ary,NPY_ARRAY_CARRAY); array_enableflags(ary,NPY_ARRAY_FARRAY); /* Recompute the strides */ @@ -2007,7 +2000,7 @@ (PyObject* array = NULL) { npy_intp dims[1]; - if (!PyInt_Check($input)) + if (!PyLong_Check($input)) { const char* typestring = pytype_string($input); PyErr_Format(PyExc_TypeError, @@ -2015,7 +2008,8 @@ typestring); SWIG_fail; } - $2 = (DIM_TYPE) PyInt_AsLong($input); + $2 = (DIM_TYPE) PyLong_AsSsize_t($input); + if ($2 == -1 && PyErr_Occurred()) SWIG_fail; dims[0] = (npy_intp) $2; array = PyArray_SimpleNew(1, dims, DATA_TYPECODE); if (!array) SWIG_fail; @@ -2035,7 +2029,7 @@ (PyObject* array = NULL) { npy_intp dims[1]; - if (!PyInt_Check($input)) + if (!PyLong_Check($input)) { const char* typestring = pytype_string($input); PyErr_Format(PyExc_TypeError, @@ -2043,7 +2037,8 @@ typestring); SWIG_fail; } - $1 = (DIM_TYPE) PyInt_AsLong($input); + $1 = (DIM_TYPE) PyLong_AsSsize_t($input); + if ($1 == -1 && PyErr_Occurred()) SWIG_fail; dims[0] = (npy_intp) $1; array = PyArray_SimpleNew(1, dims, DATA_TYPECODE); if (!array) SWIG_fail; @@ -2462,13 +2457,9 @@ if (!array) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -2496,13 +2487,9 @@ if (!array) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$2), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -2531,13 +2518,9 @@ if (!array) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -2566,13 +2549,9 @@ if (!array) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$3), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -2601,13 +2580,9 @@ if (!array || !require_fortran(array)) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -2636,13 +2611,9 @@ if (!array || !require_fortran(array)) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$3), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -2673,13 +2644,9 @@ if (!array) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -2710,13 +2677,9 @@ if (!array) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$4), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -2747,13 +2710,9 @@ if (!array || !require_fortran(array)) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -2784,13 +2743,9 @@ if (!array || !require_fortran(array)) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$4), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -2822,13 +2777,9 @@ if (!array) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -2860,165 +2811,9 @@ if (!array) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$5), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 - PyArray_BASE(array) = cap; -%#else - PyArray_SetBaseObject(array,cap); -%#endif - - $result = SWIG_Python_AppendOutput($result,obj); -} - -/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, - DIM_TYPE* DIM3, DIM_TYPE* DIM4) - */ -%typemap(in,numinputs=0) - (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) - (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) -{ - $1 = &data_temp; - $2 = &dim1_temp; - $3 = &dim2_temp; - $4 = &dim3_temp; - $5 = &dim4_temp; -} -%typemap(argout, - fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") - (DATA_TYPE** ARGOUTVIEWM_FARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) -{ - npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; - PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); - PyArrayObject* array = (PyArrayObject*) obj; - - if (!array || !require_fortran(array)) SWIG_fail; - -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif - -%#if NPY_API_VERSION < 0x00000007 - PyArray_BASE(array) = cap; -%#else - PyArray_SetBaseObject(array,cap); -%#endif - - $result = SWIG_Python_AppendOutput($result,obj); -} - -/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, - DATA_TYPE** ARGOUTVIEWM_FARRAY4) - */ -%typemap(in,numinputs=0) - (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEWM_FARRAY4) - (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) -{ - $1 = &dim1_temp; - $2 = &dim2_temp; - $3 = &dim3_temp; - $4 = &dim4_temp; - $5 = &data_temp; -} -%typemap(argout, - fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements,NumPy_Utilities") - (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_FARRAY4) -{ - npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; - PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); - PyArrayObject* array = (PyArrayObject*) obj; - - if (!array || !require_fortran(array)) SWIG_fail; - -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif - -%#if NPY_API_VERSION < 0x00000007 - PyArray_BASE(array) = cap; -%#else - PyArray_SetBaseObject(array,cap); -%#endif - - $result = SWIG_Python_AppendOutput($result,obj); -} - -/* Typemap suite for (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, - DIM_TYPE* DIM3, DIM_TYPE* DIM4) - */ -%typemap(in,numinputs=0) - (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 ) - (DATA_TYPE* data_temp = NULL , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp) -{ - $1 = &data_temp; - $2 = &dim1_temp; - $3 = &dim2_temp; - $4 = &dim3_temp; - $5 = &dim4_temp; -} -%typemap(argout, - fragment="NumPy_Backward_Compatibility,NumPy_Utilities") - (DATA_TYPE** ARGOUTVIEWM_ARRAY4, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4) -{ - npy_intp dims[4] = { *$2, *$3, *$4 , *$5 }; - PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$1)); - PyArrayObject* array = (PyArrayObject*) obj; - - if (!array) SWIG_fail; - -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif - -%#if NPY_API_VERSION < 0x00000007 - PyArray_BASE(array) = cap; -%#else - PyArray_SetBaseObject(array,cap); -%#endif - - $result = SWIG_Python_AppendOutput($result,obj); -} - -/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, - DATA_TYPE** ARGOUTVIEWM_ARRAY4) - */ -%typemap(in,numinputs=0) - (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DIM_TYPE* DIM3 , DIM_TYPE* DIM4 , DATA_TYPE** ARGOUTVIEWM_ARRAY4) - (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DIM_TYPE dim4_temp, DATA_TYPE* data_temp = NULL ) -{ - $1 = &dim1_temp; - $2 = &dim2_temp; - $3 = &dim3_temp; - $4 = &dim4_temp; - $5 = &data_temp; -} -%typemap(argout, - fragment="NumPy_Backward_Compatibility,NumPy_Utilities") - (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DIM_TYPE* DIM4, DATA_TYPE** ARGOUTVIEWM_ARRAY4) -{ - npy_intp dims[4] = { *$1, *$2, *$3 , *$4 }; - PyObject* obj = PyArray_SimpleNewFromData(4, dims, DATA_TYPECODE, (void*)(*$5)); - PyArrayObject* array = (PyArrayObject*) obj; - - if (!array) SWIG_fail; - -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif - -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -3050,13 +2845,9 @@ if (!array || !require_fortran(array)) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); @@ -3088,13 +2879,9 @@ if (!array || !require_fortran(array)) SWIG_fail; -%#ifdef SWIGPY_USE_CAPSULE - PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME, free_cap); -%#else - PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1), free); -%#endif +PyObject* cap = PyCapsule_New((void*)(*$5), SWIGPY_CAPSULE_NAME, free_cap); -%#if NPY_API_VERSION < 0x00000007 +%#if NPY_API_VERSION < NPY_1_7_API_VERSION PyArray_BASE(array) = cap; %#else PyArray_SetBaseObject(array,cap); diff --git a/tools/prepare_python.sh b/tools/prepare_python.sh index bf316bf..e59c638 100755 --- a/tools/prepare_python.sh +++ b/tools/prepare_python.sh @@ -11,7 +11,11 @@ fi DO_HDF5=0 if [[ -z ${1} ]] && [[ "${1}" == "--without-hdf5" ]] ; then - echo "Compiling Python API without the HDF5 back end." + echo "" + echo "******************** WARNING **********************" + echo "* Compiling Python API without the HDF5 back end. *" + echo "***************************************************" + echo "" DO_HDF5=1 else echo "Compiling Python API with the HDF5 back end."