Skip to content

Commit 32ade92

Browse files
authored
Merge pull request #49 from simpeg/pyproject_update
Switch to pyproject.toml based install
2 parents 3297054 + 9d9b60f commit 32ade92

23 files changed

+245
-197
lines changed

.bumpversion.cfg

Lines changed: 0 additions & 3 deletions
This file was deleted.

.coveragerc

Lines changed: 0 additions & 9 deletions
This file was deleted.

.git_archival.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
4+
ref-names: $Format:%D$

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git_archival.txt export-subst

.github/workflows/python-package-conda.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,17 @@ jobs:
6262
run: |
6363
make coverage
6464
65+
- name: Generate Source Distribution
66+
if: ${{ (matrix.os == 'ubuntu-latest') && (matrix.python-version == '3.11') }}
67+
run: |
68+
pip install build twine
69+
python -m build --sdist .
70+
twine check dist/*
71+
6572
- name: Test Documentation
6673
if: ${{ (matrix.os == 'ubuntu-latest') && (matrix.python-version == '3.11') }}
6774
run: |
68-
pip install -r requirements_docs.txt
75+
pip install .[docs]
6976
cd docs
7077
make html
7178
cd ..
@@ -79,38 +86,41 @@ jobs:
7986
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8087

8188
distribute:
82-
name: Distributing from 3.8
89+
name: Distributing
8390
needs: build-and-test
8491
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
8592
runs-on: ubuntu-latest
8693
defaults:
8794
run:
8895
shell: bash -l {0}
96+
env:
97+
PYTHON_VERSION: '3.11'
8998

9099
steps:
91100
- uses: actions/checkout@v4
92101
- name: Setup Conda
93102
uses: conda-incubator/setup-miniconda@v3
94103
with:
95104
auto-update-conda: true
96-
activate-environment: dev
97-
python-version: 3.8
105+
channels: conda-forge
106+
python-version: ${{ env.PYTHON_VERSION }}
98107

99-
- name: Install Env
108+
- name: Install Base Env
100109
run: |
101110
conda info
102111
conda list
103112
conda config --show
104-
conda install --quiet --yes -c conda-forge pip numpy scipy pydiso
105-
pip install -r requirements_docs.txt
113+
conda install --quiet --yes pip numpy scipy
106114
107115
- name: Install Our Package
108116
run: |
109-
pip install -v -e .
117+
pip install -v -e .[docs]
110118
111119
- name: Generate Source Distribution
112120
run: |
113-
python setup.py sdist
121+
pip install build twine
122+
python -m build --sdist .
123+
twine check dist/*
114124
115125
- name: Build Documentation
116126
run: |
@@ -119,15 +129,16 @@ jobs:
119129
cd ..
120130
121131
- name: GitHub Pages
122-
uses: crazy-max/ghaction-github-pages@v2.5.0
132+
uses: crazy-max/ghaction-github-pages@v4
123133
with:
124134
build_dir: docs/_build/html
125135
jekyll: false
136+
keep_history: true
126137
env:
127138
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128139

129140
- name: pypi-publish
130-
uses: pypa/gh-action-pypi-publish@v1.4.2
141+
uses: pypa/gh-action-pypi-publish@v1
131142
with:
132143
user: __token__
133144
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.coverage
22
coverage.xml
3+
coverage_html_report/
34
*.pyc
45
*.so
56
build/

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
prune .github
2+
prune docs
3+
prune tests
4+
exclude .gitignore MANIFEST.in .pre-commit-config.yaml
5+
exclude .git_archival.txt .gitattributes Makefile

Makefile

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
1-
.PHONY: build coverage lint graphs tests docs mumps mumps_mac mumps_install_mac
2-
3-
build:
4-
python setup.py build_ext --inplace
1+
.PHONY: coverage tests docs
52

63
coverage:
7-
pytest --cov-config=.coveragerc --cov-report=xml --cov=pymatsolver -s -v
8-
9-
lint:
10-
pylint --output-format=html pymatsolver > pylint.html
11-
12-
graphs:
13-
pyreverse -my -A -o pdf -p pymatsolver pymatsolver/**.py pymatsolver/**/**.py
4+
pytest --cov --cov-config=pyproject.toml -s -v
5+
coverage xml
146

157
tests:
168
pytest
179

1810
docs:
1911
cd docs;make html
20-
21-
mumps:
22-
cd pymatsolver/mumps;make build
23-
24-
mumps_mac:
25-
cd pymatsolver/mumps;make build_mac
26-
27-
mumps_install_mac:
28-
brew install mumps --with-scotch5 --without-mpi

README.rst

