Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
650f1472
Kaydet (Commit)
650f1472
authored
Kas 20, 2010
tarafından
R. David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#10453: compileall now uses argparse instead of getopt, so -h works.
Patch by Michele Orrù.
üst
a78f74ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
78 deletions
+111
-78
compileall.py
Lib/compileall.py
+55
-77
test_compileall.py
Lib/test/test_compileall.py
+53
-1
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/compileall.py
Dosyayı görüntüle @
650f1472
...
@@ -153,90 +153,68 @@ def compile_path(skip_curdir=1, maxlevels=0, force=False, quiet=False,
...
@@ -153,90 +153,68 @@ def compile_path(skip_curdir=1, maxlevels=0, force=False, quiet=False,
legacy
=
legacy
)
legacy
=
legacy
)
return
success
return
success
def
expand_args
(
args
,
flist
):
"""read names in flist and append to args"""
expanded
=
args
[:]
if
flist
:
try
:
if
flist
==
'-'
:
fd
=
sys
.
stdin
else
:
fd
=
open
(
flist
)
while
1
:
line
=
fd
.
readline
()
if
not
line
:
break
expanded
.
append
(
line
[:
-
1
])
except
IOError
:
print
(
"Error reading file list
%
s"
%
flist
)
raise
return
expanded
def
main
():
def
main
():
"""Script main program."""
"""Script main program."""
import
getopt
import
argparse
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'lfqd:x:i:b'
)
parser
=
argparse
.
ArgumentParser
(
except
getopt
.
error
as
msg
:
description
=
'Utilities to support installing Python libraries.'
)
print
(
msg
)
parser
.
add_argument
(
'-l'
,
action
=
'store_const'
,
default
=
10
,
const
=
0
,
print
(
"usage: python compileall.py [-l] [-f] [-q] [-d destdir] "
dest
=
'maxlevels'
,
help
=
"don't recurse down"
)
"[-x regexp] [-i list] [directory|file ...]"
)
parser
.
add_argument
(
'-f'
,
action
=
'store_true'
,
dest
=
'force'
,
print
(
"-l: don't recurse down"
)
help
=
'force rebuild even if timestamps are up to date'
)
print
(
"-f: force rebuild even if timestamps are up-to-date"
)
parser
.
add_argument
(
'-q'
,
action
=
'store_true'
,
dest
=
'quiet'
,
print
(
"-q: quiet operation"
)
help
=
'quiet operation'
)
print
(
"-d destdir: purported directory name for error messages"
)
parser
.
add_argument
(
'-b'
,
action
=
'store_true'
,
dest
=
'legacy'
,
print
(
" if no directory arguments, -l sys.path is assumed"
)
help
=
'procude legacy byte-compiled file paths'
)
print
(
"-x regexp: skip files matching the regular expression regexp"
)
parser
.
add_argument
(
'-d'
,
metavar
=
'DESTDIR'
,
dest
=
'ddir'
,
default
=
None
,
print
(
" the regexp is searched for in the full path of the file"
)
help
=
(
'purported directory name for error messages; '
print
(
"-i list: expand list with its content "
'if no directory arguments, -l sys.path '
"(file and directory names)"
)
'is assumed.'
)
)
print
(
"-b: Produce legacy byte-compile file paths"
)
parser
.
add_argument
(
'-x'
,
metavar
=
'REGEXP'
,
dest
=
'rx'
,
default
=
None
,
sys
.
exit
(
2
)
help
=
(
'skip files matching the regular expression.
\n\t
'
maxlevels
=
10
'The regexp is searched for in the full path'
ddir
=
None
'of the file'
))
force
=
False
parser
.
add_argument
(
'-i'
,
metavar
=
'FILE'
,
dest
=
'flist'
,
quiet
=
False
help
=
'expand the list with the contenent of FILE.'
)
rx
=
None
parser
.
add_argument
(
'compile_dest'
,
metavar
=
'FILE|DIR'
,
nargs
=
'?'
)
flist
=
None
args
=
parser
.
parse_args
()
legacy
=
False
for
o
,
a
in
opts
:
if
(
args
.
ddir
and
args
.
compile_dest
!=
1
and
if
o
==
'-l'
:
maxlevels
=
0
not
os
.
path
.
isdir
(
args
.
compile_dest
)):
if
o
==
'-d'
:
ddir
=
a
raise
argparse
.
ArgumentError
(
"-d destdir require exactly one "
if
o
==
'-f'
:
force
=
True
"directory argument"
)
if
o
==
'-q'
:
quiet
=
True
if
args
.
rx
:
i
f
o
==
'-x'
:
i
mport
re
import
re
args
.
rx
=
re
.
compile
(
args
.
rx
)
rx
=
re
.
compile
(
a
)
if
o
==
'-i'
:
flist
=
a
# if flist is provided then load it
if
o
==
'-b'
:
legacy
=
True
compile_dests
=
[
args
.
compile_dest
]
if
ddir
:
if
args
.
flist
:
if
len
(
args
)
!=
1
and
not
os
.
path
.
isdir
(
args
[
0
])
:
with
open
(
args
.
flist
)
as
f
:
print
(
"-d destdir require exactly one directory argument"
)
files
=
f
.
read
()
.
split
(
)
sys
.
exit
(
2
)
compile_dests
.
extend
(
files
)
success
=
1
try
:
try
:
if
args
or
flist
:
if
compile_dests
:
try
:
for
dest
in
compile_dests
:
if
flist
:
if
os
.
path
.
isdir
(
dest
):
args
=
expand_args
(
args
,
flist
)
if
not
compile_dir
(
dest
,
args
.
maxlevels
,
args
.
ddir
,
except
IOError
:
args
.
force
,
args
.
rx
,
args
.
quiet
,
success
=
0
args
.
legacy
):
if
success
:
return
0
for
arg
in
args
:
else
:
if
os
.
path
.
isdir
(
arg
):
if
not
compile_file
(
dest
,
args
.
ddir
,
args
.
force
,
args
.
rx
,
if
not
compile_dir
(
arg
,
maxlevels
,
ddir
,
args
.
quiet
,
args
.
legacy
):
force
,
rx
,
quiet
,
legacy
):
return
0
success
=
0
else
:
if
not
compile_file
(
arg
,
ddir
,
force
,
rx
,
quiet
,
legacy
):
success
=
0
else
:
else
:
success
=
compile_path
(
legacy
=
legacy
)
return
compile_path
(
legacy
=
args
.
legacy
)
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
print
(
"
\n
[interrupt]"
)
print
(
"
\n
[interrupt]"
)
success
=
0
return
0
return
success
return
1
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
exit_status
=
int
(
not
main
())
exit_status
=
int
(
not
main
())
...
...
Lib/test/test_compileall.py
Dosyayı görüntüle @
650f1472
...
@@ -7,6 +7,7 @@ import shutil
...
@@ -7,6 +7,7 @@ import shutil
import
struct
import
struct
import
subprocess
import
subprocess
import
tempfile
import
tempfile
import
time
import
unittest
import
unittest
import
io
import
io
...
@@ -112,7 +113,7 @@ class EncodingTest(unittest.TestCase):
...
@@ -112,7 +113,7 @@ class EncodingTest(unittest.TestCase):
class
CommandLineTests
(
unittest
.
TestCase
):
class
CommandLineTests
(
unittest
.
TestCase
):
"""Test
some aspects of
compileall's CLI."""
"""Test compileall's CLI."""
def
setUp
(
self
):
def
setUp
(
self
):
self
.
addCleanup
(
self
.
_cleanup
)
self
.
addCleanup
(
self
.
_cleanup
)
...
@@ -184,6 +185,57 @@ class CommandLineTests(unittest.TestCase):
...
@@ -184,6 +185,57 @@ class CommandLineTests(unittest.TestCase):
self
.
assertTrue
(
os
.
path
.
exists
(
cachedir
))
self
.
assertTrue
(
os
.
path
.
exists
(
cachedir
))
self
.
assertFalse
(
os
.
path
.
exists
(
cachecachedir
))
self
.
assertFalse
(
os
.
path
.
exists
(
cachecachedir
))
def
test_force
(
self
):
retcode
=
subprocess
.
call
(
(
sys
.
executable
,
'-m'
,
'compileall'
,
'-q'
,
self
.
pkgdir
))
self
.
assertEqual
(
retcode
,
0
)
pycpath
=
imp
.
cache_from_source
(
os
.
path
.
join
(
self
.
pkgdir
,
'bar.py'
))
# set atime/mtime backward to avoid file timestamp resolution issues
os
.
utime
(
pycpath
,
(
time
.
time
()
-
60
,)
*
2
)
access
=
os
.
stat
(
pycpath
)
.
st_mtime
retcode
=
subprocess
.
call
(
(
sys
.
executable
,
'-m'
,
'compileall'
,
'-q'
,
'-f'
,
self
.
pkgdir
))
self
.
assertEqual
(
retcode
,
0
)
access2
=
os
.
stat
(
pycpath
)
.
st_mtime
self
.
assertNotEqual
(
access
,
access2
)
def
test_legacy
(
self
):
# create a new module
newpackage
=
os
.
path
.
join
(
self
.
pkgdir
,
'spam'
)
os
.
mkdir
(
newpackage
)
with
open
(
os
.
path
.
join
(
newpackage
,
'__init__.py'
),
'w'
):
pass
with
open
(
os
.
path
.
join
(
newpackage
,
'ham.py'
),
'w'
):
pass
sourcefile
=
os
.
path
.
join
(
newpackage
,
'ham.py'
)
retcode
=
subprocess
.
call
(
(
sys
.
executable
,
'-m'
,
'compileall'
,
'-q'
,
'-l'
,
self
.
pkgdir
))
self
.
assertEqual
(
retcode
,
0
)
self
.
assertFalse
(
os
.
path
.
exists
(
imp
.
cache_from_source
(
sourcefile
)))
retcode
=
subprocess
.
call
(
(
sys
.
executable
,
'-m'
,
'compileall'
,
'-q'
,
self
.
pkgdir
))
self
.
assertEqual
(
retcode
,
0
)
self
.
assertTrue
(
os
.
path
.
exists
(
imp
.
cache_from_source
(
sourcefile
)))
def
test_quiet
(
self
):
noise
=
subprocess
.
getoutput
(
'{} -m compileall {}'
.
format
(
sys
.
executable
,
self
.
pkgdir
))
quiet
=
subprocess
.
getoutput
((
'{} -m compileall {}'
.
format
(
sys
.
executable
,
self
.
pkgdir
)))
self
.
assertTrue
(
len
(
noise
)
>
len
(
quiet
))
def
test_regexp
(
self
):
retcode
=
subprocess
.
call
(
(
sys
.
executable
,
'-m'
,
'compileall'
,
'-q'
,
'-x'
,
'bar.*'
,
self
.
pkgdir
))
self
.
assertEqual
(
retcode
,
0
)
sourcefile
=
os
.
path
.
join
(
self
.
pkgdir
,
'bar.py'
)
self
.
assertFalse
(
os
.
path
.
exists
(
imp
.
cache_from_source
(
sourcefile
)))
sourcefile
=
os
.
path
.
join
(
self
.
pkgdir
,
'__init__.py'
)
self
.
assertTrue
(
os
.
path
.
exists
(
imp
.
cache_from_source
(
sourcefile
)))
def
test_main
():
def
test_main
():
support
.
run_unittest
(
support
.
run_unittest
(
...
...
Misc/NEWS
Dosyayı görüntüle @
650f1472
...
@@ -30,6 +30,9 @@ Core and Builtins
...
@@ -30,6 +30,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #10453: compileall now uses argparse instead of getopt, and thus
provides clean output when called with '-h'.
- Issue #8078: Add constants for higher baud rates in the termios module.
- Issue #8078: Add constants for higher baud rates in the termios module.
Patch by Rodolpho Eckhardt.
Patch by Rodolpho Eckhardt.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment