Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
912a14c0
Commit
912a14c0
authored
Mar 05, 1998
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reindented, removed tabs.
parent
1e07403b
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
320 additions
and
312 deletions
+320
-312
Tools/freeze/makefreeze.py
Tools/freeze/makefreeze.py
+37
-33
Tools/freeze/modulefinder.py
Tools/freeze/modulefinder.py
+283
-279
No files found.
Tools/freeze/makefreeze.py
View file @
912a14c0
...
...
@@ -10,52 +10,56 @@ header = """
static struct _frozen _PyImport_FrozenModules[] = {
"""
trailer
=
"""
\
{0, 0, 0} /* sentinel */
{0, 0, 0} /* sentinel */
};
int
main(argc, argv)
int argc;
char **argv;
int argc;
char **argv;
{
PyImport_FrozenModules = _PyImport_FrozenModules;
return Py_FrozenMain(argc, argv);
PyImport_FrozenModules = _PyImport_FrozenModules;
return Py_FrozenMain(argc, argv);
}
"""
def
makefreeze
(
outfp
,
dict
,
debug
=
0
):
done
=
[]
mods
=
dict
.
keys
()
mods
.
sort
()
for
mod
in
mods
:
m
=
dict
[
mod
]
mangled
=
string
.
join
(
string
.
split
(
mod
,
"."
),
"__"
)
if
m
.
__code__
:
if
debug
:
print
"freezing"
,
mod
,
"..."
str
=
marshal
.
dumps
(
m
.
__code__
)
size
=
len
(
str
)
if
m
.
__path__
:
# Indicate package by negative size
size
=
-
size
done
.
append
((
mod
,
mangled
,
size
))
writecode
(
outfp
,
mangled
,
str
)
if
debug
:
print
"generating table of frozen modules"
outfp
.
write
(
header
)
for
mod
,
mangled
,
size
in
done
:
outfp
.
write
(
'
\
t
{"%s", M_%s, %d},
\
n
'
%
(
mod
,
mangled
,
size
))
outfp
.
write
(
trailer
)
done
=
[]
mods
=
dict
.
keys
()
mods
.
sort
()
for
mod
in
mods
:
m
=
dict
[
mod
]
mangled
=
string
.
join
(
string
.
split
(
mod
,
"."
),
"__"
)
if
m
.
__code__
:
if
debug
:
print
"freezing"
,
mod
,
"..."
str
=
marshal
.
dumps
(
m
.
__code__
)
size
=
len
(
str
)
if
m
.
__path__
:
# Indicate package by negative size
size
=
-
size
done
.
append
((
mod
,
mangled
,
size
))
writecode
(
outfp
,
mangled
,
str
)
if
debug
:
print
"generating table of frozen modules"
outfp
.
write
(
header
)
for
mod
,
mangled
,
size
in
done
:
outfp
.
write
(
'
\
t
{"%s", M_%s, %d},
\
n
'
%
(
mod
,
mangled
,
size
))
outfp
.
write
(
trailer
)
# Write a C initializer for a module containing the frozen python code.
# The array is called M_<mod>.
def
writecode
(
outfp
,
mod
,
str
):
outfp
.
write
(
'static unsigned char M_%s[] = {'
%
mod
)
for
i
in
range
(
0
,
len
(
str
),
16
):
outfp
.
write
(
'
\
n
\
t
'
)
for
c
in
str
[
i
:
i
+
16
]:
outfp
.
write
(
'%d,'
%
ord
(
c
))
outfp
.
write
(
'
\
n
};
\
n
'
)
outfp
.
write
(
'static unsigned char M_%s[] = {'
%
mod
)
for
i
in
range
(
0
,
len
(
str
),
16
):
outfp
.
write
(
'
\
n
\
t
'
)
for
c
in
str
[
i
:
i
+
16
]:
outfp
.
write
(
'%d,'
%
ord
(
c
))
outfp
.
write
(
'
\
n
};
\
n
'
)
# Local Variables:
# indent-tabs-mode: nil
# End:
Tools/freeze/modulefinder.py
View file @
912a14c0
This diff is collapsed.
Click to expand it.
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