Skip to content

Commit

Permalink
Fixes for Python 3.12, NumPy 2.0, and SciPy 1.14 (#1050)
Browse files Browse the repository at this point in the history
* Monkeypatch versioneer.py

- Python 3.12 doesn't like SafeConfigParser
- Python 2.7 doesn't like versioneer > 0.18

* Replace obj2sctype

* Replace `.getsctype()` with `.dtype`

* Replace `NUMERIX.issubclass_()` with `issubclass()`

* Replace `itemset()` with indexing

* Fix obsolete name for infinity

* Fix comparison operator representation

* Use `ins.argrepr` for representation of operator variables

* Remove future.standard_library

This library no longer exists in Python 3.12

It looks like it isn't even needed in Python 2.7 to use pickle
and redirecting_html.py should go away (but fixed it anyway).

* Update locks

* Add `return_scalar` to `__array_wrap__` for NumPy 2.0

* Add `copy=` argument to `__array__` for NumPy 2.0

* Address `copy=None` for NumPy < 2.0

Based on https://github.com/scipy/scipy/pull/20172/files
as suggested by https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword

* Defer return_scalar for OperatorVariables

* Replace deprecated `numpy.in1d` with `numpy.isin`

* Replace deprecated `tol=` with `rtol=` to SciPy Krylov solvers

* Replace deprecated `atol='legacy'` for SciPy Krylov solves

* Remove internal implementation details of numpy.array2string

* Override legacy formatting set for tests

* Lock out petsc 3.21

petsc(4py) 3.21.2 crashes when running tests in parallel:

```
mesh2D (examples.cahnHilliard)
Doctest: examples.cahnHilliard.mesh2D ...  Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
 Internal error 2 in DMUMPS_LOAD_RECV_MSGS  1275068685          52
 Internal error 1 in DMUMPS_LOAD_PROCESS_MESSAGE
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
 Internal error 1 in DMUMPS_LOAD_PROCESS_MESSAGE
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
 Internal error 2 in DMUMPS_LOAD_RECV_MSGS  1275068685          52
 Internal error 1 in DMUMPS_LOAD_PROCESS_MESSAGE
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
 Internal error 1 in DMUMPS_LOAD_PROCESS_MESSAGE
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
 Internal error 2 in DMUMPS_LOAD_RECV_MSGS  1275068685          52
 Internal error 1 in DMUMPS_LOAD_PROCESS_MESSAGE
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
```

* Make directory that already exists

* Fix case of tarball

* Fix type of int Variable for Windows

* build(nix): update to python 3.12 and nixos 24.05

Update Nix build to use Python 3.12, NixOS 24.05. Also, include
aarch4-darwin as a possible build.

Currently, there is a single test failure in
fipy.matrices.scipyMatrix._ScipyMatrix.

* ci(actions): generate egg_info

Generate the egg_info before executing the tests otherwise setup.py
doesn't register the correct version of the test suite, but possibly
the older version already available in nixpkgs.

---------

Co-authored-by: Daniel Wheeler <[email protected]>
  • Loading branch information
guyer and wd15 authored Jun 25, 2024
1 parent 6236076 commit 66774ea
Show file tree
Hide file tree
Showing 37 changed files with 10,227 additions and 7,180 deletions.
12 changes: 6 additions & 6 deletions .azure/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ stages:
- bash: |
conda create --quiet --name wheelEnvironment --channel conda-forge python=3.10
source activate wheelEnvironment
mkdir tmp
mkdir -p tmp
cd tmp
python -m pip install ../dist/*.whl
FIPY_SOLVERS=scipy python -c "import fipy; fipy.test()"
Expand All @@ -232,11 +232,11 @@ stages:
- bash: |
source activate myEnvironment
FIPY_VERSION=`python setup.py --version`
mkdir tmp
mkdir -p tmp
cd tmp
cp ../dist/FiPy-${FIPY_VERSION}.tar.gz .
tar zxvf FiPy-${FIPY_VERSION}.tar.gz
cd FiPy-${FIPY_VERSION}
cp ../dist/fipy-${FIPY_VERSION}.tar.gz .
tar zxvf fipy-${FIPY_VERSION}.tar.gz
cd fipy-${FIPY_VERSION}
python setup.py install
cd ..
python -c "import fipy; fipy.test()"
Expand All @@ -248,7 +248,7 @@ stages:
- bash: |
source activate myEnvironment
FIPY_VERSION=`python setup.py --version`
mkdir tmp
mkdir -p tmp
cd tmp
cp ../dist/FiPy-${FIPY_VERSION}.zip .
unzip FiPy-${FIPY_VERSION}.zip
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
with:
path: /run/user/${{ env.UID }}/http_cache.sqlite
key: ${{ runner.os }}-http_cache.sqlite
- run: nix develop --command bash -c "python setup.py egg_info"
- run: nix develop --command bash -c "python setup.py test"
- run: nix develop --command bash -c "py.test --nbval --nbval-sanitize-with examples/sanitize.cfg examples/index.ipynb"
- uses: actions/cache/save@v3
Expand Down
10 changes: 5 additions & 5 deletions docs/source/sphinxext/redirecting_html.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import unicode_literals
from future import standard_library
standard_library.install_aliases()
from docutils import nodes
import urllib.parse

try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
from sphinx.builders.html import StandaloneHTMLBuilder

class RedirectingHTMLBuilder(StandaloneHTMLBuilder):
Expand All @@ -17,7 +17,7 @@ def write_doc(self, docname, doctree):
for node in doctree.traverse(nodes.reference):
try:
uri = node['refuri']
uri = urllib.parse.urlparse(uri)
uri = urlparse(uri)
if uri.scheme in ["http", "https"]:
if not uri.netloc.endswith("nist.gov"):
node['refuri'] = "/cgi-bin/redirect.py?url=" + uri.geturl()
Expand Down
322 changes: 175 additions & 147 deletions environments/locks/conda-petsc-linux-64.lock

Large diffs are not rendered by default.

Loading

0 comments on commit 66774ea

Please sign in to comment.