Skip to content

Commit 8262292

Browse files
authored
update build system (#519)
* replace setup.py with pyporject.toml for easier maintenance and compatibility with PEP 517. * updated pypi publish Action to utilize build instead of 'python setup.py sdist bdis_wheel' as recommended by https://packaging.python.org/en/latest/discussions/setup-py-deprecated/ * updated docs to reflect changes to build system. * updated test execution location because /examples is not installed as a package. * fix typo in RTD instructions * Revert "updated test execution location because /examples is not installed as a package." This reverts commit 943d1ae. * copied /examples/distr/distr_data.py to /mpisppy/tests/ and updated some imports accordingly. * correcting import error introduced in an earlier commit
1 parent ddf07a9 commit 8262292

18 files changed

+500
-29
lines changed

.github/workflows/publish-to-test-pypi.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ jobs:
1717
python-version: 3.11
1818
- name: Install mpi-sppy
1919
run: |
20-
python -m pip install --user --upgrade setuptools wheel
20+
python -m pip install --user --upgrade pip
21+
pip install build
2122
- name: Build a binary wheel and a source tarball
2223
run: |
23-
python3 setup.py sdist bdist_wheel
24+
python -m build
2425
- name: Publish distribution to Test PyPI
2526
uses: pypa/gh-action-pypi-publish@release/v1
2627
with:

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,9 @@ dmypy.json
131131
# .svn
132132
.svn/
133133

134+
# emacs artifacts
135+
*~
136+
*#*
137+
134138
# .DS_Store
135139
.DS_Store

.readthedocs.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
# Required
55
version: 2
66

7-
87
build:
9-
os: ubuntu-22.04
10-
tools:
11-
python: "3.9"
8+
os: ubuntu-22.04
9+
tools:
10+
python: "3.9"
1211

1312
# Build documentation in the docs/ directory with Sphinx
1413
sphinx:
15-
configuration: doc/src/conf.py
14+
configuration: doc/src/conf.py
1615

1716
# we need mpi-sppy for automodule
1817
python:
19-
install:
20-
- requirements: requirements-doc.txt
18+
install:
19+
- method: pip
20+
path: .
21+
extra_requirements:
22+
- doc

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Here are two methods that seem to work well for installation, at least when cons
2828

2929
* ``pip install mpi4py``
3030

31+
#. It is also possible to automate mpi4py installation through pip as an optional dependency when installing mpi-sppy from pip or from source by adding the `[mpi]` extras flag.
32+
33+
* ``pip install -e .[mpi]`` (after cloning and moving to the repo root directory)
34+
3135
To test
3236
your installation, cd to the directory where you installed mpi-sppy
3337
(it is called ``mpi-sppy``) and then give this command.

doc/src/install_mpi.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Here are two methods that seem to work well for installation, at least when cons
1616

1717
* ``pip install mpi4py``
1818

19+
#. It is also possible to automate mpi4py installation through pip as an optional dependency when installing mpi-sppy from pip or from source by adding the `[mpi]` extras flag.
20+
21+
* ``pip install -e .[mpi]`` (after cloning and moving to the repo root directory)
22+
1923
To test
2024
your installation, cd to the directory where you installed mpi-sppy
2125
(it is called ``mpi-sppy``) and then give this command.

doc/src/quick_start.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
Quick Start
22
===========
33

4-
If you installed from github, run `setup.py` from the mpi-sppy directory.
4+
If you installed from github, install from source using pip in editable mode from the mpi-sppy repo root directory.
55

66
::
77
8-
python setup.py develop
8+
pip install -e .
99

1010
This step is not needed if you installed using pip.
11+
You can also include the extras flags ``mpi`` to install a compliant version
12+
of mpi4py or ``docs`` to install documentation dependencies from pip.
1113

1214

1315
Verify installation

examples/stoch_distr/globalmodel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import pyomo.environ as pyo
1616
import stoch_distr
17-
import examples.distr.distr_data as distr_data
17+
import mpisppy.tests.examples.distr.distr_data as distr_data
1818
from mpisppy.utils import config
1919

2020
def _parse_args():
@@ -98,4 +98,4 @@ def main():
9898

9999

100100
if __name__ == "__main__":
101-
main()
101+
main()

examples/stoch_distr/stoch_distr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Network Flow - various formulations
1010
import pyomo.environ as pyo
1111
import mpisppy.utils.sputils as sputils
12-
import examples.distr.distr_data as distr_data
12+
import mpisppy.tests.examples.distr.distr_data as distr_data
1313
import numpy as np
1414

1515
# In this file, we create a (linear) inter-region minimal cost distribution problem.
@@ -396,4 +396,4 @@ def inparser_adder(cfg):
396396
cfg.add_to_config("ensure_xhat_feas",
397397
description="adds slacks with high costs to ensure the feasibility of xhat yet maintaining the optimal",
398398
domain=bool,
399-
default=False)
399+
default=False)

examples/stoch_distr/stoch_distr_admm_cylinders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Driver file for stochastic admm
1212
import mpisppy.utils.stoch_admmWrapper as stoch_admmWrapper
1313

14-
import examples.distr.distr_data as distr_data
14+
import mpisppy.tests.examples.distr.distr_data as distr_data
1515
import stoch_distr
1616

1717
from mpisppy.spin_the_wheel import WheelSpinner

examples/stoch_distr/stoch_distr_ef.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# Solves the stochastic distribution problem
1414
import stoch_distr
1515
import stoch_distr_admm_cylinders
16-
import examples.distr.distr_data as distr_data
16+
import mpisppy.tests.examples.distr.distr_data as distr_data
1717
import pyomo.environ as pyo
1818

1919
import mpisppy.utils.sputils as sputils
@@ -93,4 +93,4 @@ def main():
9393

9494

9595
if __name__ == "__main__":
96-
main()
96+
main()

0 commit comments

Comments
 (0)