Skip to content

Commit fb8a819

Browse files
committed
cleaner setup.py
Avoid printing useless message on each import of magic
1 parent 9cab422 commit fb8a819

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

python/magic/setup.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,25 +99,27 @@ def buildLib(fileName,libName):
9999
t1 = os.stat(sos[-1]).st_mtime
100100
else: # in case the file does not exist t2 is set to t1
101101
t1 = t2
102+
102103
if len(sos) < 1 or t2 > t1:
103104

104105
if (sys.version_info.major == 3 and sys.version_info.minor < 12):
105-
print("Please wait: building %s using distutils..." %libName)
106+
print("Please wait: building {} using distutils...".format(libName))
106107
return_code = sp.call(['{}'.format(f2pycmd),
107108
'--fcompiler={}'.format(fcompiler),
108109
'--opt={}'.format(f90options),
109110
'-c', '-m',
110-
'%s' %libName,
111-
'fortranLib/%s' %fileName], stderr=sp.PIPE, stdout=sp.PIPE)
111+
'{}'.format(libName),
112+
'fortranLib/{}'.format(fileName)],
113+
stderr=sp.PIPE, stdout=sp.PIPE)
112114
else:
113-
print("Please wait: building %s using meson..." %libName)
115+
print("Please wait: building {} using meson...".format(libName))
114116
my_env = os.environ.copy()
115117
my_env["FFLAGS"]=f90options
116118
return_code = sp.call(['{}'.format(f2pycmd),
117119
'-c', '-m',
118-
'%s' %libName,
119-
'fortranLib/%s' %fileName,
120-
"--backend","meson"],
120+
'{}'.format(libName),
121+
'fortranLib/{}'.format(fileName),
122+
'--backend', 'meson'],
121123
env=my_env,
122124
stderr=sp.PIPE, stdout=sp.PIPE)
123125

@@ -135,9 +137,7 @@ def buildLib(fileName,libName):
135137

136138
for fileName,libName in zip(fortranFiles,sharedLibFiles):
137139
return_code = buildLib(fileName,libName)
138-
if return_code == 0:
139-
print("%s built successfully" %libName)
140-
else:
141-
print("Error in building %s" %libName)
140+
if return_code != 0:
141+
print("Error in building {}".format(libName))
142142

143143
os.chdir(startdir)

0 commit comments

Comments
 (0)