Lines changed: 21 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pymatsolver
99
:target: https://github.com/simpeg/pymatsolver/blob/master/LICENSE
1010
:alt: MIT license.
1111

12-
.. image:: https://codecov.io/gh/simpeg/pymatsolver/branch/master/graph/badge.svg
12+
.. image:: https://codecov.io/gh/simpeg/pymatsolver/branch/main/graph/badge.svg?token=8uQoxzxf3r
1313
:target: https://codecov.io/gh/simpeg/pymatsolver
1414
:alt: Coverage status
1515

@@ -32,68 +32,42 @@ All solvers work with :code:`scipy.sparse` matricies, and a single or multiple r
3232

3333
* L/U Triangular Solves
3434
* Wrapping of SciPy matrix solvers (direct and indirect)
35-
* Pardiso solvers now that MKL comes with conda!
36-
* Mumps solver with nice error messages
35+
* Pardiso solvers
36+
* Mumps solvers
3737

3838

39-
Installing Mumps
40-
================
39+
Installing Solvers
40+
==================
41+
Often, there are faster solvers available for your system than the default scipy factorizations available.
42+
pymatsolver provides a consistent interface to both MKL's ``Pardiso`` routines and the ``MUMPS`` solver package. To
43+
make use of these we use intermediate wrappers for the libraries that must be installed separately.
4144

42-
We have not been able to get the pip install to work because of multiple dependencies on fortran libraries.
43-
However, the linux and mac installs are relatively easy. Note that you must have mumps pre-installed,
44-
currently we have only got this working for the sequential version, so when you are installing,
45-
you will need to point to that one. You can also look at the `.travis.yml` file for how to get it working on TravisCI.
45+
Pardiso
46+
-------
47+
The Pardiso interface is recommended for Intel processor based systems. The interface is enabled by
48+
the ``pydiso`` python package, which can be installed through conda-forge as:
4649

47-
Linux
48-
-----
49-
50-
From a clean install on Ubuntu:
51-
52-
.. code-block:: bash
53-
54-
apt-get update
55-
apt-get -y install gcc gfortran git libopenmpi-dev libmumps-seq-dev libblas-dev liblapack-dev
56-
57-
# Install all the python you need!
58-
wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh -O miniconda.sh;
59-
chmod +x miniconda.sh
60-
./miniconda.sh -b
61-
export PATH=/root/anaconda/bin:/root/miniconda/bin:$PATH
62-
conda update --yes conda
63-
conda install --yes numpy scipy matplotlib cython ipython pytest coverage
64-
65-
git clone https://github.com/rowanc1/pymatsolver.git
66-
cd pymatsolver
67-
make mumps
50+
.. code::
6851
69-
Mac
70-
---
52+
conda install -c conda-forge pydiso
7153
72-
This assumes that you have Brew and some python installed (numpy, scipy):
73-
74-
.. code-block:: bash
75-
76-
brew install mumps --with-scotch5 --without-mpi
77-
78-
git clone https://github.com/rowanc1/pymatsolver.git
79-
cd pymatsolver
80-
make mumps_mac
81-
82-
If you have problems you may have to go into the Makefile and update the pointers to Lib and Include for the various libraries.
54+
Mumps
55+
-----
56+
Mumps is available for all platforms. The mumps interface is enabled by installing the ``python-mumps``
57+
wrapper package. This can easily be installed through conda-forge with:
8358

84-
This command is helpful for finding dependencies. You should also take note of have happens when brew installs mumps.
59+
.. code::
8560
86-
.. code-block:: bash
61+
conda install -c conda-forge python-mumps
8762
88-
mpicc --showme
8963
9064
9165
Code:
9266
https://github.com/simpeg/pymatsolver
9367

9468

9569
Tests:
96-
https://travis-ci.org/simpeg/pymatsolver
70+
https://github.com/simpeg/pymatsolver/actions
9771

9872

9973
Bugs & Issues:

