MCPcopy
hub / github.com/pyinstaller/pyinstaller / distclean

Function distclean

bootloader/waflib/Scripting.py:222–265  ·  view source on GitHub ↗

removes build folders and data

(ctx)

Source from the content-addressed store, hash-verified

220
221
222def distclean(ctx):
223 '''removes build folders and data'''
224 def remove_and_log(k, fun):
225 try:
226 fun(k)
227 except EnvironmentError as e:
228 if e.errno != errno.ENOENT:
229 Logs.warn('Could not remove %r', k)
230
231 if not Options.commands:
232 for k in os.listdir('.'):
233 for x in '.waf-2 waf-2 .waf3-2 waf3-2'.split():
234 if k.startswith(x):
235 remove_and_log(k, shutil.rmtree)
236 cur = '.'
237 if os.environ.get('NO_LOCK_IN_TOP') or ctx.options.no_lock_in_top:
238 cur = ctx.options.out
239 try:
240 lst = os.listdir(cur)
241 except OSError:
242 Logs.warn('Could not read %r', cur)
243 return
244 if Options.lockfile in lst:
245 f = os.path.join(cur, Options.lockfile)
246 try:
247 env = ConfigSet.ConfigSet(f)
248 except EnvironmentError:
249 Logs.warn('Could not read %r', f)
250 return
251 if not env.out_dir or not env.top_dir:
252 Logs.warn('Invalid lock file %r', f)
253 return
254 if env.out_dir == env.top_dir:
255 distclean_dir(env.out_dir)
256 else:
257 remove_and_log(env.out_dir, shutil.rmtree)
258 env_dirs = [env.out_dir]
259 if not (os.environ.get('NO_LOCK_IN_TOP') or ctx.options.no_lock_in_top):
260 env_dirs.append(env.top_dir)
261 if not (os.environ.get('NO_LOCK_IN_RUN') or ctx.options.no_lock_in_run):
262 env_dirs.append(env.run_dir)
263 for k in env_dirs:
264 p = os.path.join(k, Options.lockfile)
265 remove_and_log(p, os.remove)
266
267
268class Dist(Context.Context):

Callers

nothing calls this directly

Calls 4

remove_and_logFunction · 0.85
distclean_dirFunction · 0.85
listdirMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…