Skip to content

Commit

Permalink
release: version 1.2.4 (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhughes-usgs authored Mar 9, 2022
1 parent 353da75 commit 3c39b81
Show file tree
Hide file tree
Showing 20 changed files with 184 additions and 111 deletions.
3 changes: 1 addition & 2 deletions .github/common/install-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
python -m pip install --upgrade pip
pip install wheel
pip install pytest pytest-cov pytest-xdist coverage
pip install pydotplus appdirs
pip install matplotlib
pip install appdirs matplotlib
pip install https://github.com/modflowpy/flopy/zipball/develop
pip install .

33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

Python package for compiling MODFLOW-based programs.

### Version 1.2.2
### Version 1.2.4

![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://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)
[![PyPI Version](https://img.shields.io/pypi/v/mfpymake.png)](https://pypi.python.org/pypi/mfpymake)

This is a python package for compiling MODFLOW-based and other Fortran, C, and
C++ programs. The package determines the build order using a directed acyclic
graph and then compiles the source files using GNU compilers (`gcc`, `g++`,
`gfortran`) or Intel compilers (`ifort`, `icc`).
`gfortran`), Clang compilers (`clang`, `clang++`), Intel compilers (`ifort`,
`icl`, `icc`, `mpiifort`), or the CRAY Fortran compiler (`ftn`).

pymake can be run from the command line or it can be called from within python.
By default, pymake sets the optimization level, Fortran flags, C/C++ flags, and
Expand Down Expand Up @@ -59,20 +61,19 @@ 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] [-md] [-cs COMMONSRC] [-ef EXTRAFILES] [-exf EXCLUDEFILES] [-so] [-ad APPDIR] [-v] [--keep] [--zip ZIP] [--inplace] [--networkx] [--mb]
usage: __main__.py [-h] [-fc {ifort,mpiifort,gfortran,ftn,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] [-md] [-cs COMMONSRC] [-ef EXTRAFILES] [-exf EXCLUDEFILES] [-so]
[-ad APPDIR] [-v] [--keep] [--zip ZIP] [--inplace] [--networkx] [--mb] [-mbd]
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.
target Name of target to create. (can include path)
optional arguments:
-h, --help show this help message and exit
-fc {ifort,mpiifort,gfortran,none}
-fc {ifort,mpiifort,gfortran,ftn,none}
Fortran compiler to use. (default is gfortran)
-cc {gcc,clang,clang++,icc,icl,mpiicc,g++,cl,none}
C/C++ compiler to use. (default is gcc)
Expand All @@ -85,23 +86,19 @@ optional arguments:
-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)
-md, --makefile-dir GNU make makefile directory. (default is '.')
-cs COMMONSRC, --commonsrc COMMONSRC
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)
-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)
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)
Expand All @@ -111,9 +108,10 @@ optional arguments:
--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)
--mb, --meson-build Use meson to build executable. (default is False)
-mbd, --mesonbuild-dir
meson directory. (default is '.')
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 @@ -182,6 +180,7 @@ example scripts include:
* `make_mf2000.py`
* `make_modpath6.py`
* `make_modpath7.py`
* `make_prms.py`
* `make_gsflow.py`
* `make_vs2dt.py`
* `make_mt3d.py`
Expand Down
2 changes: 2 additions & 0 deletions autotest/ci_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
if not os.path.exists(temp_pth):
os.makedirs(temp_pth)
mf6_exdir = os.path.join(temp_pth, "mf6examples")
if os.path.isdir(mf6_exdir):
shutil.rmtree(mf6_exdir)


def download_mf6_examples(verbose=False):
Expand Down
49 changes: 36 additions & 13 deletions autotest/t008_test_existing_meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,29 @@

import pymake

target = "mf6"
ext = ""
shared_ext = ".so"
executables = [target, "zbud6", "mf5to6", "libmf6"]
if sys.platform.lower() == "win32":
ext = ".exe"
shared_ext = ".dll"
elif sys.platform.lower() == "darwin":
shared_ext = ".dylib"
for idx, executable in enumerate(executables[:3]):
executables[idx] += ext
executables[3] += shared_ext

# get program dictionary
prog_dict = pymake.usgs_program_data.get_target(target)

# set up paths
dstpth = os.path.join(f"temp_{os.path.basename(__file__).replace('.py', '')}")
if not os.path.exists(dstpth):
os.makedirs(dstpth, exist_ok=True)

mesondir = os.path.join(dstpth, "modflow6-develop")
mf6pth = os.path.join(dstpth, prog_dict.dirname)
mesondir = mf6pth


def clean_up():
Expand Down Expand Up @@ -58,27 +75,33 @@ def test_build_with_existing_meson():
# print fortran and c/c++ compilers
print(f"fortran compiler={fc}\n" + f"c/c++ compiler={cc}\n")

# download modflow6 github repo
url = (
"https://github.com/MODFLOW-USGS/"
+ "modflow6/archive/refs/heads/develop.zip"
)
success = pymake.download_and_unzip(
url,
pth=dstpth,
)
assert success, f"could not download modflow 6 from '{url}'"
pm = pymake.Pymake(verbose=True)
pm.target = target
pm.appdir = os.path.join(mesondir, "bin")
pm.meson = True
pm.makeclean = True
pm.mesondir = mesondir
pm.verbose = True

# download the modflow 6
pm.download_target(target, download_path=dstpth)
assert pm.download, f"could not download {target} distribution"

# make modflow 6 with existing meson.build file
returncode = pymake.meson_build(
mesondir,
fc,
cc,
appdir=os.path.join(mesondir, "bin"),
appdir=pm.appdir,
)
assert (
returncode == 0
), "could not build modflow 6 using existing meson.build file"
), "could not build modflow 6 applications using existing meson.build file"

