Skip to content

Commit

Permalink
refactor(dag): add NetworkX python package as DAG option (#98)
Browse files Browse the repository at this point in the history
Modified makefile generation to remove date and time so that changes
to makefiles are limited to source file name and dependency changes.
Refactored setup.py to a more modern format. Bumped version number
to 1.2.1. Black formatting. Added test of standard installation.
  • Loading branch information
jdhughes-usgs authored Dec 2, 2021
1 parent 4d8313f commit 5b8d6bd
Show file tree
Hide file tree
Showing 19 changed files with 364 additions and 253 deletions.
1 change: 1 addition & 0 deletions .github/common/install-python.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

python -m pip install --upgrade pip
pip install wheel
pip install .
pip install pytest pytest-cov coverage
pip install pydotplus appdirs
Expand Down
43 changes: 38 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,42 @@ jobs:
- name: Run pylint
run: pylint --jobs=0 --errors-only ./pymake

pymake_setup:
name: standard installation
runs-on: ubuntu-latest
strategy:
fail-fast: false
defaults:
run:
shell: bash

steps:

# check out repo
- name: Checkout pymake repo
uses: actions/[email protected]

- name: Setup Python 3.9
uses: actions/[email protected]
with:
python-version: 3.9

- name: Upgrade pip and install wheel
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Base pymake installation
run: |
pip install . --use-feature=in-tree-build
- name: Print pymake version
run: |
python -c "import pymake; print(pymake.__version__)"
pymakeCI-os-gcc:
name: pymake CI gcc on different OSs
needs: pymake_lint
needs: [pymake_lint, pymake_setup]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -109,7 +142,7 @@ jobs:

pymakeCI-os-intel:
name: pymake CI intel on different OSs
needs: pymake_lint
needs: [pymake_lint, pymake_setup]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -233,7 +266,7 @@ jobs:
pymakeCI-gcc-prev:
name: pymake CI GCC 9 and 8
needs: pymake_lint
needs: [pymake_lint, pymake_setup]
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -290,7 +323,7 @@ jobs:

pymakeCI-requests:
name: pymake CI requests
needs: pymake_lint
needs: [pymake_lint, pymake_setup]
runs-on: ubuntu-latest
defaults:
run:
Expand Down Expand Up @@ -324,7 +357,7 @@ jobs:

pymakeCI-python-prev:
name: pymake CI with previous python versions
needs: pymake_lint
needs: [pymake_lint, pymake_setup]
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
8 changes: 6 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Exclude files
global-exclude .DS_Store *.pyc *.pyo *.pyd *.swp *.bak *~ .* *.sh *.yml
global-exclude .DS_Store *.pyc *.pyo *.pyd *.swp *.bak *~ .* *.sh *.yml *.md *.toml
prune */__pycache__
# exclude directories
exclude docs/*
exclude autotest/*
# include specific files
include pymake/utils/usgsprograms.txt
recursive-include example *.py *.bat
include pymake/examples/*.bat
include pymake/examples/*.py
124 changes: 51 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Python package for compiling MODFLOW-based programs.


### Version 1.2
### Version 1.2.2
![pymake continuous integration](https://github.com/modflowpy/pymake/workflows/pymake%20continuous%20integration/badge.svg)
[![codecov](https://codecov.io/gh/modflowpy/pymake/branch/master/graph/badge.svg)](https://codecov.io/gh/modflowpy/pymake)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ff198bf587524161ad2bc60b3ab15979)](https://app.codacy.com/manual/jdhughes-usgs/pymake?utm_source=github.com&utm_medium=referral&utm_content=modflowpy/pymake&utm_campaign=Badge_Grade_Dashboard)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/fe4275a3cfb84acf9c84aba7b4ae2086)](https://www.codacy.com/gh/modflowpy/pymake/dashboard?utm_source=github.com&utm_medium=referral&utm_content=modflowpy/pymake&utm_campaign=Badge_Grade)
[![Documentation Status](https://readthedocs.org/projects/mfpymake/badge/?version=latest)](https://mfpymake.readthedocs.io/en/latest/?badge=latest)

This is a python package for compiling MODFLOW-based and other Fortran, C, and
Expand Down Expand Up @@ -58,18 +58,12 @@ The help message identifies required positional arguments and optional
arguments that can be provided to overide default values.

```
usage: __main__.py [-h] [-fc {ifort,mpiifort,gfortran,none}]
[-cc {gcc,clang,clang++,icc,icl,mpiicc,g++,cl,none}]
[-ar {ia32,ia32_intel64,intel64}] [-mc] [-dbl] [-dbg] [-e]
[-dr] [-sd] [-ff FFLAGS] [-cf CFLAGS] [-sl {-lc,-lm}] [-mf]
[-cs COMMONSRC] [-ef EXTRAFILES] [-exf EXCLUDEFILES] [-so]
[-ad APPDIR] [-v] [--keep] [--zip ZIP] [--inplace]
srcdir target
usage: __main__.py [-h] [-fc {ifort,mpiifort,gfortran,none}] [-cc {gcc,clang,clang++,icc,icl,mpiicc,g++,cl,none}] [-ar {ia32,ia32_intel64,intel64}] [-mc] [-dbl] [-dbg] [-e] [-dr] [-sd] [-ff FFLAGS]
[-cf CFLAGS] [-sl {-lc,-lm}] [-mf] [-cs COMMONSRC] [-ef EXTRAFILES] [-exf EXCLUDEFILES] [-so] [-ad APPDIR] [-v] [--keep] [--zip ZIP] [--inplace] [--networkx]
srcdir target
This is the pymake program for compiling fortran, c, and c++ source files,
such as the source files that come with MODFLOW. The program works by building
a directed acyclic graph of the module dependencies and then compiling the
source files in the proper order.
This is the pymake program for compiling fortran, c, and c++ source files, such as the source files that come with MODFLOW. The program works by building a directed acyclic graph of the module
dependencies and then compiling the source files in the proper order.
positional arguments:
srcdir Path source directory.
Expand All @@ -82,64 +76,42 @@ optional arguments:
-cc {gcc,clang,clang++,icc,icl,mpiicc,g++,cl,none}
C/C++ compiler to use. (default is gcc)
-ar {ia32,ia32_intel64,intel64}, --arch {ia32,ia32_intel64,intel64}
Architecture to use for Intel and Microsoft compilers
on Windows. (default is intel64)
-mc, --makeclean Clean temporary object, module, and source files when
done. (default is False)
Architecture to use for Intel and Microsoft compilers on Windows. (default is intel64)
-mc, --makeclean Clean temporary object, module, and source files when done. (default is False)
-dbl, --double Force double precision. (default is False)
-dbg, --debug Create debug version. (default is False)
-e, --expedite Only compile out of date source files. Clean must not
have been used on previous build. (default is False)
-dr, --dryrun Do not actually compile. Files will be deleted, if
--makeclean is used. Does not work yet for ifort.
(default is False)
-sd, --subdirs Include source files in srcdir subdirectories.
(default is None)
-e, --expedite Only compile out of date source files. Clean must not have been used on previous build. (default is False)
-dr, --dryrun Do not actually compile. Files will be deleted, if --makeclean is used. Does not work yet for ifort. (default is False)
-sd, --subdirs Include source files in srcdir subdirectories. (default is None)
-ff FFLAGS, --fflags FFLAGS
Additional Fortran compiler flags. Fortran compiler
flags should be enclosed in quotes and start with a
blank space or separated from the name (-ff or
--fflags) with a equal sign (-ff='-O3'). (default is
None)
Additional Fortran compiler flags. Fortran compiler flags should be enclosed in quotes and start with a blank space or separated from the name (-ff or --fflags) with a equal
sign (-ff='-O3'). (default is None)
-cf CFLAGS, --cflags CFLAGS
Additional C/C++ compiler flags. C/C++ compiler flags
should be enclosed in quotes and start with a blank
space or separated from the name (-cf or --cflags)
with a equal sign (-cf='-O3'). (default is None)
Additional C/C++ compiler flags. C/C++ compiler flags should be enclosed in quotes and start with a blank space or separated from the name (-cf or --cflags) with a equal sign
(-cf='-O3'). (default is None)
-sl {-lc,-lm}, --syslibs {-lc,-lm}
Linker system libraries. Linker libraries should be
enclosed in quotes and start with a blank space or
separated from the name (-sl or --syslibs) with a
equal sign (-sl='-libgcc'). (default is None)
Linker system libraries. Linker libraries should be enclosed in quotes and start with a blank space or separated from the name (-sl or --syslibs) with a equal sign
(-sl='-libgcc'). (default is None)
-mf, --makefile Create a GNU make makefile. (default is False)
-cs COMMONSRC, --commonsrc COMMONSRC
Additional directory with common source files.
(default is None)
Additional directory with common source files. (default is None)
-ef EXTRAFILES, --extrafiles EXTRAFILES
List of extra source files to include in the
compilation. extrafiles can be either a list of files
or the name of a text file that contains a list of
files. (default is None)
List of extra source files to include in the compilation. extrafiles can be either a list of files or the name of a text file that contains a list of files. (default is None)
-exf EXCLUDEFILES, --excludefiles EXCLUDEFILES
List of extra source files to exclude from the
compilation. excludefiles can be either a list of
files or the name of a text file that contains a list
of files. (default is None)
-so, --sharedobject Create shared object or dll on Windows. (default is
False)
List of extra source files to exclude from the compilation. excludefiles can be either a list of files or the name of a text file that contains a list of files. (default is
None)
-so, --sharedobject Create shared object or dll on Windows. (default is False)
-ad APPDIR, --appdir APPDIR
Target path that overides path defined target path
(default is None)
Target path that overides path defined target path (default is None)
-v, --verbose Verbose output to terminal. (default is False)
--keep Keep existing executable. (default is False)
--zip ZIP Zip built executable. (default is False)
--inplace Source files in srcdir are used directly. (default is
False)
--inplace Source files in srcdir are used directly. (default is False)
--networkx Use networkx package to build Directed Acyclic Graph use to determine the order source files are compiled in. (default is False)
Note that the source directory should not contain any bad or duplicate source files as all source files in the source directory, the common source file directory (srcdir2), and the extra files
(extrafiles) will be built and linked. Files can be excluded by using the excludefiles command line switch.
Note that the source directory should not contain any bad or duplicate source
files as all source files in the source directory, the common source file
directory (srcdir2), and the extra files (extrafiles) will be built and
linked. Files can be excluded by using the excludefiles command line switch.
```

Note that command line arguments for Fortran flags, C/C++ flags, and syslib
Expand Down Expand Up @@ -200,22 +172,22 @@ downloaded from
and set all of the pymake settings required to build the program. Available
example scripts include:

* make_modflow6.py
* make_mf2005.py
* make_mfnwt.py
* make_mfusg.py
* make_mflgr.py
* make_mf2000.py
* make_modpath6.py
* make_modpath7.py
* make_gsflow.py
* make_vs2dt.py
* make_mt3d.py
* make_mt3dusgs.py
* make_swtv4.py
* make_crt.py
* make_gridgen.py
* make_triangle.py
* `make_modflow6.py`
* `make_mf2005.py`
* `make_mfnwt.py`
* `make_mfusg.py`
* `make_mflgr.py`
* `make_mf2000.py`
* `make_modpath6.py`
* `make_modpath7.py`
* `make_gsflow.py`
* `make_vs2dt.py`
* `make_mt3d.py`
* `make_mt3dusgs.py`
* `make_swtv4.py`
* `make_crt.py`
* `make_gridgen.py`
* `make_triangle.py`

Optional command line arguments can be used to customize the build (`-fc`,
`-cc`, `--fflags`, etc.). MODFLOW 6 could be built using intel compilers and
Expand All @@ -228,6 +200,12 @@ python make_mf6.py -fc=ifort --fflags='-O3'

## Installation

To install pymake using pip type:

```
pip install mfpymake
```

To install pymake directly from the git repository type:

```
Expand Down
1 change: 1 addition & 0 deletions autotest/t008_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
pm.appdir = dstpth
pm.makefile = True
pm.inplace = True
pm.networkx = True


def build_with_makefile():
Expand Down
1 change: 1 addition & 0 deletions autotest/t009_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def test_download_exes():

@pytest.mark.regression
@pytest.mark.skipif(sys.platform == "darwin", reason="do not run on OSX")
@pytest.mark.skipif(sys.platform == "win32", reason="do not run on OSX")
@pytest.mark.parametrize("ws", sim_dirs)
def test_mt3dusgs(ws):
assert run_mt3dusgs(ws), "could not run {}".format(ws)
Expand Down
9 changes: 9 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
coverage:
precision: 3
round: down
range: "50...100"
status:
project: off
patch: off
comment:
layout: "diff, files"
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
# -- Project information -----------------------------------------------------

project = "pymake"
copyright = u"2020, Joseph D. Hughes"
author = u"Joseph D. Hughes"
copyright = "2020, Joseph D. Hughes"
author = "Joseph D. Hughes"

# The version.
version = __version__
Expand Down
Loading

0 comments on commit 5b8d6bd

Please sign in to comment.