From efdde5c5c5dfd1c9e0f4ef04e10f2f0711b9f570 Mon Sep 17 00:00:00 2001 From: BenjaminRodenberg Date: Fri, 23 Apr 2021 13:21:28 +0200 Subject: [PATCH 01/14] Remove MPI as dependency. --- README.md | 2 -- cyprecice/cyprecice.pyx | 1 - setup.py | 4 +--- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 193a3c54..88f25146 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,6 @@ Please refer to [precice.org](https://www.precice.org/installation-bindings-pyth **preCICE**: Refer to [the preCICE wiki](https://github.com/precice/precice/wiki#1-get-precice) for information on building and installation. -**MPI**: `mpi4py` requires MPI to be installed on your system. - # Installing the package We recommend using pip3 (version 19.0.0 or newer required) for the sake of simplicity. You can check your pip3 version via `pip3 --version`. To update pip3, use the following line: diff --git a/cyprecice/cyprecice.pyx b/cyprecice/cyprecice.pyx index 3b858988..c5479421 100644 --- a/cyprecice/cyprecice.pyx +++ b/cyprecice/cyprecice.pyx @@ -7,7 +7,6 @@ The python module precice offers python language bindings to the C++ coupling li cimport cyprecice import numpy as np -from mpi4py import MPI from cpython.version cimport PY_MAJOR_VERSION # important for determining python version in order to properly normalize string input. See http://docs.cython.org/en/latest/src/tutorial/strings.html#general-notes-about-c-strings and https://github.com/precice/precice/issues/68 . diff --git a/setup.py b/setup.py index b6efc9ff..536ea142 100644 --- a/setup.py +++ b/setup.py @@ -145,9 +145,7 @@ def initialize_options(self): author_email='info@precice.org', license='LGPL-3.0', python_requires='>=3', - install_requires=['numpy', 'mpi4py'], - # mpi4py is only needed, if preCICE was compiled with MPI - # see https://github.com/precice/python-bindings/issues/8 + install_requires=['numpy'], packages=['precice'], zip_safe=False # needed because setuptools are used ) From bf85d77b2b2ea8b59bb132a62ccbbf1b7771052e Mon Sep 17 00:00:00 2001 From: BenjaminRodenberg Date: Fri, 23 Apr 2021 19:15:21 +0200 Subject: [PATCH 02/14] Remove dependency at other places. --- .github/workflows/build-spack.yml | 2 +- spack/repo/packages/py-pyprecice/package.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-spack.yml b/.github/workflows/build-spack.yml index 1d734b7c..a40dbd2f 100644 --- a/.github/workflows/build-spack.yml +++ b/.github/workflows/build-spack.yml @@ -22,4 +22,4 @@ jobs: cp spack/repo/packages/py-pyprecice/*.patch /py-pyprecice-repo/packages/py-pyprecice/ - name: Try to build py-pyprecice with spack and test it run: | - . /opt/spack/share/spack/setup-env.sh && spack env activate ci && spack arch && spack find && spack dev-build py-pyprecice@develop target=x86_64 && spack load precice py-numpy py-mpi4py py-cython openssh openmpi && mkdir runner && cd runner && python3 -c "import precice; print(precice.__version__)" + . /opt/spack/share/spack/setup-env.sh && spack env activate ci && spack arch && spack find && spack dev-build py-pyprecice@develop target=x86_64 && spack load precice py-numpy py-cython openssh openmpi && mkdir runner && cd runner && python3 -c "import precice; print(precice.__version__)" diff --git a/spack/repo/packages/py-pyprecice/package.py b/spack/repo/packages/py-pyprecice/package.py index 65817306..ca9d96a9 100644 --- a/spack/repo/packages/py-pyprecice/package.py +++ b/spack/repo/packages/py-pyprecice/package.py @@ -44,7 +44,6 @@ class PyPyprecice(PythonPackage): depends_on("python@3:", type=("build", "run")) depends_on("py-setuptools", type="build") depends_on("py-numpy", type=("build", "run")) - depends_on("py-mpi4py", type=("build", "run")) depends_on("py-cython@0.29:", type=("build")) phases = ['install_lib', 'build_ext', 'install'] From 33f5aad0884daeb4a5b74e1609b675d3c2f35aa1 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 29 Apr 2021 09:33:53 +0200 Subject: [PATCH 03/14] Remove travis --- .travis.yml | 28 ---------------------------- README.md | 4 ---- 2 files changed, 32 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1d4f4376..00000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: python -dist: trusty -os: linux - -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-6 - - libopenmpi-dev - - openmpi-bin - -jobs: - include: - - name: "Mock Test Python Bindings" - cache: false - before_install: - - pyenv global $(pyenv whence 2to3) # activate all python versions - - PYTHONPATH="" - - PY_CMD=python3 - - $PY_CMD -m pip install --upgrade pip wheel setuptools - install: - - pip3 install cython numpy mpi4py packaging - script: - - git clone https://github.com/precice/precice.git precice-core # use --branch $TRAVIS_BRANCH to select the proper branch especially master/develop - - export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$TRAVIS_BUILD_DIR/precice-core/src - - python3 setup.py test diff --git a/README.md b/README.md index 193a3c54..a1f1f112 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ Python language bindings for the C++ library preCICE ---------------------------------------------------- - - Build status - - [![Upload Python Package](https://github.com/precice/python-bindings/workflows/Upload%20Python%20Package/badge.svg?branch=master)](https://pypi.org/project/pyprecice/) This package provides python language bindings for the C++ library [preCICE](https://github.com/precice/precice). Note that the first three digits of the version number of the bindings indicate the preCICE version that the bindings support. The last digit represents the version of the bindings. Example: `v2.0.0.1` and `v2.0.0.2` of the bindings represent versions `1` and `2` of the bindings that are compatible with preCICE `v2.0.0`. From fc1e75b22b1770968a741563c92728fdb253264f Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 30 Apr 2021 13:13:17 +0200 Subject: [PATCH 04/14] Cloning preCICE and placing in correct folder for mock testing --- .github/workflows/build-and-test.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index df10f517..590c4166 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -71,8 +71,11 @@ jobs: setup_test: name: Run setup test runs-on: ubuntu-latest - container: precice/ci-ubuntu-1804 steps: + - name: Build OpenMPI + run : | + apt-get -yy update + apt-get install -y libopenmpi-dev - name: Checkout Repository uses: actions/checkout@v2 - name: Install & upgrade pip3 @@ -81,15 +84,15 @@ jobs: apt-get install -y python3-pip rm -rf /var/lib/apt/lists/* pip3 install --upgrade --user pip - - name: Checkout precice and make required files discoverable - run: | - git clone https://github.com/precice/precice.git precice-core - mkdir -p precice - cp precice-core/src/precice/SolverInterface.hpp precice/SolverInterface.hpp - name: Install dependencies run: | pip3 install --user toml python3 -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))' | pip3 install -r /dev/stdin + - name: Checkout precice and make required files discoverable + run: | + git clone https://github.com/precice/precice.git precice-core + mkdir -p precice + cp precice-core/src/precice/SolverInterface.hpp precice/SolverInterface.hpp - name: Run setup test run: | export CFLAGS=-I$GITHUB_WORKSPACE From d91aa81a2a0821517de08645c8c0d648585b0801 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 30 Apr 2021 13:20:12 +0200 Subject: [PATCH 05/14] Move linopenmpi-dev into other apt-get command --- .github/workflows/build-and-test.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 590c4166..fd9577a6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -72,16 +72,12 @@ jobs: name: Run setup test runs-on: ubuntu-latest steps: - - name: Build OpenMPI - run : | - apt-get -yy update - apt-get install -y libopenmpi-dev - name: Checkout Repository uses: actions/checkout@v2 - - name: Install & upgrade pip3 + - name: Install & upgrade pip3 and install OpenMPI run: | apt-get -yy update - apt-get install -y python3-pip + apt-get install -y python3-pip libopenmpi-dev rm -rf /var/lib/apt/lists/* pip3 install --upgrade --user pip - name: Install dependencies From f507962ac1b8756ee1ca2e54abe110b205ee80a4 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 30 Apr 2021 13:30:59 +0200 Subject: [PATCH 06/14] Trying without libopenmpi-dev package --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index fd9577a6..4bec1e1a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -77,7 +77,7 @@ jobs: - name: Install & upgrade pip3 and install OpenMPI run: | apt-get -yy update - apt-get install -y python3-pip libopenmpi-dev + apt-get install -y python3-pip rm -rf /var/lib/apt/lists/* pip3 install --upgrade --user pip - name: Install dependencies From 86a31a6719d86aff1ae35cf5f17d7c82504f50ee Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 30 Apr 2021 15:57:48 +0200 Subject: [PATCH 07/14] Adding sudo apt-get commands in testing --- .github/workflows/build-and-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4bec1e1a..778c4a5b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -76,8 +76,8 @@ jobs: uses: actions/checkout@v2 - name: Install & upgrade pip3 and install OpenMPI run: | - apt-get -yy update - apt-get install -y python3-pip + sudo apt-get -yy update + sudo apt-get install -y python3-pip libopenmpi-dev rm -rf /var/lib/apt/lists/* pip3 install --upgrade --user pip - name: Install dependencies From c3a333546f97b3612e72eb1662665dd5915708ce Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 30 Apr 2021 15:59:54 +0200 Subject: [PATCH 08/14] sudo rm commands --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 778c4a5b..cdc28dc0 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -78,7 +78,7 @@ jobs: run: | sudo apt-get -yy update sudo apt-get install -y python3-pip libopenmpi-dev - rm -rf /var/lib/apt/lists/* + sudo rm -rf /var/lib/apt/lists/* pip3 install --upgrade --user pip - name: Install dependencies run: | From 27d6691cb1d7c774e3eb39e6287480e80a8c6607 Mon Sep 17 00:00:00 2001 From: BenjaminRodenberg Date: Fri, 30 Apr 2021 19:52:55 +0200 Subject: [PATCH 09/14] Don't install MPI in test, since it's not needed. --- .github/workflows/build-and-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index cdc28dc0..448dd971 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -74,10 +74,10 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Install & upgrade pip3 and install OpenMPI + - name: Install & upgrade pip3 run: | sudo apt-get -yy update - sudo apt-get install -y python3-pip libopenmpi-dev + sudo apt-get install -y python3-pip sudo rm -rf /var/lib/apt/lists/* pip3 install --upgrade --user pip - name: Install dependencies From 4c417cbeac05e175d2cbe7e014244dbce3c2d80d Mon Sep 17 00:00:00 2001 From: BenjaminRodenberg Date: Fri, 30 Apr 2021 20:01:42 +0200 Subject: [PATCH 10/14] Remove mpi4py dependency. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0e050577..a9064dd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] # PEP 518 - minimum build system requirements -requires = ["setuptools", "wheel", "Cython>=0.29", "packaging", "pip>=19.0.0", "numpy", "mpi4py"] +requires = ["setuptools", "wheel", "Cython>=0.29", "pip>=19.0.0", "numpy"] From bfe9acba22101fed36056021880b89baa20ca108 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Fri, 30 Apr 2021 20:22:05 +0200 Subject: [PATCH 11/14] Comment out mpi test --- test/test_bindings_module.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test_bindings_module.py b/test/test_bindings_module.py index e5d174d0..3d0fc2ad 100644 --- a/test/test_bindings_module.py +++ b/test/test_bindings_module.py @@ -1,7 +1,7 @@ import precice from unittest import TestCase import numpy as np -from mpi4py import MPI +#from mpi4py import MPI class TestBindings(TestCase): @@ -12,11 +12,11 @@ class TestBindings(TestCase): def test_constructor(self): solver_interface = precice.Interface("test", "dummy.xml", 0, 1) self.assertTrue(True) - - def test_constructor_custom_mpi_comm(self): - solver_interface = precice.Interface( - "test", "dummy.xml", 0, 1, MPI.COMM_WORLD) - self.assertTrue(True) + + #def test_constructor_custom_mpi_comm(self): + # solver_interface = precice.Interface( + # "test", "dummy.xml", 0, 1, MPI.COMM_WORLD) + # self.assertTrue(True) def test_version(self): precice.__version__ From 874452e8060b68e3fae6f278ceb100f0a47737e0 Mon Sep 17 00:00:00 2001 From: BenjaminRodenberg Date: Fri, 30 Apr 2021 20:26:23 +0200 Subject: [PATCH 12/14] Make MPI tests and dependency optional. --- test/test_bindings_module.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/test_bindings_module.py b/test/test_bindings_module.py index 3d0fc2ad..d82b79ad 100644 --- a/test/test_bindings_module.py +++ b/test/test_bindings_module.py @@ -1,7 +1,13 @@ import precice from unittest import TestCase import numpy as np -#from mpi4py import MPI +import warnings +try: + from mpi4py import MPI + has_mpi = True +except ModuleNotFoundError: + warnings.warn("No MPI detected. Some tests will not be run.") + has_mpi = False class TestBindings(TestCase): @@ -12,11 +18,12 @@ class TestBindings(TestCase): def test_constructor(self): solver_interface = precice.Interface("test", "dummy.xml", 0, 1) self.assertTrue(True) - - #def test_constructor_custom_mpi_comm(self): - # solver_interface = precice.Interface( - # "test", "dummy.xml", 0, 1, MPI.COMM_WORLD) - # self.assertTrue(True) + + if has_mpi: + def test_constructor_custom_mpi_comm(self): + solver_interface = precice.Interface( + "test", "dummy.xml", 0, 1, MPI.COMM_WORLD) + self.assertTrue(True) def test_version(self): precice.__version__ From 84f51c2bf03268a9b4142337c9beb39c124f4b84 Mon Sep 17 00:00:00 2001 From: BenjaminRodenberg Date: Fri, 30 Apr 2021 20:49:05 +0200 Subject: [PATCH 13/14] Add test with and without mpi. --- .github/workflows/build-and-test.yml | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3c4a356f..5e125f32 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -80,6 +80,12 @@ jobs: sudo apt-get install -y python3-pip sudo rm -rf /var/lib/apt/lists/* pip3 install --upgrade --user pip + - name: Install OpenMPI and mpi4py + run: | + sudo apt-get -yy update + sudo apt-get install -y libopenmpi-dev + sudo rm -rf /var/lib/apt/lists/* + pip3 install --user mpi4py - name: Checkout precice and make required files discoverable run: | git clone https://github.com/precice/precice.git precice-core @@ -93,7 +99,33 @@ jobs: run: | export CFLAGS=-I$GITHUB_WORKSPACE python3 setup.py test - + + setup_test_no_mpi: + name: Run setup test + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Install & upgrade pip3 + run: | + sudo apt-get -yy update + sudo apt-get install -y python3-pip + sudo rm -rf /var/lib/apt/lists/* + pip3 install --upgrade --user pip + - name: Checkout precice and make required files discoverable + run: | + git clone https://github.com/precice/precice.git precice-core + mkdir -p precice + cp precice-core/src/precice/SolverInterface.hpp precice/SolverInterface.hpp + - name: Install dependencies + run: | + pip3 install --user toml + python3 -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))' | pip3 install -r /dev/stdin + - name: Run setup test + run: | + export CFLAGS=-I$GITHUB_WORKSPACE + python3 setup.py test + pip_install: name: Run pip install needs: [setup_test] From f5959a402ea91074a2be26e1dcd81174dbe92370 Mon Sep 17 00:00:00 2001 From: BenjaminRodenberg Date: Fri, 30 Apr 2021 21:38:15 +0200 Subject: [PATCH 14/14] Make tests distinguishable --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 5e125f32..2161688f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -101,7 +101,7 @@ jobs: python3 setup.py test setup_test_no_mpi: - name: Run setup test + name: Run setup test (without MPI based tests) runs-on: ubuntu-latest steps: - name: Checkout Repository