pymatsolver/__init__.py

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,6 @@
4949
Mumps
5050
"""
5151

52-
SolverHelp = {}
53-
AvailableSolvers = {
54-
"Diagonal": True,
55-
"Solver": True,
56-
"SolverLU": True,
57-
"SolverCG": True,
58-
"Triangle": True,
59-
"Pardiso": False,
60-
"Mumps": False
61-
}
62-
6352
# Simple solvers
6453
from .solvers import Diagonal, Triangle, Forward, Backward
6554
from .wrappers import wrap_direct, WrapDirect
@@ -71,35 +60,58 @@
7160
from .iterative import BiCGJacobi
7261

7362
# Scipy direct solvers
74-
from .direct import Solver
63+
from .direct import Solver, pardiso
7564
from .direct import SolverLU
7665

77-
from .solvers import PymatsolverAccuracyError
66+
from .solvers import SolverAccuracyError
67+
from .direct import Pardiso, Mumps
68+
from .direct.pardiso import _available as _pardiso_available
69+
from .direct.mumps import _available as _mumps_available
70+
71+
SolverHelp = {}
72+
AvailableSolvers = {
73+
"Diagonal": True,
74+
"Solver": True,
75+
"SolverLU": True,
76+
"SolverCG": True,
77+
"Triangle": True,
78+
"Pardiso": _pardiso_available,
79+
"Mumps": _mumps_available,
80+
}
7881

7982
BicgJacobi = BiCGJacobi # backwards compatibility
83+
PardisoSolver = Pardiso # backwards compatibility
8084

81-
try:
82-
from .direct import Pardiso
83-
AvailableSolvers['Pardiso'] = True
84-
PardisoSolver = Pardiso # backwards compatibility
85-
except ImportError:
85+
if not AvailableSolvers["Pardiso"]:
8686
SolverHelp['Pardiso'] = """Pardiso is not working
8787
8888
Ensure that you have pydiso installed, which may also require Python
8989
to be installed through conda.
9090
"""
9191

92-
try:
93-
from .direct import Mumps
94-
AvailableSolvers['Mumps'] = True
95-
except ImportError:
92+
if not AvailableSolvers["Mumps"]:
9693
SolverHelp['Mumps'] = """Mumps is not working.
9794
9895
Ensure that you have python-mumps installed, which may also require Python
9996
to be installed through conda.
10097
"""
10198

102-
__version__ = '0.2.0'
10399
__author__ = 'SimPEG Team'
104100
__license__ = 'MIT'
105101
__copyright__ = '2013 - 2024, SimPEG Team, https://simpeg.xyz'
102+
103+
from importlib.metadata import version, PackageNotFoundError
104+
105+
# Version
106+
try:
107+
# - Released versions just tags: 0.8.0
108+
# - GitHub commits add .dev#+hash: 0.8.1.dev4+g2785721
109+
# - Uncommitted changes add timestamp: 0.8.1.dev4+g2785721.d20191022
110+
__version__ = version("pymatsolver")
111+
except PackageNotFoundError:
112+
# If it was not installed, then we don't know the version. We could throw a
113+
# warning here, but this case *should* be rare. discretize should be
114+
# installed properly!
115+
from datetime import datetime
116+
117+
__version__ = "unknown-" + datetime.today().strftime("%Y%m%d")

pymatsolver/direct/__init__.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
from ..wrappers import WrapDirect
21
from scipy.sparse.linalg import spsolve, splu
32

3+
from ..wrappers import WrapDirect
4+
from .pardiso import Pardiso
5+
from .mumps import Mumps
6+
47
Solver = WrapDirect(spsolve, factorize=False, name="Solver")
58
SolverLU = WrapDirect(splu, factorize=True, name="SolverLU")
69

7-
__all__ = ["Solver", "SolverLU"]
8-
try:
9-
from .pardiso import Pardiso
10-
__all__ += ["Pardiso"]
11-
except ImportError:
12-
pass
13-
14-
try:
15-
from .mumps import Mumps
16-
__all__ += ["Mumps"]
17-
except ImportError:
18-
pass
10+
__all__ = ["Solver", "SolverLU", "Pardiso", "Mumps"]

pymatsolver/direct/mumps.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
from pymatsolver.solvers import Base
2-
from mumps import Context
2+
try:
3+
from mumps import Context
4+
_available = True
5+
except ImportError:
6+
Context = None
7+
_available = False
38

49
class Mumps(Base):
510
"""The MUMPS direct solver.
@@ -33,6 +38,10 @@ class Mumps(Base):
3338
_transposed = False
3439

3540
def __init__(self, A, ordering=None, is_symmetric=None, is_positive_definite=False, check_accuracy=False, check_rtol=1e-6, check_atol=0, accuracy_tol=None, **kwargs):
41+
if not _available:
42+
raise ImportError(
43+
"The Mumps solver requires the python-mumps package to be installed."
44+
)
3645
is_hermitian = kwargs.pop('is_hermitian', False)
3746
super().__init__(A, is_symmetric=is_symmetric, is_positive_definite=is_positive_definite, is_hermitian=is_hermitian, check_accuracy=check_accuracy, check_rtol=check_rtol, check_atol=check_atol, accuracy_tol=accuracy_tol, **kwargs)
3847
if ordering is None:

0 commit comments

Comments
 (0)