# check that all of the executables exist
for executable in executables:
exe_pth = os.path.join(pm.appdir, executable)
assert os.path.isfile(exe_pth), f"{exe_pth} does not exist"

# clean up test files
clean_up()
Expand Down
16 changes: 0 additions & 16 deletions autotest/t015_test_meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,6 @@ def copy_example_dir(epth):
msg = f"could not move files from {src} to '{dst}'"
raise NameError(msg)

# # edit the control file for a shorter run
# # sagehen
# example, control_file = examples[0]
# if epth == example:
# fpth = os.path.join(dstpth, epth, "linux", control_file)
# with open(fpth) as f:
# lines = f.readlines()
# with open(fpth, "w") as f:
# idx = 0
# while idx < len(lines):
# line = lines[idx]
# if "end_time" in line:
# line += "6\n1\n1981\n"
# idx += 3
# f.write(line)
# idx += 1
return


Expand Down
29 changes: 20 additions & 9 deletions autotest/t999_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,17 @@ def test_previous_assets():


@pytest.mark.requests
def test_download_and_unzip_and_zip():
exclude_files = ["code.json"]
pth = os.path.join(f"temp_{os.path.basename(__file__).replace('.py', '')}")
def test_mfexes_download_and_unzip_and_zip():
exclude_files = [
"code.json",
"prms_constants.f90",
"prms_summary.f90",
"prms_time.f90",
"utils_prms.f90",
]
pth = os.path.join(
f"temp_mfexes_{os.path.basename(__file__).replace('.py', '')}"
)
pymake.getmfexes(pth, verbose=True)
for f in os.listdir(pth):
fpth = os.path.join(pth, f)
Expand All @@ -102,7 +110,7 @@ def test_download_and_unzip_and_zip():

# zip up exe's using files
zip_pth = os.path.join(
f"temp_{os.path.basename(__file__).replace('.py', '')}",
f"temp_mfexes_{os.path.basename(__file__).replace('.py', '')}",
"ziptest01.zip",
)
print(f"creating '{zip_pth}'")
Expand All @@ -114,7 +122,7 @@ def test_download_and_unzip_and_zip():

# zip up exe's using directories
zip_pth = os.path.join(
f"temp_{os.path.basename(__file__).replace('.py', '')}",
f"temp_mfexes_{os.path.basename(__file__).replace('.py', '')}",
"ziptest02.zip",
)
print(f"creating '{zip_pth}'")
Expand All @@ -124,7 +132,7 @@ def test_download_and_unzip_and_zip():

# zip up exe's using directories and a pattern
zip_pth = os.path.join(
f"temp_{os.path.basename(__file__).replace('.py', '')}",
f"temp_mfexes_{os.path.basename(__file__).replace('.py', '')}",
"ziptest03.zip",
)
print(f"creating '{zip_pth}'")
Expand All @@ -134,7 +142,7 @@ def test_download_and_unzip_and_zip():

# zip up exe's using files and directories
zip_pth = os.path.join(
f"temp_{os.path.basename(__file__).replace('.py', '')}",
f"temp_mfexes_{os.path.basename(__file__).replace('.py', '')}",
"ziptest04.zip",
)
print(f"creating '{zip_pth}'")
Expand Down Expand Up @@ -163,12 +171,15 @@ def test_download_and_unzip_and_zip():

@pytest.mark.requests
def test_nightly_download_and_unzip():
pth = os.path.join(f"temp_{os.path.basename(__file__).replace('.py', '')}")
exclude_files = ["code.json"]
pth = os.path.join(
f"temp_nightly_{os.path.basename(__file__).replace('.py', '')}"
)
pymake.getmfnightly(pth, verbose=True)
for f in os.listdir(pth):
fpth = os.path.join(pth, f)
print(f"downloaded: {fpth}")
if not os.path.isdir(fpth):
if not os.path.isdir(fpth) and f not in exclude_files:
errmsg = f"{fpth} not executable"
assert which(fpth) is not None, errmsg

Expand Down
26 changes: 11 additions & 15 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@ 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] [-md] [-cs COMMONSRC] [-ef EXTRAFILES] [-exf EXCLUDEFILES] [-so] [-ad APPDIR] [-v] [--keep] [--zip ZIP] [--inplace] [--networkx] [--mb]
usage: __main__.py [-h] [-fc {ifort,mpiifort,gfortran,ftn,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] [-md] [-cs COMMONSRC] [-ef EXTRAFILES] [-exf EXCLUDEFILES] [-so]
[-ad APPDIR] [-v] [--keep] [--zip ZIP] [--inplace] [--networkx] [--mb] [-mbd]
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.
target Name of target to create. (can include path)
optional arguments:
-h, --help show this help message and exit
-fc {ifort,mpiifort,gfortran,none}
-fc {ifort,mpiifort,gfortran,ftn,none}
Fortran compiler to use. (default is gfortran)
-cc {gcc,clang,clang++,icc,icl,mpiicc,g++,cl,none}
C/C++ compiler to use. (default is gcc)
Expand All @@ -48,23 +47,19 @@ optional arguments:
-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)
-md, --makefile-dir GNU make makefile directory. (default is '.')
-cs COMMONSRC, --commonsrc COMMONSRC
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)
-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)
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)
Expand All @@ -74,9 +69,10 @@ optional arguments:
--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)
--mb, --meson-build Use meson to build executable. (default is False)
-mbd, --mesonbuild-dir
meson directory. (default is '.')
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
4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
numpy
requests
networkx
meson
ninja
pydotplus
nbsphinx
nbsphinx_link
Ipython
Expand Down
Loading

0 comments on commit 3c39b81

Please sign in to comment.