Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
python-defaults
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pkg
python-defaults
Commits
d02912b5
Commit
d02912b5
authored
14 years ago
by
Matthias Klose
Browse files
Options
Downloads
Patches
Plain Diff
- Use the correct python interpreter when called with -O.
- Add options -l/--lazy, -O.
parent
d72d9624
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
debian/changelog
+2
-1
2 additions, 1 deletion
debian/changelog
pycompile
+23
-8
23 additions, 8 deletions
pycompile
pycompile.1
+7
-0
7 additions, 0 deletions
pycompile.1
with
32 additions
and
9 deletions
debian/changelog
+
2
−
1
View file @
d02912b5
...
@@ -3,7 +3,8 @@ python-defaults (2.6.6-7) experimental; urgency=high
...
@@ -3,7 +3,8 @@ python-defaults (2.6.6-7) experimental; urgency=high
* pycompile:
* pycompile:
- Don't over-optimize, check the timestamps of byte-code files.
- Don't over-optimize, check the timestamps of byte-code files.
- Use the correct name for byte-code files.
- Use the correct name for byte-code files.
- Add an option -f/--force.
- Use the correct python interpreter when called with -O.
- Add options -f/--force, -l/--lazy, -O.
- Copy stdout/stderr of py_compile processes in case of error.
- Copy stdout/stderr of py_compile processes in case of error.
- Propagate the exit value of the py_compile processes.
- Propagate the exit value of the py_compile processes.
- Update manual page.
- Update manual page.
...
...
This diff is collapsed.
Click to expand it.
pycompile
+
23
−
8
View file @
d02912b5
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
# vim: et ts=4 sw=4
# vim: et ts=4 sw=4
# Copyright © 2010 Piotr Ożarowski <piotr@debian.org>
# Copyright © 2010 Piotr Ożarowski <piotr@debian.org>
# Copyright © 2010 Canonical Ltd
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# of this software and associated documentation files (the "Software"), to deal
...
@@ -165,10 +166,11 @@ def filter_files(files, e_patterns, compile_versions):
...
@@ -165,10 +166,11 @@ def filter_files(files, e_patterns, compile_versions):
### COMPILE ####################################################
### COMPILE ####################################################
def
py_compile
(
version
,
workers
):
def
py_compile
(
version
,
optimize
,
workers
):
if
not
isinstance
(
version
,
basestring
):
if
not
isinstance
(
version
,
basestring
):
version
=
vrepr
(
version
)
version
=
vrepr
(
version
)
cmd
=
"
python%s -m py_compile -
"
%
version
cmd
=
"
python%s%s -m py_compile -
"
\
%
(
version
,
(
__debug__
or
optimize
)
and
''
or
'
-O
'
)
process
=
Popen
(
cmd
,
bufsize
=
1
,
shell
=
True
,
process
=
Popen
(
cmd
,
bufsize
=
1
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
stderr
=
STDOUT
,
close_fds
=
True
)
stdin
=
PIPE
,
stdout
=
PIPE
,
stderr
=
STDOUT
,
close_fds
=
True
)
workers
[
version
]
=
process
# keep the reference for .communicate()
workers
[
version
]
=
process
# keep the reference for .communicate()
...
@@ -178,19 +180,21 @@ def py_compile(version, workers):
...
@@ -178,19 +180,21 @@ def py_compile(version, workers):
stdin
.
write
(
filename
+
'
\n
'
)
stdin
.
write
(
filename
+
'
\n
'
)
def
compile
(
files
,
versions
,
force
,
e_patterns
=
None
):
def
compile
(
files
,
versions
,
force
,
lazy
,
optimize
,
e_patterns
=
None
):
global
STDINS
,
WORKERS
global
STDINS
,
WORKERS
# start Python interpreters that will handle byte compilation
# start Python interpreters that will handle byte compilation
for
version
in
versions
:
for
version
in
versions
:
if
version
not
in
STDINS
:
if
version
not
in
STDINS
:
coroutine
=
py_compile
(
version
,
WORKERS
)
coroutine
=
py_compile
(
version
,
optimize
,
WORKERS
)
coroutine
.
next
()
coroutine
.
next
()
STDINS
[
version
]
=
coroutine
STDINS
[
version
]
=
coroutine
# byte compile files
# byte compile files
for
fn
,
versions_to_compile
in
filter_files
(
files
,
e_patterns
,
versions
):
for
fn
,
versions_to_compile
in
filter_files
(
files
,
e_patterns
,
versions
):
cfn
=
fn
+
((
__debug__
or
optimize
)
and
'
c
'
or
'
o
'
)
if
lazy
and
exists
(
cfn
):
continue
if
not
force
:
if
not
force
:
cfn
=
fn
+
(
__debug__
and
'
c
'
or
'
o
'
)
ftime
=
os
.
stat
(
fn
).
st_mtime
ftime
=
os
.
stat
(
fn
).
st_mtime
try
:
try
:
ctime
=
os
.
stat
(
cfn
).
st_mtime
ctime
=
os
.
stat
(
cfn
).
st_mtime
...
@@ -221,6 +225,10 @@ def main():
...
@@ -221,6 +225,10 @@ def main():
default
=
False
,
help
=
'
be quiet
'
)
default
=
False
,
help
=
'
be quiet
'
)
parser
.
add_option
(
'
-f
'
,
'
--force
'
,
action
=
'
store_true
'
,
dest
=
'
force
'
,
parser
.
add_option
(
'
-f
'
,
'
--force
'
,
action
=
'
store_true
'
,
dest
=
'
force
'
,
default
=
False
,
help
=
'
force rebuild even if timestamps are up-to-date
'
)
default
=
False
,
help
=
'
force rebuild even if timestamps are up-to-date
'
)
parser
.
add_option
(
'
-l
'
,
'
--lazy
'
,
action
=
'
store_true
'
,
dest
=
'
lazy
'
,
default
=
False
,
help
=
"
don
'
t check if byte-code files are up-to-date
"
)
parser
.
add_option
(
'
-O
'
,
action
=
'
store_true
'
,
dest
=
'
optimize
'
,
default
=
False
,
help
=
"
byte-compile to .pyo files
"
)
parser
.
add_option
(
'
-p
'
,
'
--package
'
,
parser
.
add_option
(
'
-p
'
,
'
--package
'
,
help
=
'
specify Debian package name whose files should be bytecompiled
'
)
help
=
'
specify Debian package name whose files should be bytecompiled
'
)
parser
.
add_option
(
'
-V
'
,
type
=
'
version_range
'
,
dest
=
'
vrange
'
,
parser
.
add_option
(
'
-V
'
,
type
=
'
version_range
'
,
dest
=
'
vrange
'
,
...
@@ -246,6 +254,10 @@ multiple times to build up a list of things to exclude.')
...
@@ -246,6 +254,10 @@ multiple times to build up a list of things to exclude.')
else
:
else
:
log
.
setLevel
(
logging
.
WARN
)
log
.
setLevel
(
logging
.
WARN
)
if
options
.
force
and
options
.
lazy
:
options
.
lazy
=
False
log
.
warn
(
'
--force is in effect, ignore --lazy
'
)
if
options
.
regexpr
and
not
args
:
if
options
.
regexpr
and
not
args
:
parser
.
error
(
'
--exclude option works with private directories
'
parser
.
error
(
'
--exclude option works with private directories
'
'
only, please use /usr/share/python/bcep to specify
'
'
only, please use /usr/share/python/bcep to specify
'
...
@@ -277,20 +289,23 @@ multiple times to build up a list of things to exclude.')
...
@@ -277,20 +289,23 @@ multiple times to build up a list of things to exclude.')
log
.
debug
(
'
byte compiling %s using Python %s
'
,
log
.
debug
(
'
byte compiling %s using Python %s
'
,
item
,
compile_versions
)
item
,
compile_versions
)
files
=
get_private_files
(
pkg_files
,
item
)
files
=
get_private_files
(
pkg_files
,
item
)
compile
(
files
,
compile_versions
,
options
.
force
,
e_patterns
)
compile
(
files
,
compile_versions
,
options
.
force
,
options
.
lazy
,
options
.
optimize
,
e_patterns
)
elif
options
.
package
:
# package's public modules
elif
options
.
package
:
# package's public modules
# no need to limit versions here, it's either pyr mode or version is
# no need to limit versions here, it's either pyr mode or version is
# hardcoded in path / via -V option
# hardcoded in path / via -V option
e_patterns
=
get_exclude_patterns
()
e_patterns
=
get_exclude_patterns
()
files
=
get_package_files
(
options
.
package
)
files
=
get_package_files
(
options
.
package
)
files
=
get_public_files
(
files
,
versions
)
files
=
get_public_files
(
files
,
versions
)
compile
(
files
,
versions
,
options
.
force
,
e_patterns
)
compile
(
files
,
versions
,
options
.
force
,
options
.
lazy
,
options
.
optimize
,
e_patterns
)
elif
args
:
# other directories/files (public ones mostly)
elif
args
:
# other directories/files (public ones mostly)
versions
=
debsorted
(
versions
)[:
1
]
versions
=
debsorted
(
versions
)[:
1
]
for
item
in
args
:
for
item
in
args
:
e_patterns
=
get_exclude_patterns
(
item
,
options
.
regexpr
,
versions
)
e_patterns
=
get_exclude_patterns
(
item
,
options
.
regexpr
,
versions
)
files
=
get_directory_files
(
item
)
files
=
get_directory_files
(
item
)
compile
(
files
,
versions
,
options
.
force
,
e_patterns
)
compile
(
files
,
versions
,
options
.
force
,
options
.
lazy
,
options
.
optimize
,
e_patterns
)
else
:
else
:
parser
.
print_usage
()
parser
.
print_usage
()
exit
(
1
)
exit
(
1
)
...
...
This diff is collapsed.
Click to expand it.
pycompile.1
+
7
−
0
View file @
d02912b5
...
@@ -22,6 +22,13 @@ Show this help message and exit
...
@@ -22,6 +22,13 @@ Show this help message and exit
\fB\-f\fR, \fB\-\-force\fR
\fB\-f\fR, \fB\-\-force\fR
Force rebuild of byte-code files even if timestamps are up-to-date.
Force rebuild of byte-code files even if timestamps are up-to-date.
.TP
.TP
\fB\-l\fR, \fB\-\-lazy\fR
Do not rebuild byte-code files even if timestamps are out-of-date (ignored when
\fB\-\-force\fR is in effect).
.TP
\fB\-O\fR
Byte-compile to .pyo files.
.TP
\fB\-q\fR, \fB\-\-quiet\fR
\fB\-q\fR, \fB\-\-quiet\fR
Be quiet.
Be quiet.
.TP
.TP
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment