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
592eb6da
Commit
592eb6da
authored
14 years ago
by
Piotr Ożarowski
Browse files
Options
Downloads
Patches
Plain Diff
pycompile: do not exit before all background byte compilation is finished
(closes: 590224)
parent
13a07ea7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
debian/changelog
+2
-0
2 additions, 0 deletions
debian/changelog
debpython/depends.py
+1
-1
1 addition, 1 deletion
debpython/depends.py
pyclean
+7
-15
7 additions, 15 deletions
pyclean
pycompile
+15
-10
15 additions, 10 deletions
pycompile
with
25 additions
and
26 deletions
debian/changelog
+
2
−
0
View file @
592eb6da
...
...
@@ -4,6 +4,8 @@ python-defaults (2.6.5-10) UNRELEASED; urgency=low
- add --depend command line option (use it if requires.txt
doesn't contain dependency that package needs)
- add {/usr,}/sbin to the list of directories with checked shebangs
* pycompile: do not exit before all background byte compilation is finished
(closes: 590224)
-- Piotr Ożarowski <piotr@debian.org> Wed, 21 Jul 2010 21:10:19 +0200
...
...
This diff is collapsed.
Click to expand it.
debpython/depends.py
+
1
−
1
View file @
592eb6da
...
...
@@ -119,7 +119,7 @@ class Dependencies(object):
# make sure pycompile binary is available
if
stats
[
'
compile
'
]:
self
.
depend
(
"
python (>= 2.6.5-
9
~)
"
)
self
.
depend
(
"
python (>= 2.6.5-
10
~)
"
)
for
interpreter
,
version
in
stats
[
'
shebangs
'
]:
self
.
depend
(
interpreter
)
...
...
This diff is collapsed.
Click to expand it.
pyclean
+
7
−
15
View file @
592eb6da
...
...
@@ -33,7 +33,7 @@ from subprocess import Popen, PIPE
# initialize script
logging
.
basicConfig
(
format
=
'
%(levelname).1s: %(module)s:%(lineno)d:
'
'
%(message)s
'
)
log
=
logging
.
getLogger
(
'
pyclean
'
)
log
=
logging
.
getLogger
(
__name__
)
"""
TODO: move it to manpage
Examples:
...
...
@@ -43,12 +43,7 @@ Examples:
def
destroyer
():
# ;-)
"""
Removes every .py[co] file associated to received .py file.
:param magic_tags: if True, removes __pycache__ directories,
if None, removes .py[co] files (PEP 3147 mode turned off),
otherwise removes set of magic tags from __pycache__ directory
"""
"""
Removes every .py[co] file associated to received .py file.
"""
def
find_files_to_remove
(
pyfile
):
for
filename
in
(
"
%sc
"
%
pyfile
,
"
%so
"
%
pyfile
):
...
...
@@ -61,14 +56,14 @@ def destroyer(): # ;-)
pyfile
=
(
yield
)
for
filename
in
find_files_to_remove
(
pyfile
):
try
:
log
.
debug
(
'
removing %s
'
,
filename
)
remove
(
filename
)
counter
+=
1
except
(
IOError
,
OSError
),
e
:
log
.
error
(
'
cannot remove %s
'
,
filename
)
log
.
debug
(
e
)
except
GeneratorExit
:
if
counter
:
log
.
info
(
"
removed files: %s
"
,
counter
)
log
.
info
(
"
removed files: %s
"
,
counter
)
def
get_files
(
items
):
...
...
@@ -108,16 +103,13 @@ def main():
(
options
,
args
)
=
parser
.
parse_args
()
if
options
.
verbose
:
log
.
setLevel
(
logging
.
INFO
)
else
:
log
.
setLevel
(
logging
.
WARNING
)
if
environ
.
get
(
'
PYCLEAN_DEBUG
'
)
==
'
1
'
:
if
options
.
verbose
or
environ
.
get
(
'
PYCLEAN_DEBUG
'
)
==
'
1
'
:
log
.
setLevel
(
logging
.
DEBUG
)
log
.
debug
(
'
argv: %s
'
,
sys
.
argv
)
log
.
debug
(
'
options: %s
'
,
options
)
log
.
debug
(
'
args: %s
'
,
args
)
else
:
log
.
setLevel
(
logging
.
WARNING
)
d
=
destroyer
()
d
.
next
()
# initialize coroutine
...
...
This diff is collapsed.
Click to expand it.
pycompile
+
15
−
10
View file @
592eb6da
...
...
@@ -38,8 +38,9 @@ from debpython.tools import memoize
# initialize script
logging
.
basicConfig
(
format
=
'
%(levelname).1s: %(module)s:%(lineno)d:
'
'
%(message)s
'
)
log
=
logging
.
getLogger
(
'
pycompile
'
)
log
=
logging
.
getLogger
(
__name__
)
STDINS
=
{}
WORKERS
=
{}
"""
TODO: move it to manpage
Examples:
...
...
@@ -158,22 +159,24 @@ def filter_files(files, e_patterns, compile_versions):
### COMPILE ####################################################
def
py_compile
(
version
):
def
py_compile
(
version
,
workers
):
if
not
isinstance
(
version
,
basestring
):
version
=
vrepr
(
version
)
cmd
=
"
python%s -m py_compile -
"
%
version
stdin
=
Popen
(
cmd
,
bufsize
=
1
,
shell
=
True
,
stdin
=
PIPE
).
stdin
process
=
Popen
(
cmd
,
bufsize
=
1
,
shell
=
True
,
stdin
=
PIPE
)
workers
[
version
]
=
process
# keep the reference for .communicate()
stdin
=
process
.
stdin
while
True
:
filename
=
(
yield
)
stdin
.
write
(
filename
+
'
\n
'
)
def
compile
(
files
,
versions
,
e_patterns
=
None
):
global
STDINS
global
STDINS
,
WORKERS
# start Python interpreters that will handle byte compilation
for
version
in
versions
:
if
version
not
in
STDINS
:
coroutine
=
py_compile
(
version
)
coroutine
=
py_compile
(
version
,
WORKERS
)
coroutine
.
next
()
STDINS
[
version
]
=
coroutine
...
...
@@ -213,15 +216,13 @@ multiple times to build up a list of things to exclude.')
(
options
,
args
)
=
parser
.
parse_args
()
if
options
.
verbose
:
log
.
setLevel
(
logging
.
INFO
)
else
:
log
.
setLevel
(
logging
.
WARN
)
if
environ
.
get
(
'
PYCOMPILE_DEBUG
'
)
==
'
1
'
:
if
options
.
verbose
or
environ
.
get
(
'
PYCOMPILE_DEBUG
'
)
==
'
1
'
:
log
.
setLevel
(
logging
.
DEBUG
)
log
.
debug
(
'
argv: %s
'
,
sys
.
argv
)
log
.
debug
(
'
options: %s
'
,
options
)
log
.
debug
(
'
args: %s
'
,
args
)
else
:
log
.
setLevel
(
logging
.
WARN
)
if
options
.
regexpr
and
not
args
:
parser
.
error
(
'
--exclude option works with private directories
'
...
...
@@ -266,5 +267,9 @@ multiple times to build up a list of things to exclude.')
parser
.
print_usage
()
exit
(
1
)
# wait for all processes to finish
for
process
in
WORKERS
.
itervalues
():
process
.
communicate
()
if
__name__
==
'
__main__
'
:
main
()
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