Bug#1058127: python-mpiplus: FTBFS: AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'?

Yogeswaran Umasankar kd8mbd at gmail.com
Sun Jan 14 16:46:30 GMT 2024


Hi,
I created a patch for fixing AttributeError: module 'configparser' has
no attribute 'SafeConfigParser'. In the process I have updated it to the
latest upstream too. I’ve attached the debdiff for you to check out.
Cheers!
-------------- next part --------------
diff -Nru python-mpiplus-0.0.1/debian/changelog python-mpiplus-0.0.2/debian/changelog
--- python-mpiplus-0.0.1/debian/changelog	2022-11-05 14:33:23.000000000 +0000
+++ python-mpiplus-0.0.2/debian/changelog	2024-01-14 01:30:00.000000000 +0000
@@ -1,3 +1,12 @@
+python-mpiplus (0.0.2-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * New upstream 0.0.2.
+  * Patch for configparser and version issue. (Closes: #1058127)
+  * Included d/tests/pytest to avoid __file__ attribute issues.
+
+ -- Yogeswaran Umasankar <kd8mbd at gmail.com>  Sun, 14 Jan 2024 01:30:00 +0000
+
 python-mpiplus (0.0.1-2) unstable; urgency=medium
 
   * Add autopkgtest.
diff -Nru python-mpiplus-0.0.1/debian/patches/001_AttributeError-fix-py312.patch python-mpiplus-0.0.2/debian/patches/001_AttributeError-fix-py312.patch
--- python-mpiplus-0.0.1/debian/patches/001_AttributeError-fix-py312.patch	1970-01-01 00:00:00.000000000 +0000
+++ python-mpiplus-0.0.2/debian/patches/001_AttributeError-fix-py312.patch	2024-01-14 01:30:00.000000000 +0000
@@ -0,0 +1,30 @@
+Description: Fix for AttributeError: module 'configparser'
+ Revising configparser did not fix the error. Seems mpiplus/_version.py is not
+ compatible with latest setuptools. Time being fix is to set version number in setup.py
+Author: Yogeswaran Umasankar <kd8mbd at gmail.com>
+Last-Update: 2024-01-14
+
+--- a/versioneer.py
++++ b/versioneer.py
+@@ -339,9 +339,9 @@ def get_config_from_root(root):
+     # configparser.NoOptionError (if it lacks "VCS="). See the docstring at
+     # the top of versioneer.py for instructions on writing your setup.cfg .
+     setup_cfg = os.path.join(root, "setup.cfg")
+-    parser = configparser.SafeConfigParser()
++    parser = configparser.ConfigParser()
+     with open(setup_cfg, "r") as f:
+-        parser.readfp(f)
++        parser.read_file(f)
+     VCS = parser.get("versioneer", "VCS")  # mandatory
+ 
+     def get(parser, name):
+--- a/setup.py
++++ b/setup.py
+@@ -13,7 +13,7 @@ setup(
+     author='Chodera Lab',
+     description=DOCLINES[0],
+     long_description="\n".join(DOCLINES[2:]),
+-    version=versioneer.get_version(),
++    version='0.0.2',
+     cmdclass=versioneer.get_cmdclass(),
+     license='MIT',
diff -Nru python-mpiplus-0.0.1/debian/patches/series python-mpiplus-0.0.2/debian/patches/series
--- python-mpiplus-0.0.1/debian/patches/series	1970-01-01 00:00:00.000000000 +0000
+++ python-mpiplus-0.0.2/debian/patches/series	2024-01-14 01:30:00.000000000 +0000
@@ -0,0 +1 @@
+001_AttributeError-fix-py312.patch
\ No newline at end of file
diff -Nru python-mpiplus-0.0.1/debian/tests/control python-mpiplus-0.0.2/debian/tests/control
--- python-mpiplus-0.0.1/debian/tests/control	2022-10-21 06:30:12.000000000 +0000
+++ python-mpiplus-0.0.2/debian/tests/control	2024-01-14 01:30:00.000000000 +0000
@@ -1,4 +1,4 @@
-Test-Command: pytest-3
+Tests: pytest
 Depends:
  python3-pytest,
  @,
diff -Nru python-mpiplus-0.0.1/debian/tests/pytest python-mpiplus-0.0.2/debian/tests/pytest
--- python-mpiplus-0.0.1/debian/tests/pytest	1970-01-01 00:00:00.000000000 +0000
+++ python-mpiplus-0.0.2/debian/tests/pytest	2024-01-14 01:30:00.000000000 +0000
@@ -0,0 +1,7 @@
+#!/bin/bash
+set -e
+
+for py in $(py3versions --supported 3> /dev/null)
+do
+        $py -m pytest -v mpiplus/tests
+done
diff -Nru python-mpiplus-0.0.1/devtools/conda-recipe/meta.yaml python-mpiplus-0.0.2/devtools/conda-recipe/meta.yaml
--- python-mpiplus-0.0.1/devtools/conda-recipe/meta.yaml	2018-10-24 21:16:03.000000000 +0000
+++ python-mpiplus-0.0.2/devtools/conda-recipe/meta.yaml	2023-04-27 17:21:36.000000000 +0000
@@ -17,6 +17,7 @@
   run:
     - python
     - numpy >=1.11
+    - mpi4py
 
 test:
   requires:
diff -Nru python-mpiplus-0.0.1/docs/installation.rst python-mpiplus-0.0.2/docs/installation.rst
--- python-mpiplus-0.0.1/docs/installation.rst	2018-10-24 21:16:03.000000000 +0000
+++ python-mpiplus-0.0.2/docs/installation.rst	2023-04-27 17:21:36.000000000 +0000
@@ -6,7 +6,8 @@
 Installing via `conda`
 ======================
 
-mpiplus is not currently available via `conda`
+.. code-block:: bash
+   $ conda install -c conda-forge mpiplus
 
 
 Development Build
diff -Nru python-mpiplus-0.0.1/environment.yml python-mpiplus-0.0.2/environment.yml
--- python-mpiplus-0.0.1/environment.yml	1970-01-01 00:00:00.000000000 +0000
+++ python-mpiplus-0.0.2/environment.yml	2023-04-27 17:21:36.000000000 +0000
@@ -0,0 +1,12 @@
+name: mpiplus
+channels:
+  - conda-forge
+dependencies:
+  - mpi4py
+  - numpy >=1.11
+  - python
+  # testing
+  - coverage
+  - pytest
+  - pytest-cov
+  - pytest-xdist
diff -Nru python-mpiplus-0.0.1/.github/workflows/ci.yaml python-mpiplus-0.0.2/.github/workflows/ci.yaml
--- python-mpiplus-0.0.1/.github/workflows/ci.yaml	1970-01-01 00:00:00.000000000 +0000
+++ python-mpiplus-0.0.2/.github/workflows/ci.yaml	2023-04-27 17:21:36.000000000 +0000
@@ -0,0 +1,72 @@
+name: "CI"
+on:
+  pull_request:
+    branches:
+      - main
+  push:
+    branches:
+      - main
+  schedule:
+    # At 07:00 UTC Everyday.
+    - cron: "0 7 * * *"
+
+concurrency:
+  group: "${{ github.workflow }}-${{ github.ref }}"
+  cancel-in-progress: true
+
+defaults:
+  run:
+    shell: bash -l {0}
+
+jobs:
+  tests:
+    runs-on: ${{ matrix.OS }}-latest
+    name: "tests"
+    strategy:
+      fail-fast: false
+      matrix:
+        os: ['ubuntu', 'macos']
+        python-version:
+          - "3.9"
+          - "3.10"
+
+    steps:
+      - uses: actions/checkout at v3
+
+      # More info on options: https://github.com/conda-incubator/setup-miniconda
+      - name: Setup Micromamba
+        uses: mamba-org/provision-with-micromamba at main
+        with:
+          environment-file: environment.yml
+          environment-name: mpiplus
+          cache-env: true
+          cache-downloads: true
+          extra-specs: |
+            python==${{ matrix.python-version }}
+
+      - name: "Install"
+        run: python -m pip install --no-deps -e .
+
+      - name: "Test imports"
+        run: |
+          # if we add more to this, consider changing to for + env vars
+          python -Ic "import mpiplus; print(mpiplus.__version__)"
+
+      - name: "Environment Information"
+        run: |
+          micromamba info
+          micromamba list
+
+      - name: "Run tests"
+        run: |
+          pytest -n auto -v --cov=mpiplus --cov=mpiplus --cov-report=xml
+
+      - name: codecov
+        if: ${{ github.repository == 'choderalab/mpiplus'
+                && github.event_name != 'schedule' }}
+        uses: codecov/codecov-action at v3
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
+          file: coverage.xml
+          fail_ci_if_error: False
+          verbose: True
diff -Nru python-mpiplus-0.0.1/.github/workflows/clean_cache.yaml python-mpiplus-0.0.2/.github/workflows/clean_cache.yaml
--- python-mpiplus-0.0.1/.github/workflows/clean_cache.yaml	1970-01-01 00:00:00.000000000 +0000
+++ python-mpiplus-0.0.2/.github/workflows/clean_cache.yaml	2023-04-27 17:21:36.000000000 +0000
@@ -0,0 +1,34 @@
+# from https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
+name: cleanup caches by a branch
+on:
+  pull_request:
+    types:
+      - closed
+
+jobs:
+  cleanup:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Check out code
+        uses: actions/checkout at v3
+        
+      - name: Cleanup
+        run: |
+          gh extension install actions/gh-actions-cache
+          
+          REPO=${{ github.repository }}
+          BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
+
+          echo "Fetching list of cache key"
+          cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
+
+          ## Setting this to not fail the workflow while deleting cache keys. 
+          set +e
+          echo "Deleting caches..."
+          for cacheKey in $cacheKeysForPR
+          do
+              gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
+          done
+          echo "Done"
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff -Nru python-mpiplus-0.0.1/mpiplus/mpiplus.py python-mpiplus-0.0.2/mpiplus/mpiplus.py
--- python-mpiplus-0.0.1/mpiplus/mpiplus.py	2018-10-24 21:16:03.000000000 +0000
+++ python-mpiplus-0.0.2/mpiplus/mpiplus.py	2023-04-27 17:21:36.000000000 +0000
@@ -47,6 +47,7 @@
 import os
 import sys
 import signal
+import warnings
 from contextlib import contextmanager
 from traceback import format_exception
 
@@ -111,6 +112,15 @@
             use_mpi = True
             break
 
+    # Now we check if mpi4py is installed and warn users if we think they want to use mpi
+    # but they don't have mpi4py installed
+    try:
+        import mpi4py
+    except ImportError:
+        if use_mpi:
+            warnings.warn("mpirun environment variables detected, but mpi4py is not installed.")
+        use_mpi = False
+
     # Return None if we are not running on MPI.
     if not use_mpi:
         logger.debug('Cannot find MPI environment. MPI disabled.')
@@ -436,11 +446,12 @@
         to be distributed must the the first one.
     distributed_args : iterable
         The sequence of the parameters to distribute among nodes.
-    send_results_to : int, 'all', or None, optional
+    send_results_to : int, 'all', or None, optional, default='all'
         If the string 'all', the result will be sent to all nodes. If an
         int, the result will be send only to the node with rank ``send_results_to``.
-        The return value of distribute depends on the value of this parameter
-        (default is None).
+        If None no result will be sent to any other node
+        (This is useful if the distributed function is a routine).
+        The return value of distribute depends on the value of this parameter.
     propagate_exceptions_to : 'all', 'group', or None, optional
         When one of the processes raise an exception during the task execution,
         this controls which other processes raise it (default is 'all'). This
diff -Nru python-mpiplus-0.0.1/.travis.yml python-mpiplus-0.0.2/.travis.yml
--- python-mpiplus-0.0.1/.travis.yml	2018-10-24 21:16:03.000000000 +0000
+++ python-mpiplus-0.0.2/.travis.yml	1970-01-01 00:00:00.000000000 +0000
@@ -1,68 +0,0 @@
-language: python
-
-# Run jobs on container-based infrastructure, can be overridden per job
-dist: trusty
-
-#matrix:
-#  include:
-#    # Extra includes for OSX since python language is not available by default on OSX
-#    - os: osx
-#      language: generic
-#      env: PYTHON_VER=3.5
-#    - os: osx
-#      language: generic
-#      env: PYTHON_VER=3.6
-#
-#    - os: linux
-#      python: 3.5
-#      env: PYTHON_VER=3.5
-#    - os: linux
-#      python: 3.6
-#      env: PYTHON_VER=3.6
-env:
-  matrix:
-    - python=3.5 CONDA_PY=3.5
-    - python=3.6 CONDA_PY=3.6
-
-  global:
-    - ORGNAME="omnia"
-    - PACKAGENAME="mpiplus"
-
-before_install:
-    # Additional info about the build
-  - uname -a
-  - df -h
-  - ulimit -a
-
-    # Install the Python environment
-  - source devtools/travis-ci/before_install.sh
-  - python -V
-
-install:
-
-    # Create test environment for package
-  - conda create -n test python=$PYTHON_VER pip pytest pytest-cov "numpy>=1.11" 
-  - conda activate test
-  - conda config --add channels conda-forge
-    # Add omnia channel
-    # omina is prepended so coverage is installed from conda-forge
-  - conda config --append channels omnia 
-    # Add omnia dev channels
-    # - if [ $DEVOMNIA ]; then conda config --add channels https://conda.anaconda.org/omnia/label/dev; fi
-
-    # Install pip only modules
-  - pip install codecov
-
-    # Build and install package
-  - conda build --python=$PYTHON_VER devtools/conda-recipe
-  - conda install --use-local mpiplus
-
-
-script:
-  - pytest -v --cov=mpiplus mpiplus/tests/
-
-notifications:
-    email: false
-
-after_success:
-  - codecov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/debian-science-maintainers/attachments/20240114/25d57536/attachment.sig>


More information about the debian-science-maintainers mailing list