Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/buildall.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
print('pymake is not installed...will not build executables')
pymake = None


def build_all():
if pymake is not None:
# build all of the applications
Expand All @@ -14,5 +15,6 @@ def build_all():
# build code json
pymake.usgs_program_data.export_json(current=True)


if __name__ == '__main__':
build_all()
2 changes: 1 addition & 1 deletion examples/make_triangle.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import pymake


def make_triangle():
pymake.build_apps('triangle')

Expand Down
9 changes: 4 additions & 5 deletions pymake/autotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def setup_comparison(namefile, dst, remove_existing=True):
action = dirs[idx]
else:
action = dirs[idx]
pth = root
break
if action is not None:
dst = os.path.join(dst, '{}'.format(action))
Expand Down Expand Up @@ -1287,7 +1286,7 @@ def compare_heads(namefile1, namefile2, precision='auto',
if idx == 0:
e = 'shape of exclusion data ({})'.format(exd.shape) + \
'can not be reshaped to the size of the ' + \
'head arrays ()'.format(h1.shape)
'head arrays ({})'.format(h1.shape)
assert h1.flatten().shape == exd.shape, e
exd = exd.reshape(h1.shape)
iexd = exd > 0
Expand Down Expand Up @@ -1502,7 +1501,7 @@ def compare_concs(namefile1, namefile2, precision='auto',
if difftol:
ee = 'Maximum concentration difference ({})'.format(
diffmax) + \
' -- {} tolerance exceeded at '.format(htol) + \
' -- {} tolerance exceeded at '.format(ctol) + \
'{} node location(s)'.format(indices[0].shape[0])
else:
ee = 'Maximum concentration difference ' + \
Expand Down Expand Up @@ -1594,8 +1593,8 @@ def compare_stages(namefile1=None, namefile2=None, files1=None, files2=None,
# confirm that there are two files to compare
if sfpth1 is None or sfpth2 is None:
print('spth1 or spth2 is None')
print('spth1: {}'.format(spth1))
print('spth2: {}'.format(spth2))
print('spth1: {}'.format(sfpth1))
print('spth2: {}'.format(sfpth2))
return False

if not os.path.isfile(sfpth1) or not os.path.isfile(sfpth2):
Expand Down
13 changes: 4 additions & 9 deletions pymake/build_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def get_function_names(module, select_name=None):
func = {}
for key, value in module.__dict__.items():
ladd = False
# if type(value) is types.FunctionType:
if isinstance(types.FunctionType, type(value)):
if isinstance(value, types.FunctionType):
if select_name is None:
ladd = True
else:
Expand Down Expand Up @@ -664,12 +663,12 @@ def build_program(target='mf2005', fc='gfortran', cc='gcc', makeclean=True,
exe_name = filename + 'dbl' + file_extension
if debug:
filename, file_extension = os.path.splitext(exe_name)
if filename.lower()[-1] is not 'd':
if filename.lower()[-1] != 'd':
exe_name = filename + 'd' + file_extension

if platform.system().lower() is 'windows':
if platform.system().lower() == 'windows':
filename, file_extension = os.path.splitext(exe_name)
if file_extension.lower() is not '.exe':
if file_extension.lower() != '.exe':
exe_name += '.exe'

# determine if the target should be built
Expand Down Expand Up @@ -968,10 +967,6 @@ def build_apps(targets=None):
print('elapsed download and compile time (hh:mm:ss.ms): ' +
'{}\n'.format(elapsed))

# write code.json
if len(code_dict) > 0:
fpth = os.path.join(bindir, 'code.json')

end_time = datetime.now()
elapsed = end_time - start_time
print('elapsed time (hh:mm:ss.ms): {}\n'.format(elapsed))
Expand Down
10 changes: 5 additions & 5 deletions pymake/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ def order_c_source_files(srcfiles):
if len(linelist) == 0:
continue
if linelist[0].upper() == '#INCLUDE':
modulename = linelist[1].replace('"', '').replace("'",
"").replace(
'<', '').replace('>', '').upper()
modulename = linelist[1].upper()
for cval in ['"', "'", '<', '>']:
modulename = modulename.replace(cval, '')
# add source file for this c(pp) file if it is the same
# as the include file without the extension
bn = os.path.basename(srcfile)
if os.path.splitext(modulename)[0] == os.path.splitext(bn)[
0].upper():
if os.path.splitext(modulename)[0] == \
os.path.splitext(bn)[0].upper():
module_dict[modulename] = srcfile
# add include file name
if modulename not in modulelist:
Expand Down
9 changes: 5 additions & 4 deletions pymake/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def download_and_unzip(url, pth='./', delete_zip=True, verify=True,
if fs > 0:
bfmt = '{:' + '{}'.format(lenfs) + ',d}'
sbfmt = '{:>' + '{}'.format(len(bfmt.format(int(fs)))) + 's} bytes'
print(' file size: {}'.format(sbfmt.format(bfmt.format(int(fs)))))
print(
' file size: {}'.format(sbfmt.format(bfmt.format(int(fs)))))
ds = 0
try:
req = requests.get(url, verify=verify, timeout=timeout)
Expand All @@ -79,8 +80,8 @@ def download_and_unzip(url, pth='./', delete_zip=True, verify=True,
ds += len(chunk)
msg = ' downloaded ' + \
sbfmt.format(bfmt.format(ds)) + \
' of ' + bfmt.format(int(fs)) + ' bytes'+ \
' ({:10.4%})'.format(float(ds)/float(fs))
' of ' + bfmt.format(int(fs)) + ' bytes' + \
' ({:10.4%})'.format(float(ds) / float(fs))
print(msg)
f.write(chunk)
success = True
Expand All @@ -93,7 +94,7 @@ def download_and_unzip(url, pth='./', delete_zip=True, verify=True,

# Unzip the file, and delete zip file if successful.
if 'zip' in os.path.basename(file_name) or \
'exe' in os.path.basename(file_name):
'exe' in os.path.basename(file_name):
z = MyZipFile(file_name)
try:
print('Extracting the zipfile...')
Expand Down
10 changes: 3 additions & 7 deletions pymake/pymake.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ def out_of_date(srcfile, objfile):
# determine if iso_c_binding is used so that correct
# gcc and clang compiler flags can be set
def get_iso_c(srcfiles):
use_iso_c = False
for srcfile in srcfiles:
try:
f = open(srcfile, 'rb')
Expand Down Expand Up @@ -515,8 +514,6 @@ def compile_with_gnu(srcfiles, target, fc, cc, objdir_temp, moddir_temp,
if os_macro is not None:
compileflags.append(os_macro)

objext = '.o'

# Split all tokens by spaces
for fflag in ' '.join(fflags).split():
if fflag not in compileflags:
Expand Down Expand Up @@ -989,7 +986,6 @@ def compile_with_ifort(srcfiles, target, fc, cc, objdir_temp, moddir_temp,
for cflag in ' '.join(cflagsu).split():
if cflag not in cflags:
cflags.append(cflag)
objext = '.obj'
batchfile = 'compile.bat'
if os.path.isfile(batchfile):
try:
Expand Down Expand Up @@ -1082,8 +1078,8 @@ def makebatch(batchfile, fc, cc, fflags, cflags, srcfiles, target, arch,
for switch in fflags:
cmd += switch + ' '
cmd += '-c' + ' '
cmd += '/module:{0}\ '.format(moddir_temp)
cmd += '/object:{0}\ '.format(objdir_temp)
cmd += '/module:{0}\\ '.format(moddir_temp)
cmd += '/object:{0}\\ '.format(objdir_temp)
cmd += srcfile
f.write('echo ' + os.path.basename(srcfile) + '\n')
f.write(cmd + '\n')
Expand All @@ -1095,7 +1091,7 @@ def makebatch(batchfile, fc, cc, fflags, cflags, srcfiles, target, arch,
cmd = fc + ' '
for switch in fflags:
cmd += switch + ' '
cmd += '-o' + ' ' + target + ' ' + objdir_temp + '\*.obj' + '\n'
cmd += '-o' + ' ' + target + ' ' + objdir_temp + '\\*.obj' + '\n'
f.write(cmd)
f.close()
return
Expand Down
5 changes: 5 additions & 0 deletions pymake/usgsprograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

import pymake

# write installation location for pymake
thisfilepath = os.path.dirname(os.path.abspath(__file__))
pymakepth = os.path.abspath(os.path.join(thisfilepath))
print('pymake is installed in {}'.format(pymakepth))


class dotdict(dict):
"""dot.notation access to dictionary attributes"""
Expand Down