diff --git a/.github/workflows/dolfinx-tests.yml b/.github/workflows/dolfinx-tests.yml index 6bf34ef40..2e0d8340c 100644 --- a/.github/workflows/dolfinx-tests.yml +++ b/.github/workflows/dolfinx-tests.yml @@ -37,14 +37,13 @@ jobs: OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Basix run: | cmake -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build-dir -S ./cpp cmake --build build-dir cmake --install build-dir python3 -m pip install ./python - - name: Install FEniCS Python components if: github.event_name != 'workflow_dispatch' run: | @@ -55,17 +54,16 @@ jobs: run: | python3 -m pip install git+https://github.com/FEniCS/ufl.git@${{ github.event.inputs.ufl_branch }} python3 -m pip install git+https://github.com/FEniCS/ffcx.git@${{ github.event.inputs.ffcx_branch }} - - name: Get DOLFINx if: github.event_name != 'workflow_dispatch' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: ./dolfinx repository: FEniCS/dolfinx ref: main - name: Get DOLFINx if: github.event_name == 'workflow_dispatch' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: ./dolfinx repository: FEniCS/dolfinx @@ -79,12 +77,10 @@ jobs: run: | python3 -m pip install -r dolfinx/python/build-requirements.txt # TO REMOVE python3 -m pip -v install --check-build-dependencies --no-build-isolation dolfinx/python/ - - name: Run mypy checks run: | cd dolfinx/python python3 -m mypy dolfinx - - name: Build DOLFINx C++ unit tests run: | cmake -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build/test/ -S dolfinx/cpp/test/ @@ -93,12 +89,10 @@ jobs: run: | cd build/test ctest -V --output-on-failure -R unittests - - name: Run DOLFINx Python unit tests run: | cd dolfinx python3 -m pytest -n auto python/test/unit - - name: Run DOLFINx Python demos run: | cd dolfinx/ diff --git a/.github/workflows/ffcx-tests.yml b/.github/workflows/ffcx-tests.yml index b16c82306..d9cde4da9 100644 --- a/.github/workflows/ffcx-tests.yml +++ b/.github/workflows/ffcx-tests.yml @@ -27,46 +27,37 @@ jobs: build: name: Run FFCx tests runs-on: ubuntu-latest - env: - CC: gcc-10 - CXX: g++-10 - steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: - python-version: 3.9 - + python-version: '3.11' - name: Install dependencies run: sudo apt-get install -y libopenblas-dev liblapack-dev graphviz libgraphviz-dev ninja-build - - name: Install UFL (default branch) if: github.event_name != 'workflow_dispatch' - run: python3 -m pip install git+https://github.com/FEniCS/ufl.git + run: pip install git+https://github.com/FEniCS/ufl.git - name: Install UFL (specified branch) if: github.event_name == 'workflow_dispatch' - run: python3 -m pip install git+https://github.com/FEniCS/ufl.git@${{ github.event.inputs.ufl_branch }} - + run: pip install git+https://github.com/FEniCS/ufl.git@${{ github.event.inputs.ufl_branch }} - name: Install Basix - run: python3 -m pip -v install .[ci] - + run: pip -v install .[ci] - name: Get FFCx source (default branch) if: github.event_name != 'workflow_dispatch' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: ./ffcx repository: FEniCS/ffcx ref: main - name: Get FFCx source (specified branch) if: github.event_name == 'workflow_dispatch' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: ./ffcx repository: FEniCS/ffcx ref: ${{ github.event.inputs.ffcx_branch }} - - name: Install FFCx - run: python3 -m pip install ./ffcx[ci] + run: pip install ./ffcx[ci] - name: Run FFCx tests - run: python3 -m pytest -n auto ffcx/test + run: pytest -n auto --ignore=ffcx/test/test_lnodes.py ffcx/test diff --git a/.github/workflows/intel.yml b/.github/workflows/intel.yml index 090059176..01eff83aa 100644 --- a/.github/workflows/intel.yml +++ b/.github/workflows/intel.yml @@ -17,43 +17,35 @@ on: jobs: build: name: Build and test (oneAPI) - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest container: ubuntu:22.04 # Run in container to test with minimal pre-installed packages - env: CC: icx CXX: icpx DEBIAN_FRONTEND: noninteractive - steps: - name: Install required packages to install Intel compilers and to build run: apt -y update && apt install -y bzip2 cmake git gnupg ninja-build wget - - - uses: actions/checkout@v3 - + - uses: actions/checkout@v4 - name: Install Intel compilers and Intel Python run: | wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list apt update apt install -y intel-oneapi-compiler-dpcpp-cpp intel-oneapi-mkl intel-oneapi-python libstdc++-11-dev - - name: Install Basix run: | . /opt/intel/oneapi/setvars.sh pip -v install .[test] - - name: Run units tests run: | . /opt/intel/oneapi/setvars.sh pip install pytest-xdist pytest -n auto --durations 20 test/ - - name: Run Python demos run: | . /opt/intel/oneapi/setvars.sh pytest demo/python/test.py - - name: Run C++ demos run: | . /opt/intel/oneapi/setvars.sh diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index e7a0e760e..e79503e1b 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -21,32 +21,22 @@ on: jobs: build: name: Build and test (MacOS) - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-12] - + runs-on: macos-12 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.11" - name: Install dependencies (non-Python) run: brew install ninja - - name: Install Basix - run: | - python -m pip -v install .[test] - + run: pip -v install .[test] - name: Run units tests run: | - python -m pip install pytest-xdist - python -m pytest -n auto --durations 20 test/ - + pip install pytest-xdist + pytest -n auto --durations 20 test/ - name: Run python demos - run: python -m pytest demo/python/test.py - + run: pytest demo/python/test.py - name: Run C++ demos - run: | - python -m pytest demo/cpp/test.py + run: pytest demo/cpp/test.py diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 13ab68e70..698c7f5e9 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -26,9 +26,8 @@ jobs: matrix: os: [ubuntu-22.04] python-version: ["3.8", "3.9", "3.10", "3.11"] - steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: @@ -37,47 +36,28 @@ jobs: run: | sudo apt-get update sudo apt-get install -y doxygen graphviz libopenblas-dev liblapack-dev ninja-build - - name: Install Basix - run: python3 -m pip -v install .[ci] - + run: pip -v install .[ci] - name: Lint with flake8 - run: | - flake8 --statistics test/ - flake8 --statistics python/ - flake8 --statistics demo/python - + run: flake8 --statistics test/ python/ demo/python - name: Run mypy checks - run: | - python3 -m mypy python/basix - + run: mypy python/basix - name: pydocstyle checks - run: | - python3 -m pydocstyle python/basix - + run: pydocstyle python/basix - name: isort checks - run: | - python3 -m isort --check . - + run: isort --check . - name: Run units tests - run: | - python3 -m pytest -n auto --durations 20 test/ - + run: pytest -n auto --durations 20 test/ - name: Run simple CMake integration test run: | cd test/test_cmake cmake -DCMAKE_BUILD_TYPE=Debug -DPython3_EXECUTABLE=python3 -G Ninja -B build-dir -S . cmake --build build-dir/ build-dir/a.out - - name: Run Python demos - run: | - python3 -m pytest demo/python/test.py - + run: pytest demo/python/test.py - name: Run C++ demos - run: | - python3 -m pytest demo/cpp/test.py - + run: pytest demo/cpp/test.py - name: Build documentation run: | export BASIX_VERSION=`python3 -c "import basix; print(basix.__version__)"` @@ -85,7 +65,6 @@ jobs: doxygen cd ../python make html - - name: Upload C++ documentation artifact uses: actions/upload-artifact@v3 with: @@ -102,13 +81,11 @@ jobs: doc/python/build/html retention-days: 2 if-no-files-found: error - - name: Build website documentation run: | export BASIX_VERSION=`python3 -c "import basix; print(basix.__version__)"` cd doc/web python make_html.py - - name: Set version name if: ${{ github.repository == 'FEniCS/basix' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') ) && matrix.python-version == '3.11' }} run: | @@ -121,7 +98,7 @@ jobs: python make_html.py --url https://docs.fenicsproject.org/basix/${{ env.VERSION_NAME }} - name: Checkout FEniCS/docs if: ${{ github.repository == 'FEniCS/basix' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') ) && matrix.python-version == '3.11' }} - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: "FEniCS/docs" path: "docs" @@ -143,71 +120,69 @@ jobs: git commit --allow-empty -m "Update Basix docs FEniCS/basix@${{ github.sha }}" git push + isolated-python-build: + name: Build Python using '--no-build-isolation' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Install dependencies + run: sudo apt-get install -y libopenblas-dev liblapack-dev ninja-build + - name: Install Python dependencies + run: pip install nanobind scikit-build-core[pyproject] + - name: Install Basix + run: pip install --no-build-isolation . + build-cmake: name: Build using C++ and Python parts separately and run tests - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-22.04] - python-version: ["3.11"] - + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} + python-version: '3.11' - name: Install dependencies run: sudo apt-get install -y libopenblas-dev liblapack-dev - - name: Install Basix C++ library run: | cd cpp cmake -DCMAKE_BUILD_TYPE=Release -B build-dir -S . # Use make (not ninja) cmake --build build-dir sudo cmake --install build-dir - - name: Install Basix Python wrapper run: | cd python - python3 -m pip install .[test] - + pip install .[test] - name: Run units tests run: | - python3 -m pip install pytest-xdist # in ci extras, but most not needed. - python3 -m pytest -n auto --durations 20 test/ - + pip install pytest-xdist # in ci extras, but most not needed. + pytest -n auto --durations 20 test/ - name: Run Python demos - run: | - python3 -m pytest demo/python/test.py - + run: pytest demo/python/test.py - name: Run C++ demos - run: | - python3 -m pytest demo/cpp/test.py + run: pytest demo/cpp/test.py build-cpp-only: name: Build C++ only and run demos - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-22.04] - + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: sudo apt-get install -y libopenblas-dev liblapack-dev ninja-build - - name: Install Basix run: | cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -B build-dir -S cpp cmake --build build-dir sudo cmake --install build-dir - - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.11" - - name: Run C++ demos + - name: Run tests run: | - python3 -m pip install pytest - python3 -m pytest demo/cpp/test.py + pip install pytest + pytest demo/cpp/test.py diff --git a/.github/workflows/redhat.yml b/.github/workflows/redhat.yml index c1c72ea0a..73d08eed8 100644 --- a/.github/workflows/redhat.yml +++ b/.github/workflows/redhat.yml @@ -22,11 +22,9 @@ jobs: name: Build and test (Red Hat) runs-on: ubuntu-22.04 container: rockylinux/rockylinux:9 - env: CC: gcc CXX: g++ - steps: - name: Install dependencies run: | @@ -34,20 +32,14 @@ jobs: dnf install -y dnf-plugins-core dnf config-manager --set-enabled crb dnf install -y blas-devel cmake gcc gcc-c++ git lapack-devel python3 python3-devel python3-pip - - - uses: actions/checkout@v3 - + - uses: actions/checkout@v4 - name: Install Basix - run: | - python3 -m pip install .[test] - + run: python3 -m pip install .[test] - name: Run units tests run: | python3 -m pip install pytest-xdist python3 -m pytest -n auto --durations 20 test/ - - name: Run Python demos run: python3 -m pytest demo/python/test.py - name: Run C++ demos - run: | - python3 -m pytest demo/cpp/test.py + run: python3 -m pytest demo/cpp/test.py diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 50ab0672c..843d7079d 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -20,7 +20,7 @@ jobs: PETSC_ARCH: linux-gnu-real-32 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Install dependencies @@ -28,11 +28,12 @@ jobs: sudo apt-get update sudo apt-get install -y libopenblas-dev liblapack-dev ninja-build - name: Set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v2 with: - java-version: 11 + distribution: 'zulu' + java-version: 17 - name: Cache SonarCloud packages - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar @@ -61,5 +62,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" + run: sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" diff --git a/README.md b/README.md index 999c88b08..b9582fb70 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,10 @@ Basix is one of the components of FEniCSx, alongside [FFCx](https://github.com/fenics/ffcx), and [DOLFINx](https://github.com/fenics/dolfinx). -## Installing Basix -To install the latest stable version of Basix from [pypi.org](https://pypi.org/project/fenics-basix/): +## Installation + +To install Basix: ```console pip install fenics-basix ``` @@ -40,6 +41,7 @@ detailed [install instructions](INSTALL.md) Documentation of Basix can be found at https://docs.fenicsproject.org/basix/main/. + ## Support If you find a bug in Basix, you can report it on the [GitHub issue @@ -71,6 +73,7 @@ The following elements are supported on an interval: - [Hermite](https://defelement.com/elements/hermite.html) - [iso](https://defelement.com/elements/p1-iso-p2.html) + ### Triangle In Basix, the sub-entities of the reference triangle are numbered as @@ -165,6 +168,7 @@ The following elements are supported on a prism: - [Lagrange](https://defelement.com/elements/lagrange.html) + ### Pyramid In Basix, the sub-entities of the reference pyramid are numbered as diff --git a/pyproject.toml b/pyproject.toml index 448291569..f812fe720 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["scikit-build-core", "nanobind>=1.6.0"] +requires = ["scikit-build-core[pyproject]", "nanobind>=1.6.0"] build-backend = "scikit_build_core.build" # Minimum cmake and any necessary cmake install is handled by # scikit-build-core @@ -11,8 +11,11 @@ version = "0.8.0.dev0" description = "Basix Python interface" readme = "README.md" requires-python = ">=3.8.0" -license = {file = "LICENSE"} -authors = [{email="fenics-dev@googlegroups.com"}, {name="FEniCS Project"}] +license = { file = "LICENSE" } +authors = [ + { email = "fenics-dev@googlegroups.com" }, + { name = "FEniCS Project" }, +] packages = ["basix"] dependencies = ["numpy>=1.21"] @@ -55,11 +58,17 @@ test-skip = "*-macosx_arm64 *-*linux_aarch64" manylinux-x86_64-image = "manylinux_2_28" [tool.cibuildwheel.linux] -archs = ["x86_64", "aarch64"] # Forces arm64 build on x86_64 runner using emulation. +archs = [ + "x86_64", + "aarch64", +] # Forces arm64 build on x86_64 runner using emulation. before-build = "yum -y update && yum install -y epel-release && yum install -y openblas-devel ninja-build" [tool.cibuildwheel.macos] -archs = ["x86_64", "arm64"] # Forces arm64 build on x86_64 runner using cross-compilation. +archs = [ + "x86_64", + "arm64", +] # Forces arm64 build on x86_64 runner using cross-compilation. before-build = "export HOMEBREW_AUTO_UPDATING=0 && brew update && brew install ninja" [tool.pydocstyle] diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 308580284..83bdf217f 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.19) if(APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") endif() + project(basix_nanobind VERSION "0.8.0.0" LANGUAGES CXX) # Set C++ standard @@ -11,7 +12,6 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) - # See https://gitlab.kitware.com/cmake/cmake/-/issues/16414 if(TARGET basix) add_library(Basix::basix ALIAS basix) @@ -29,7 +29,7 @@ list(APPEND CMAKE_PREFIX_PATH "${NB_DIR}") find_package(nanobind CONFIG REQUIRED) # Create the binding library -nanobind_add_module(_basixcpp MODULE wrapper.cpp) +nanobind_add_module(_basixcpp wrapper.cpp) target_link_libraries(_basixcpp PRIVATE Basix::basix) # Add strict compiler flags @@ -38,6 +38,7 @@ CHECK_CXX_COMPILER_FLAG("-Wall -Werror -Wextra -Wno-comment -pedantic" HAVE_PEDA if(HAVE_PEDANTIC) target_compile_options(_basixcpp PRIVATE -Wall;-Wextra;-Werror;-Wno-comment) + # target_compile_options(_basixcpp PRIVATE -Wall;-Wextra;-Werror;-Wno-comment;-pedantic) endif() diff --git a/python/pyproject.toml b/python/pyproject.toml index b1a87391e..a2fc3fd7b 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["scikit-build-core", "nanobind>=1.6.0"] +requires = ["scikit-build-core[pyproject]", "nanobind>=1.6.0"] build-backend = "scikit_build_core.build" # Minimum cmake and any necessary cmake install is handled by # scikit-build-core @@ -11,8 +11,11 @@ version = "0.8.0.dev0" description = "Basix Python interface" readme = "../README.md" requires-python = ">=3.8.0" -license = {file = "../LICENSE"} -authors = [{email="fenics-dev@googlegroups.com"}, {name="FEniCS Project"}] +license = { file = "../LICENSE" } +authors = [ + { email = "fenics-dev@googlegroups.com" }, + { name = "FEniCS Project" }, +] packages = ["basix"] dependencies = ["numpy>=1.21"]