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
b93f5215
Kaydet (Commit)
b93f5215
authored
Agu 18, 1998
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Support for freezing packages (Just).
üst
201f46de
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
12 deletions
+58
-12
py_resource.py
Mac/Lib/py_resource.py
+15
-5
macimport.c
Mac/Python/macimport.c
+32
-1
macgen_bin.py
Mac/Tools/macfreeze/macgen_bin.py
+5
-2
macgen_rsrc.py
Mac/Tools/macfreeze/macgen_rsrc.py
+6
-4
No files found.
Mac/Lib/py_resource.py
Dosyayı görüntüle @
b93f5215
...
...
@@ -28,9 +28,18 @@ def open(dst):
Res
.
UseResFile
(
output
)
return
output
def
writemodule
(
name
,
id
,
data
,
type
=
'PYC '
,
preload
=
0
):
def
writemodule
(
name
,
id
,
data
,
type
=
'PYC '
,
preload
=
0
,
ispackage
=
0
):
"""Write pyc code to a PYC resource with given name and id."""
# XXXX Check that it doesn't exist
# Normally, byte 4-7 are the time stamp, but that is not used
# for 'PYC ' resources. We abuse byte 4 as a flag to indicate
# that it is a package rather than an ordinary module.
# See also macimport.c. (jvr)
if
ispackage
:
data
=
data
[:
4
]
+
'
\377\0\0\0
'
+
data
[
8
:]
# flag resource as package
else
:
data
=
data
[:
4
]
+
'
\0\0\0\0
'
+
data
[
8
:]
# clear mod date field, used as package flag
res
=
Res
.
Resource
(
data
)
res
.
AddResource
(
type
,
id
,
name
)
if
preload
:
...
...
@@ -40,22 +49,23 @@ def writemodule(name, id, data, type='PYC ', preload=0):
res
.
WriteResource
()
res
.
ReleaseResource
()
def
frompycfile
(
file
,
name
=
None
,
preload
=
0
):
def
frompycfile
(
file
,
name
=
None
,
preload
=
0
,
ispackage
=
0
):
"""Copy one pyc file to the open resource file"""
if
name
==
None
:
d
,
name
=
os
.
path
.
split
(
file
)
name
=
name
[:
-
4
]
id
=
findfreeid
()
writemodule
(
name
,
id
,
__builtin__
.
open
(
file
,
'rb'
)
.
read
(),
preload
=
preload
)
data
=
__builtin__
.
open
(
file
,
'rb'
)
.
read
()
writemodule
(
name
,
id
,
data
,
preload
=
preload
,
ispackage
=
ispackage
)
return
id
,
name
def
frompyfile
(
file
,
name
=
None
,
preload
=
0
):
def
frompyfile
(
file
,
name
=
None
,
preload
=
0
,
ispackage
=
0
):
"""Compile python source file to pyc file and add to resource file"""
import
py_compile
py_compile
.
compile
(
file
)
file
=
file
+
'c'
return
frompycfile
(
file
,
name
,
preload
=
preload
)
return
frompycfile
(
file
,
name
,
preload
=
preload
,
ispackage
=
ispackage
)
# XXXX Note this is incorrect, it only handles one type and one file....
...
...
Mac/Python/macimport.c
Dosyayı görüntüle @
b93f5215
...
...
@@ -332,14 +332,45 @@ char *filename;
co
=
NULL
;
}
else
{
co
=
PyMarshal_ReadObjectFromString
((
*
h
)
+
8
,
size
-
8
);
/*
** Normally, byte 4-7 are the time stamp, but that is not used
** for 'PYC ' resources. We abuse byte 4 as a flag to indicate
** that it is a package rather than an ordinary module.
** See also py_resource.py. (jvr)
*/
if
((
*
h
)[
4
]
&
0xff
)
{
/* it's a package */
/* Set __path__ to the package name */
PyObject
*
d
,
*
s
;
int
err
;
m
=
PyImport_AddModule
(
module
);
if
(
m
==
NULL
)
{
co
=
NULL
;
goto
packageerror
;
}
d
=
PyModule_GetDict
(
m
);
s
=
PyString_InternFromString
(
module
);
if
(
s
==
NULL
)
{
co
=
NULL
;
goto
packageerror
;
}
err
=
PyDict_SetItemString
(
d
,
"__path__"
,
s
);
Py_DECREF
(
s
);
if
(
err
!=
0
)
{
co
=
NULL
;
goto
packageerror
;
}
}
}
}
packageerror
:
HUnlock
(
h
);
if
(
filerh
!=
-
1
)
CloseResFile
(
filerh
);
UseResFile
(
oldrh
);
if
(
co
)
{
m
=
PyImport_ExecCodeModule
(
module
,
co
);
m
=
PyImport_ExecCodeModule
Ex
(
module
,
co
,
"<pyc resource>"
);
Py_DECREF
(
co
);
}
else
{
m
=
NULL
;
...
...
Mac/Tools/macfreeze/macgen_bin.py
Dosyayı görüntüle @
b93f5215
...
...
@@ -128,10 +128,12 @@ def getfragname(path, dynamicfiles):
def
addpythonmodules
(
module_dict
):
# XXX should really use macgen_rsrc.generate(), this does the same, but skips __main__
items
=
module_dict
.
items
()
items
.
sort
()
for
name
,
module
in
items
:
if
module
.
gettype
()
!=
'module'
or
name
==
"__main__"
:
mtype
=
module
.
gettype
()
if
mtype
not
in
[
'module'
,
'package'
]
or
name
==
"__main__"
:
continue
location
=
module
.
__file__
...
...
@@ -143,7 +145,8 @@ def addpythonmodules(module_dict):
continue
print
'Adding module
%
s'
%
name
id
,
name
=
py_resource
.
frompyfile
(
location
,
name
,
preload
=
0
)
id
,
name
=
py_resource
.
frompyfile
(
location
,
name
,
preload
=
0
,
ispackage
=
mtype
==
'package'
)
def
Pstring
(
str
):
if
len
(
str
)
>
255
:
...
...
Mac/Tools/macfreeze/macgen_rsrc.py
Dosyayı görüntüle @
b93f5215
...
...
@@ -6,9 +6,10 @@ import sys
def
generate
(
output
,
module_dict
,
debug
=
0
,
preload
=
1
):
fsid
=
py_resource
.
create
(
output
)
for
name
,
module
in
module_dict
.
items
():
if
module
.
gettype
()
!=
'module'
:
mtype
=
module
.
gettype
()
if
mtype
not
in
[
'module'
,
'package'
]:
continue
location
=
module
.
__file__
...
...
@@ -19,10 +20,11 @@ def generate(output, module_dict, debug=0, preload=1):
print
'*** skipping'
,
location
continue
id
,
name
=
py_resource
.
frompyfile
(
location
,
name
,
preload
=
preload
)
id
,
name
=
py_resource
.
frompyfile
(
location
,
name
,
preload
=
preload
,
ispackage
=
mtype
==
'package'
)
if
debug
>
0
:
print
'PYC resource
%5
d
\t
%
s
\t
%
s'
%
(
id
,
name
,
location
)
Res
.
CloseResFile
(
fsid
)
def
warnings
(
module_dict
):
...
...
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