251 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format( |
251 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format( |
252 sys.exec_prefix, pydir, wfile) |
252 sys.exec_prefix, pydir, wfile) |
253 |
253 |
254 # Mac OS X |
254 # Mac OS X |
255 elif sys.platform == "darwin": |
255 elif sys.platform == "darwin": |
|
256 # TODO: change this to respect the Python version install is executed with |
256 pyexec = "{0}/bin/pythonw3".format(sys.exec_prefix) |
257 pyexec = "{0}/bin/pythonw3".format(sys.exec_prefix) |
257 if not os.path.exists(pyexec): |
258 if not os.path.exists(pyexec): |
258 pyexec = "{0}/bin/python3".format(sys.exec_prefix) |
259 pyexec = "{0}/bin/python3".format(sys.exec_prefix) |
259 wname = wfile |
260 wname = wfile |
260 wrapper = ('''#!/bin/sh\n''' |
261 wrapper = ('''#!/bin/sh\n''' |
336 """ |
337 """ |
337 ''' |
338 ''' |
338 ) |
339 ) |
339 f.close() |
340 f.close() |
340 os.chmod(fname, 0o644) |
341 os.chmod(fname, 0o644) |
|
342 |
|
343 |
|
344 def cleanupSource(dirName): |
|
345 """ |
|
346 Cleanup the sources directory to get rid of leftover files |
|
347 and directories. |
|
348 |
|
349 @param dirName name of the directory to prune (string) |
|
350 """ |
|
351 # step 1: delete all Ui_*.py files without a corresponding |
|
352 # *.ui file |
|
353 dirListing = os.listdir(dirName) |
|
354 for formName, sourceName in [(f.replace('Ui_',"").replace(".py",".ui"), f) |
|
355 for f in dirListing |
|
356 if fnmatch.fnmatch(f, "Ui_*.py")]: |
|
357 if not os.path.exist(os.path.join(dirName, formName)): |
|
358 os.remove(os.path.join(dirName, sourceName)) |
|
359 if os.path.exist(os.path.join(dirName, sourceName + "c")): |
|
360 os.remove(os.path.join(dirName, sourceName + "c")) |
|
361 |
|
362 # step 2: delete the __pycache__ directory |
|
363 if os.path.exist(os.path.join(dirName, "__pycache__")): |
|
364 shutil.rmtree(os.path.join(dirName, "__pycache__")) |
|
365 |
|
366 # step 3: descent into subdirectories and delete them if empty |
|
367 for name in os.listdir(dirName): |
|
368 name = os.path.join(dirName, name) |
|
369 if os.path.isdir(name): |
|
370 cleanupSource(name) |
|
371 if len(os.listdir(name)) == 0: |
|
372 os.rmdir(name) |
341 |
373 |
342 |
374 |
343 def cleanUp(): |
375 def cleanUp(): |
344 """ |
376 """ |
345 Uninstall the old eric files. |
377 Uninstall the old eric files. |
1185 os.remove(configNameC) |
1217 os.remove(configNameC) |
1186 os.remove(configName) |
1218 os.remove(configName) |
1187 except EnvironmentError: |
1219 except EnvironmentError: |
1188 pass |
1220 pass |
1189 |
1221 |
|
1222 # cleanup source if installing from source |
|
1223 if installFromSource: |
|
1224 print("Cleaning up source ...") |
|
1225 cleanupSource(sourceDir) |
|
1226 |
1190 # cleanup old installation |
1227 # cleanup old installation |
1191 print("Cleaning up old installation ...") |
1228 print("Cleaning up old installation ...") |
1192 try: |
1229 try: |
1193 if doCleanup: |
1230 if doCleanup: |
1194 if distDir: |
1231 if distDir: |