mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Change Windows test to do a complete job of removing .pyc/.pyo files
reachable from Lib/.
This commit is contained in:
parent
d2c1abe5ed
commit
6a9aec47b7
2 changed files with 25 additions and 4 deletions
24
PCbuild/rmpyc.py
Normal file
24
PCbuild/rmpyc.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Remove all the .pyc and .pyo files under ../Lib.
|
||||||
|
|
||||||
|
def deltree(root):
|
||||||
|
import os
|
||||||
|
def rm(path):
|
||||||
|
os.unlink(path)
|
||||||
|
npyc = npyo = 0
|
||||||
|
dirs = [root]
|
||||||
|
while dirs:
|
||||||
|
dir = dirs.pop()
|
||||||
|
for short in os.listdir(dir):
|
||||||
|
full = os.path.join(dir, short)
|
||||||
|
if os.path.isdir(full):
|
||||||
|
dirs.append(full)
|
||||||
|
elif short.endswith(".pyc"):
|
||||||
|
npyc += 1
|
||||||
|
rm(full)
|
||||||
|
elif short.endswith(".pyo"):
|
||||||
|
npyo += 1
|
||||||
|
rm(full)
|
||||||
|
return npyc, npyo
|
||||||
|
|
||||||
|
npyc, npyo = deltree("../Lib")
|
||||||
|
print npyc, ".pyc deleted,", npyo, ".pyo deleted"
|
|
@ -21,10 +21,7 @@
|
||||||
@if "%1"=="-d" goto Again
|
@if "%1"=="-d" goto Again
|
||||||
@if "%_qmode%"=="yes" goto Qmode
|
@if "%_qmode%"=="yes" goto Qmode
|
||||||
@echo Deleting .pyc/.pyo files ...
|
@echo Deleting .pyc/.pyo files ...
|
||||||
@del ..\Lib\*.pyc
|
@%_exe% rmpyc.py
|
||||||
@del ..\Lib\*.pyo
|
|
||||||
@del ..\Lib\test\*.pyc
|
|
||||||
@del ..\Lib\test\*.pyo
|
|
||||||
%_exe% %_dashO% ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9
|
%_exe% %_dashO% ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
@echo About to run again without deleting .pyc/.pyo first:
|
@echo About to run again without deleting .pyc/.pyo first:
|
||||||
@pause
|
@pause
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue