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
8ff672e6
Kaydet (Commit)
8ff672e6
authored
May 23, 2006
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add missing svn:eol-style property to text files.
üst
211219af
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1013 additions
and
1013 deletions
+1013
-1013
build-installer.py
Mac/OSX/BuildScript/build-installer.py
+1013
-1013
No files found.
Mac/OSX/BuildScript/build-installer.py
Dosyayı görüntüle @
8ff672e6
#!/usr/bin/python2.3
#!/usr/bin/python2.3
"""
"""
This script is used to build the "official unofficial" universal build on
This script is used to build the "official unofficial" universal build on
Mac OS X. It requires Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK to do its
Mac OS X. It requires Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK to do its
work.
work.
Please ensure that this script keeps working with Python 2.3, to avoid
Please ensure that this script keeps working with Python 2.3, to avoid
bootstrap issues (/usr/bin/python is Python 2.3 on OSX 10.4)
bootstrap issues (/usr/bin/python is Python 2.3 on OSX 10.4)
Usage: see USAGE variable in the script.
Usage: see USAGE variable in the script.
"""
"""
import
platform
,
os
,
sys
,
getopt
,
textwrap
,
shutil
,
urllib2
,
stat
,
time
,
pwd
import
platform
,
os
,
sys
,
getopt
,
textwrap
,
shutil
,
urllib2
,
stat
,
time
,
pwd
INCLUDE_TIMESTAMP
=
1
INCLUDE_TIMESTAMP
=
1
VERBOSE
=
1
VERBOSE
=
1
from
plistlib
import
Plist
from
plistlib
import
Plist
import
MacOS
import
MacOS
import
Carbon.File
import
Carbon.File
import
Carbon.Icn
import
Carbon.Icn
import
Carbon.Res
import
Carbon.Res
from
Carbon.Files
import
kCustomIconResource
,
fsRdWrPerm
,
kHasCustomIcon
from
Carbon.Files
import
kCustomIconResource
,
fsRdWrPerm
,
kHasCustomIcon
from
Carbon.Files
import
kFSCatInfoFinderInfo
from
Carbon.Files
import
kFSCatInfoFinderInfo
try
:
try
:
from
plistlib
import
writePlist
from
plistlib
import
writePlist
except
ImportError
:
except
ImportError
:
# We're run using python2.3
# We're run using python2.3
def
writePlist
(
plist
,
path
):
def
writePlist
(
plist
,
path
):
plist
.
write
(
path
)
plist
.
write
(
path
)
def
shellQuote
(
value
):
def
shellQuote
(
value
):
"""
"""
Return the string value in a form that can savely be inserted into
Return the string value in a form that can savely be inserted into
a shell command.
a shell command.
"""
"""
return
"'
%
s'"
%
(
value
.
replace
(
"'"
,
"'
\"
'
\"
'"
))
return
"'
%
s'"
%
(
value
.
replace
(
"'"
,
"'
\"
'
\"
'"
))
def
grepValue
(
fn
,
variable
):
def
grepValue
(
fn
,
variable
):
variable
=
variable
+
'='
variable
=
variable
+
'='
for
ln
in
open
(
fn
,
'r'
):
for
ln
in
open
(
fn
,
'r'
):
if
ln
.
startswith
(
variable
):
if
ln
.
startswith
(
variable
):
value
=
ln
[
len
(
variable
):]
.
strip
()
value
=
ln
[
len
(
variable
):]
.
strip
()
return
value
[
1
:
-
1
]
return
value
[
1
:
-
1
]
def
getVersion
():
def
getVersion
():
return
grepValue
(
os
.
path
.
join
(
SRCDIR
,
'configure'
),
'PACKAGE_VERSION'
)
return
grepValue
(
os
.
path
.
join
(
SRCDIR
,
'configure'
),
'PACKAGE_VERSION'
)
def
getFullVersion
():
def
getFullVersion
():
fn
=
os
.
path
.
join
(
SRCDIR
,
'Include'
,
'patchlevel.h'
)
fn
=
os
.
path
.
join
(
SRCDIR
,
'Include'
,
'patchlevel.h'
)
for
ln
in
open
(
fn
):
for
ln
in
open
(
fn
):
if
'PY_VERSION'
in
ln
:
if
'PY_VERSION'
in
ln
:
return
ln
.
split
()[
-
1
][
1
:
-
1
]
return
ln
.
split
()[
-
1
][
1
:
-
1
]
raise
RuntimeError
,
"Cannot find full version??"
raise
RuntimeError
,
"Cannot find full version??"
# The directory we'll use to create the build, will be erased and recreated
# The directory we'll use to create the build, will be erased and recreated
WORKDIR
=
"/tmp/_py"
WORKDIR
=
"/tmp/_py"
# The directory we'll use to store third-party sources, set this to something
# The directory we'll use to store third-party sources, set this to something
# else if you don't want to re-fetch required libraries every time.
# else if you don't want to re-fetch required libraries every time.
DEPSRC
=
os
.
path
.
join
(
WORKDIR
,
'third-party'
)
DEPSRC
=
os
.
path
.
join
(
WORKDIR
,
'third-party'
)
DEPSRC
=
os
.
path
.
expanduser
(
'~/Universal/other-sources'
)
DEPSRC
=
os
.
path
.
expanduser
(
'~/Universal/other-sources'
)
# Location of the preferred SDK
# Location of the preferred SDK
SDKPATH
=
"/Developer/SDKs/MacOSX10.4u.sdk"
SDKPATH
=
"/Developer/SDKs/MacOSX10.4u.sdk"
#SDKPATH="/"
#SDKPATH="/"
# Source directory (asume we're in Mac/OSX/Dist)
# Source directory (asume we're in Mac/OSX/Dist)
SRCDIR
=
os
.
path
.
dirname
(
SRCDIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
os
.
path
.
abspath
(
__file__
)))))
)))))
USAGE
=
textwrap
.
dedent
(
"""
\
USAGE
=
textwrap
.
dedent
(
"""
\
Usage: build_python [options]
Usage: build_python [options]
Options:
Options:
-? or -h: Show this message
-? or -h: Show this message
-b DIR
-b DIR
--build-dir=DIR: Create build here (default:
%(WORKDIR)
r)
--build-dir=DIR: Create build here (default:
%(WORKDIR)
r)
--third-party=DIR: Store third-party sources here (default:
%(DEPSRC)
r)
--third-party=DIR: Store third-party sources here (default:
%(DEPSRC)
r)
--sdk-path=DIR: Location of the SDK (default:
%(SDKPATH)
r)
--sdk-path=DIR: Location of the SDK (default:
%(SDKPATH)
r)
--src-dir=DIR: Location of the Python sources (default:
%(SRCDIR)
r)
--src-dir=DIR: Location of the Python sources (default:
%(SRCDIR)
r)
"""
)
%
globals
()
"""
)
%
globals
()
# Instructions for building libraries that are necessary for building a
# Instructions for building libraries that are necessary for building a
# batteries included python.
# batteries included python.
LIBRARY_RECIPES
=
[
LIBRARY_RECIPES
=
[
dict
(
dict
(
# Note that GNU readline is GPL'd software
# Note that GNU readline is GPL'd software
name
=
"GNU Readline 5.1.4"
,
name
=
"GNU Readline 5.1.4"
,
url
=
"http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz"
,
url
=
"http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz"
,
patchlevel
=
'0'
,
patchlevel
=
'0'
,
patches
=
[
patches
=
[
# The readline maintainers don't do actual micro releases, but
# The readline maintainers don't do actual micro releases, but
# just ship a set of patches.
# just ship a set of patches.
'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-001'
,
'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-001'
,
'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-002'
,
'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-002'
,
'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-003'
,
'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-003'
,
'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-004'
,
'http://ftp.gnu.org/pub/gnu/readline/readline-5.1-patches/readline51-004'
,
]
]
),
),
dict
(
dict
(
name
=
"SQLite 3.3.5"
,
name
=
"SQLite 3.3.5"
,
url
=
"http://www.sqlite.org/sqlite-3.3.5.tar.gz"
,
url
=
"http://www.sqlite.org/sqlite-3.3.5.tar.gz"
,
checksum
=
'93f742986e8bc2dfa34792e16df017a6feccf3a2'
,
checksum
=
'93f742986e8bc2dfa34792e16df017a6feccf3a2'
,
configure_pre
=
[
configure_pre
=
[
'--enable-threadsafe'
,
'--enable-threadsafe'
,
'--enable-tempstore'
,
'--enable-tempstore'
,
'--enable-shared=no'
,
'--enable-shared=no'
,
'--enable-static=yes'
,
'--enable-static=yes'
,
'--disable-tcl'
,
'--disable-tcl'
,
]
]
),
),
dict
(
dict
(
name
=
"NCurses 5.5"
,
name
=
"NCurses 5.5"
,
url
=
"http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz"
,
url
=
"http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz"
,
configure_pre
=
[
configure_pre
=
[
"--without-cxx"
,
"--without-cxx"
,
"--without-ada"
,
"--without-ada"
,
"--without-progs"
,
"--without-progs"
,
"--without-curses-h"
,
"--without-curses-h"
,
"--enable-shared"
,
"--enable-shared"
,
"--with-shared"
,
"--with-shared"
,
"--datadir=/usr/share"
,
"--datadir=/usr/share"
,
"--sysconfdir=/etc"
,
"--sysconfdir=/etc"
,
"--sharedstatedir=/usr/com"
,
"--sharedstatedir=/usr/com"
,
"--with-terminfo-dirs=/usr/share/terminfo"
,
"--with-terminfo-dirs=/usr/share/terminfo"
,
"--with-default-terminfo-dir=/usr/share/terminfo"
,
"--with-default-terminfo-dir=/usr/share/terminfo"
,
"--libdir=/Library/Frameworks/Python.framework/Versions/
%
s/lib"
%
(
getVersion
(),),
"--libdir=/Library/Frameworks/Python.framework/Versions/
%
s/lib"
%
(
getVersion
(),),
"--enable-termcap"
,
"--enable-termcap"
,
],
],
patches
=
[
patches
=
[
"ncurses-5.5.patch"
,
"ncurses-5.5.patch"
,
],
],
useLDFlags
=
False
,
useLDFlags
=
False
,
install
=
'make && make install DESTDIR=
%
s && cd
%
s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/
%
s/lib/lib* .'
%
(
install
=
'make && make install DESTDIR=
%
s && cd
%
s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/
%
s/lib/lib* .'
%
(
shellQuote
(
os
.
path
.
join
(
WORKDIR
,
'libraries'
)),
shellQuote
(
os
.
path
.
join
(
WORKDIR
,
'libraries'
)),
shellQuote
(
os
.
path
.
join
(
WORKDIR
,
'libraries'
)),
shellQuote
(
os
.
path
.
join
(
WORKDIR
,
'libraries'
)),
getVersion
(),
getVersion
(),
),
),
),
),
dict
(
dict
(
name
=
"Sleepycat DB 4.4"
,
name
=
"Sleepycat DB 4.4"
,
url
=
"http://downloads.sleepycat.com/db-4.4.20.tar.gz"
,
url
=
"http://downloads.sleepycat.com/db-4.4.20.tar.gz"
,
#name="Sleepycat DB 4.3.29",
#name="Sleepycat DB 4.3.29",
#url="http://downloads.sleepycat.com/db-4.3.29.tar.gz",
#url="http://downloads.sleepycat.com/db-4.3.29.tar.gz",
buildDir
=
"build_unix"
,
buildDir
=
"build_unix"
,
configure
=
"../dist/configure"
,
configure
=
"../dist/configure"
,
configure_pre
=
[
configure_pre
=
[
'--includedir=/usr/local/include/db4'
,
'--includedir=/usr/local/include/db4'
,
]
]
),
),
]
]
# Instructions for building packages inside the .mpkg.
# Instructions for building packages inside the .mpkg.
PKG_RECIPES
=
[
PKG_RECIPES
=
[
dict
(
dict
(
name
=
"PythonFramework"
,
name
=
"PythonFramework"
,
long_name
=
"Python Framework"
,
long_name
=
"Python Framework"
,
source
=
"/Library/Frameworks/Python.framework"
,
source
=
"/Library/Frameworks/Python.framework"
,
readme
=
"""
\
readme
=
"""
\
This package installs Python.framework, that is the python
This package installs Python.framework, that is the python
interpreter and the standard library. This also includes Python
interpreter and the standard library. This also includes Python
wrappers for lots of Mac OS X API's.
wrappers for lots of Mac OS X API's.
"""
,
"""
,
postflight
=
"scripts/postflight.framework"
,
postflight
=
"scripts/postflight.framework"
,
),
),
dict
(
dict
(
name
=
"PythonApplications"
,
name
=
"PythonApplications"
,
long_name
=
"GUI Applications"
,
long_name
=
"GUI Applications"
,
source
=
"/Applications/MacPython
%(VER)
s"
,
source
=
"/Applications/MacPython
%(VER)
s"
,
readme
=
"""
\
readme
=
"""
\
This package installs Python.framework, that is the python
This package installs Python.framework, that is the python
interpreter and the standard library. This also includes Python
interpreter and the standard library. This also includes Python
wrappers for lots of Mac OS X API's.
wrappers for lots of Mac OS X API's.
"""
,
"""
,
required
=
False
,
required
=
False
,
),
),
dict
(
dict
(
name
=
"PythonUnixTools"
,
name
=
"PythonUnixTools"
,
long_name
=
"UNIX command-line tools"
,
long_name
=
"UNIX command-line tools"
,
source
=
"/usr/local/bin"
,
source
=
"/usr/local/bin"
,
readme
=
"""
\
readme
=
"""
\
This package installs the unix tools in /usr/local/bin for
This package installs the unix tools in /usr/local/bin for
compatibility with older releases of MacPython. This package
compatibility with older releases of MacPython. This package
is not necessary to use MacPython.
is not necessary to use MacPython.
"""
,
"""
,
required
=
False
,
required
=
False
,
),
),
dict
(
dict
(
name
=
"PythonDocumentation"
,
name
=
"PythonDocumentation"
,
long_name
=
"Python Documentation"
,
long_name
=
"Python Documentation"
,
topdir
=
"/Library/Frameworks/Python.framework/Versions/
%(VER)
s/Resources/English.lproj/Documentation"
,
topdir
=
"/Library/Frameworks/Python.framework/Versions/
%(VER)
s/Resources/English.lproj/Documentation"
,
source
=
"/pydocs"
,
source
=
"/pydocs"
,
readme
=
"""
\
readme
=
"""
\
This package installs the python documentation at a location
This package installs the python documentation at a location
that is useable for pydoc and IDLE. If you have installed Xcode
that is useable for pydoc and IDLE. If you have installed Xcode
it will also install a link to the documentation in
it will also install a link to the documentation in
/Developer/Documentation/Python
/Developer/Documentation/Python
"""
,
"""
,
postflight
=
"scripts/postflight.documentation"
,
postflight
=
"scripts/postflight.documentation"
,
required
=
False
,
required
=
False
,
),
),
dict
(
dict
(
name
=
"PythonProfileChanges"
,
name
=
"PythonProfileChanges"
,
long_name
=
"Shell profile updater"
,
long_name
=
"Shell profile updater"
,
readme
=
"""
\
readme
=
"""
\
This packages updates your shell profile to make sure that
This packages updates your shell profile to make sure that
the MacPython tools are found by your shell in preference of
the MacPython tools are found by your shell in preference of
the system provided Python tools.
the system provided Python tools.
If you don't install this package you'll have to add
If you don't install this package you'll have to add
"/Library/Frameworks/Python.framework/Versions/
%(VER)
s/bin"
"/Library/Frameworks/Python.framework/Versions/
%(VER)
s/bin"
to your PATH by hand.
to your PATH by hand.
"""
,
"""
,
postflight
=
"scripts/postflight.patch-profile"
,
postflight
=
"scripts/postflight.patch-profile"
,
topdir
=
"/Library/Frameworks/Python.framework"
,
topdir
=
"/Library/Frameworks/Python.framework"
,
source
=
"/empty-dir"
,
source
=
"/empty-dir"
,
required
=
False
,
required
=
False
,
),
),
]
]
def
fatal
(
msg
):
def
fatal
(
msg
):
"""
"""
A fatal error, bail out.
A fatal error, bail out.
"""
"""
sys
.
stderr
.
write
(
'FATAL: '
)
sys
.
stderr
.
write
(
'FATAL: '
)
sys
.
stderr
.
write
(
msg
)
sys
.
stderr
.
write
(
msg
)
sys
.
stderr
.
write
(
'
\n
'
)
sys
.
stderr
.
write
(
'
\n
'
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
def
fileContents
(
fn
):
def
fileContents
(
fn
):
"""
"""
Return the contents of the named file
Return the contents of the named file
"""
"""
return
open
(
fn
,
'rb'
)
.
read
()
return
open
(
fn
,
'rb'
)
.
read
()
def
runCommand
(
commandline
):
def
runCommand
(
commandline
):
"""
"""
Run a command and raise RuntimeError if it fails. Output is surpressed
Run a command and raise RuntimeError if it fails. Output is surpressed
unless the command fails.
unless the command fails.
"""
"""
fd
=
os
.
popen
(
commandline
,
'r'
)
fd
=
os
.
popen
(
commandline
,
'r'
)
data
=
fd
.
read
()
data
=
fd
.
read
()
xit
=
fd
.
close
()
xit
=
fd
.
close
()
if
xit
!=
None
:
if
xit
!=
None
:
sys
.
stdout
.
write
(
data
)
sys
.
stdout
.
write
(
data
)
raise
RuntimeError
,
"command failed:
%
s"
%
(
commandline
,)
raise
RuntimeError
,
"command failed:
%
s"
%
(
commandline
,)
if
VERBOSE
:
if
VERBOSE
:
sys
.
stdout
.
write
(
data
);
sys
.
stdout
.
flush
()
sys
.
stdout
.
write
(
data
);
sys
.
stdout
.
flush
()
def
captureCommand
(
commandline
):
def
captureCommand
(
commandline
):
fd
=
os
.
popen
(
commandline
,
'r'
)
fd
=
os
.
popen
(
commandline
,
'r'
)
data
=
fd
.
read
()
data
=
fd
.
read
()
xit
=
fd
.
close
()
xit
=
fd
.
close
()
if
xit
!=
None
:
if
xit
!=
None
:
sys
.
stdout
.
write
(
data
)
sys
.
stdout
.
write
(
data
)
raise
RuntimeError
,
"command failed:
%
s"
%
(
commandline
,)
raise
RuntimeError
,
"command failed:
%
s"
%
(
commandline
,)
return
data
return
data
def
checkEnvironment
():
def
checkEnvironment
():
"""
"""
Check that we're running on a supported system.
Check that we're running on a supported system.
"""
"""
if
platform
.
system
()
!=
'Darwin'
:
if
platform
.
system
()
!=
'Darwin'
:
fatal
(
"This script should be run on a Mac OS X 10.4 system"
)
fatal
(
"This script should be run on a Mac OS X 10.4 system"
)
if
platform
.
release
()
<=
'8.'
:
if
platform
.
release
()
<=
'8.'
:
fatal
(
"This script should be run on a Mac OS X 10.4 system"
)
fatal
(
"This script should be run on a Mac OS X 10.4 system"
)
if
not
os
.
path
.
exists
(
SDKPATH
):
if
not
os
.
path
.
exists
(
SDKPATH
):
fatal
(
"Please install the latest version of Xcode and the
%
s SDK"
%
(
fatal
(
"Please install the latest version of Xcode and the
%
s SDK"
%
(
os
.
path
.
basename
(
SDKPATH
[:
-
4
])))
os
.
path
.
basename
(
SDKPATH
[:
-
4
])))
def
parseOptions
(
args
=
None
):
def
parseOptions
(
args
=
None
):
"""
"""
Parse arguments and update global settings.
Parse arguments and update global settings.
"""
"""
global
WORKDIR
,
DEPSRC
,
SDKPATH
,
SRCDIR
global
WORKDIR
,
DEPSRC
,
SDKPATH
,
SRCDIR
if
args
is
None
:
if
args
is
None
:
args
=
sys
.
argv
[
1
:]
args
=
sys
.
argv
[
1
:]
try
:
try
:
options
,
args
=
getopt
.
getopt
(
args
,
'?hb'
,
options
,
args
=
getopt
.
getopt
(
args
,
'?hb'
,
[
'build-dir='
,
'third-party='
,
'sdk-path='
,
'src-dir='
])
[
'build-dir='
,
'third-party='
,
'sdk-path='
,
'src-dir='
])
except
getopt
.
error
,
msg
:
except
getopt
.
error
,
msg
:
print
msg
print
msg
sys
.
exit
(
1
)
sys
.
exit
(
1
)
if
args
:
if
args
:
print
"Additional arguments"
print
"Additional arguments"
sys
.
exit
(
1
)
sys
.
exit
(
1
)
for
k
,
v
in
options
:
for
k
,
v
in
options
:
if
k
in
(
'-h'
,
'-?'
):
if
k
in
(
'-h'
,
'-?'
):
print
USAGE
print
USAGE
sys
.
exit
(
0
)
sys
.
exit
(
0
)
elif
k
in
(
'-d'
,
'--build-dir'
):
elif
k
in
(
'-d'
,
'--build-dir'
):
WORKDIR
=
v
WORKDIR
=
v
elif
k
in
(
'--third-party'
,):
elif
k
in
(
'--third-party'
,):
DEPSRC
=
v
DEPSRC
=
v
elif
k
in
(
'--sdk-path'
,):
elif
k
in
(
'--sdk-path'
,):
SDKPATH
=
v
SDKPATH
=
v
elif
k
in
(
'--src-dir'
,):
elif
k
in
(
'--src-dir'
,):
SRCDIR
=
v
SRCDIR
=
v
else
:
else
:
raise
NotImplementedError
,
k
raise
NotImplementedError
,
k
SRCDIR
=
os
.
path
.
abspath
(
SRCDIR
)
SRCDIR
=
os
.
path
.
abspath
(
SRCDIR
)
WORKDIR
=
os
.
path
.
abspath
(
WORKDIR
)
WORKDIR
=
os
.
path
.
abspath
(
WORKDIR
)
SDKPATH
=
os
.
path
.
abspath
(
SDKPATH
)
SDKPATH
=
os
.
path
.
abspath
(
SDKPATH
)
DEPSRC
=
os
.
path
.
abspath
(
DEPSRC
)
DEPSRC
=
os
.
path
.
abspath
(
DEPSRC
)
print
"Settings:"
print
"Settings:"
print
" * Source directory:"
,
SRCDIR
print
" * Source directory:"
,
SRCDIR
print
" * Build directory: "
,
WORKDIR
print
" * Build directory: "
,
WORKDIR
print
" * SDK location: "
,
SDKPATH
print
" * SDK location: "
,
SDKPATH
print
" * third-party source:"
,
DEPSRC
print
" * third-party source:"
,
DEPSRC
print
""
print
""
def
extractArchive
(
builddir
,
archiveName
):
def
extractArchive
(
builddir
,
archiveName
):
"""
"""
Extract a source archive into 'builddir'. Returns the path of the
Extract a source archive into 'builddir'. Returns the path of the
extracted archive.
extracted archive.
XXX: This function assumes that archives contain a toplevel directory
XXX: This function assumes that archives contain a toplevel directory
that is has the same name as the basename of the archive. This is
that is has the same name as the basename of the archive. This is
save enough for anything we use.
save enough for anything we use.
"""
"""
curdir
=
os
.
getcwd
()
curdir
=
os
.
getcwd
()
try
:
try
:
os
.
chdir
(
builddir
)
os
.
chdir
(
builddir
)
if
archiveName
.
endswith
(
'.tar.gz'
):
if
archiveName
.
endswith
(
'.tar.gz'
):
retval
=
os
.
path
.
basename
(
archiveName
[:
-
7
])
retval
=
os
.
path
.
basename
(
archiveName
[:
-
7
])
if
os
.
path
.
exists
(
retval
):
if
os
.
path
.
exists
(
retval
):
shutil
.
rmtree
(
retval
)
shutil
.
rmtree
(
retval
)
fp
=
os
.
popen
(
"tar zxf
%
s 2>&1"
%
(
shellQuote
(
archiveName
),),
'r'
)
fp
=
os
.
popen
(
"tar zxf
%
s 2>&1"
%
(
shellQuote
(
archiveName
),),
'r'
)
elif
archiveName
.
endswith
(
'.tar.bz2'
):
elif
archiveName
.
endswith
(
'.tar.bz2'
):
retval
=
os
.
path
.
basename
(
archiveName
[:
-
8
])
retval
=
os
.
path
.
basename
(
archiveName
[:
-
8
])
if
os
.
path
.
exists
(
retval
):
if
os
.
path
.
exists
(
retval
):
shutil
.
rmtree
(
retval
)
shutil
.
rmtree
(
retval
)
fp
=
os
.
popen
(
"tar jxf
%
s 2>&1"
%
(
shellQuote
(
archiveName
),),
'r'
)
fp
=
os
.
popen
(
"tar jxf
%
s 2>&1"
%
(
shellQuote
(
archiveName
),),
'r'
)
elif
archiveName
.
endswith
(
'.tar'
):
elif
archiveName
.
endswith
(
'.tar'
):
retval
=
os
.
path
.
basename
(
archiveName
[:
-
4
])
retval
=
os
.
path
.
basename
(
archiveName
[:
-
4
])
if
os
.
path
.
exists
(
retval
):
if
os
.
path
.
exists
(
retval
):
shutil
.
rmtree
(
retval
)
shutil
.
rmtree
(
retval
)
fp
=
os
.
popen
(
"tar xf
%
s 2>&1"
%
(
shellQuote
(
archiveName
),),
'r'
)
fp
=
os
.
popen
(
"tar xf
%
s 2>&1"
%
(
shellQuote
(
archiveName
),),
'r'
)
elif
archiveName
.
endswith
(
'.zip'
):
elif
archiveName
.
endswith
(
'.zip'
):
retval
=
os
.
path
.
basename
(
archiveName
[:
-
4
])
retval
=
os
.
path
.
basename
(
archiveName
[:
-
4
])
if
os
.
path
.
exists
(
retval
):
if
os
.
path
.
exists
(
retval
):
shutil
.
rmtree
(
retval
)
shutil
.
rmtree
(
retval
)
fp
=
os
.
popen
(
"unzip
%
s 2>&1"
%
(
shellQuote
(
archiveName
),),
'r'
)
fp
=
os
.
popen
(
"unzip
%
s 2>&1"
%
(
shellQuote
(
archiveName
),),
'r'
)
data
=
fp
.
read
()
data
=
fp
.
read
()
xit
=
fp
.
close
()
xit
=
fp
.
close
()
if
xit
is
not
None
:
if
xit
is
not
None
:
sys
.
stdout
.
write
(
data
)
sys
.
stdout
.
write
(
data
)
raise
RuntimeError
,
"Cannot extract
%
s"
%
(
archiveName
,)
raise
RuntimeError
,
"Cannot extract
%
s"
%
(
archiveName
,)
return
os
.
path
.
join
(
builddir
,
retval
)
return
os
.
path
.
join
(
builddir
,
retval
)
finally
:
finally
:
os
.
chdir
(
curdir
)
os
.
chdir
(
curdir
)
KNOWNSIZES
=
{
KNOWNSIZES
=
{
"http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz"
:
7952742
,
"http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz"
:
7952742
,
"http://downloads.sleepycat.com/db-4.4.20.tar.gz"
:
2030276
,
"http://downloads.sleepycat.com/db-4.4.20.tar.gz"
:
2030276
,
}
}
def
downloadURL
(
url
,
fname
):
def
downloadURL
(
url
,
fname
):
"""
"""
Download the contents of the url into the file.
Download the contents of the url into the file.
"""
"""
try
:
try
:
size
=
os
.
path
.
getsize
(
fname
)
size
=
os
.
path
.
getsize
(
fname
)
except
OSError
:
except
OSError
:
pass
pass
else
:
else
:
if
KNOWNSIZES
.
get
(
url
)
==
size
:
if
KNOWNSIZES
.
get
(
url
)
==
size
:
print
"Using existing file for"
,
url
print
"Using existing file for"
,
url
return
return
fpIn
=
urllib2
.
urlopen
(
url
)
fpIn
=
urllib2
.
urlopen
(
url
)
fpOut
=
open
(
fname
,
'wb'
)
fpOut
=
open
(
fname
,
'wb'
)
block
=
fpIn
.
read
(
10240
)
block
=
fpIn
.
read
(
10240
)
try
:
try
:
while
block
:
while
block
:
fpOut
.
write
(
block
)
fpOut
.
write
(
block
)
block
=
fpIn
.
read
(
10240
)
block
=
fpIn
.
read
(
10240
)
fpIn
.
close
()
fpIn
.
close
()
fpOut
.
close
()
fpOut
.
close
()
except
:
except
:
try
:
try
:
os
.
unlink
(
fname
)
os
.
unlink
(
fname
)
except
:
except
:
pass
pass
def
buildRecipe
(
recipe
,
basedir
,
archList
):
def
buildRecipe
(
recipe
,
basedir
,
archList
):
"""
"""
Build software using a recipe. This function does the
Build software using a recipe. This function does the
'configure;make;make install' dance for C software, with a possibility
'configure;make;make install' dance for C software, with a possibility
to customize this process, basically a poor-mans DarwinPorts.
to customize this process, basically a poor-mans DarwinPorts.
"""
"""
curdir
=
os
.
getcwd
()
curdir
=
os
.
getcwd
()
name
=
recipe
[
'name'
]
name
=
recipe
[
'name'
]
url
=
recipe
[
'url'
]
url
=
recipe
[
'url'
]
configure
=
recipe
.
get
(
'configure'
,
'./configure'
)
configure
=
recipe
.
get
(
'configure'
,
'./configure'
)
install
=
recipe
.
get
(
'install'
,
'make && make install DESTDIR=
%
s'
%
(
install
=
recipe
.
get
(
'install'
,
'make && make install DESTDIR=
%
s'
%
(
shellQuote
(
basedir
)))
shellQuote
(
basedir
)))
archiveName
=
os
.
path
.
split
(
url
)[
-
1
]
archiveName
=
os
.
path
.
split
(
url
)[
-
1
]
sourceArchive
=
os
.
path
.
join
(
DEPSRC
,
archiveName
)
sourceArchive
=
os
.
path
.
join
(
DEPSRC
,
archiveName
)
if
not
os
.
path
.
exists
(
DEPSRC
):
if
not
os
.
path
.
exists
(
DEPSRC
):
os
.
mkdir
(
DEPSRC
)
os
.
mkdir
(
DEPSRC
)
if
os
.
path
.
exists
(
sourceArchive
):
if
os
.
path
.
exists
(
sourceArchive
):
print
"Using local copy of
%
s"
%
(
name
,)
print
"Using local copy of
%
s"
%
(
name
,)
else
:
else
:
print
"Downloading
%
s"
%
(
name
,)
print
"Downloading
%
s"
%
(
name
,)
downloadURL
(
url
,
sourceArchive
)
downloadURL
(
url
,
sourceArchive
)
print
"Archive for
%
s stored as
%
s"
%
(
name
,
sourceArchive
)
print
"Archive for
%
s stored as
%
s"
%
(
name
,
sourceArchive
)
print
"Extracting archive for
%
s"
%
(
name
,)
print
"Extracting archive for
%
s"
%
(
name
,)
buildDir
=
os
.
path
.
join
(
WORKDIR
,
'_bld'
)
buildDir
=
os
.
path
.
join
(
WORKDIR
,
'_bld'
)
if
not
os
.
path
.
exists
(
buildDir
):
if
not
os
.
path
.
exists
(
buildDir
):
os
.
mkdir
(
buildDir
)
os
.
mkdir
(
buildDir
)
workDir
=
extractArchive
(
buildDir
,
sourceArchive
)
workDir
=
extractArchive
(
buildDir
,
sourceArchive
)
os
.
chdir
(
workDir
)
os
.
chdir
(
workDir
)
if
'buildDir'
in
recipe
:
if
'buildDir'
in
recipe
:
os
.
chdir
(
recipe
[
'buildDir'
])
os
.
chdir
(
recipe
[
'buildDir'
])
for
fn
in
recipe
.
get
(
'patches'
,
()):
for
fn
in
recipe
.
get
(
'patches'
,
()):
if
fn
.
startswith
(
'http://'
):
if
fn
.
startswith
(
'http://'
):
# Download the patch before applying it.
# Download the patch before applying it.
path
=
os
.
path
.
join
(
DEPSRC
,
os
.
path
.
basename
(
fn
))
path
=
os
.
path
.
join
(
DEPSRC
,
os
.
path
.
basename
(
fn
))
downloadURL
(
fn
,
path
)
downloadURL
(
fn
,
path
)
fn
=
path
fn
=
path
fn
=
os
.
path
.
join
(
curdir
,
fn
)
fn
=
os
.
path
.
join
(
curdir
,
fn
)
runCommand
(
'patch -p
%
s <
%
s'
%
(
recipe
.
get
(
'patchlevel'
,
1
),
runCommand
(
'patch -p
%
s <
%
s'
%
(
recipe
.
get
(
'patchlevel'
,
1
),
shellQuote
(
fn
),))
shellQuote
(
fn
),))
configure_args
=
[
configure_args
=
[
"--prefix=/usr/local"
,
"--prefix=/usr/local"
,
"--enable-static"
,
"--enable-static"
,
"--disable-shared"
,
"--disable-shared"
,
#"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),),
#"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),),
]
]
if
'configure_pre'
in
recipe
:
if
'configure_pre'
in
recipe
:
args
=
list
(
recipe
[
'configure_pre'
])
args
=
list
(
recipe
[
'configure_pre'
])
if
'--disable-static'
in
args
:
if
'--disable-static'
in
args
:
configure_args
.
remove
(
'--enable-static'
)
configure_args
.
remove
(
'--enable-static'
)
if
'--enable-shared'
in
args
:
if
'--enable-shared'
in
args
:
configure_args
.
remove
(
'--disable-shared'
)
configure_args
.
remove
(
'--disable-shared'
)
configure_args
.
extend
(
args
)
configure_args
.
extend
(
args
)
if
recipe
.
get
(
'useLDFlags'
,
1
):
if
recipe
.
get
(
'useLDFlags'
,
1
):
configure_args
.
extend
([
configure_args
.
extend
([
"CFLAGS=-arch
%
s -isysroot
%
s -I
%
s/usr/local/include"
%
(
"CFLAGS=-arch
%
s -isysroot
%
s -I
%
s/usr/local/include"
%
(
' -arch '
.
join
(
archList
),
' -arch '
.
join
(
archList
),
shellQuote
(
SDKPATH
)[
1
:
-
1
],
shellQuote
(
SDKPATH
)[
1
:
-
1
],
shellQuote
(
basedir
)[
1
:
-
1
],),
shellQuote
(
basedir
)[
1
:
-
1
],),
"LDFLAGS=-syslibroot,
%
s -L
%
s/usr/local/lib -arch
%
s"
%
(
"LDFLAGS=-syslibroot,
%
s -L
%
s/usr/local/lib -arch
%
s"
%
(
shellQuote
(
SDKPATH
)[
1
:
-
1
],
shellQuote
(
SDKPATH
)[
1
:
-
1
],
shellQuote
(
basedir
)[
1
:
-
1
],
shellQuote
(
basedir
)[
1
:
-
1
],
' -arch '
.
join
(
archList
)),
' -arch '
.
join
(
archList
)),
])
])
else
:
else
:
configure_args
.
extend
([
configure_args
.
extend
([
"CFLAGS=-arch
%
s -isysroot
%
s -I
%
s/usr/local/include"
%
(
"CFLAGS=-arch
%
s -isysroot
%
s -I
%
s/usr/local/include"
%
(
' -arch '
.
join
(
archList
),
' -arch '
.
join
(
archList
),
shellQuote
(
SDKPATH
)[
1
:
-
1
],
shellQuote
(
SDKPATH
)[
1
:
-
1
],
shellQuote
(
basedir
)[
1
:
-
1
],),
shellQuote
(
basedir
)[
1
:
-
1
],),
])
])
if
'configure_post'
in
recipe
:
if
'configure_post'
in
recipe
:
configure_args
=
configure_args
=
list
(
recipe
[
'configure_post'
])
configure_args
=
configure_args
=
list
(
recipe
[
'configure_post'
])
configure_args
.
insert
(
0
,
configure
)
configure_args
.
insert
(
0
,
configure
)
configure_args
=
[
shellQuote
(
a
)
for
a
in
configure_args
]
configure_args
=
[
shellQuote
(
a
)
for
a
in
configure_args
]
print
"Running configure for
%
s"
%
(
name
,)
print
"Running configure for
%
s"
%
(
name
,)
runCommand
(
' '
.
join
(
configure_args
)
+
' 2>&1'
)
runCommand
(
' '
.
join
(
configure_args
)
+
' 2>&1'
)
print
"Running install for
%
s"
%
(
name
,)
print
"Running install for
%
s"
%
(
name
,)
runCommand
(
'{ '
+
install
+
' ;} 2>&1'
)
runCommand
(
'{ '
+
install
+
' ;} 2>&1'
)
print
"Done
%
s"
%
(
name
,)
print
"Done
%
s"
%
(
name
,)
print
""
print
""
os
.
chdir
(
curdir
)
os
.
chdir
(
curdir
)
def
buildLibraries
():
def
buildLibraries
():
"""
"""
Build our dependencies into $WORKDIR/libraries/usr/local
Build our dependencies into $WORKDIR/libraries/usr/local
"""
"""
print
""
print
""
print
"Building required libraries"
print
"Building required libraries"
print
""
print
""
universal
=
os
.
path
.
join
(
WORKDIR
,
'libraries'
)
universal
=
os
.
path
.
join
(
WORKDIR
,
'libraries'
)
os
.
mkdir
(
universal
)
os
.
mkdir
(
universal
)
os
.
makedirs
(
os
.
path
.
join
(
universal
,
'usr'
,
'local'
,
'lib'
))
os
.
makedirs
(
os
.
path
.
join
(
universal
,
'usr'
,
'local'
,
'lib'
))
os
.
makedirs
(
os
.
path
.
join
(
universal
,
'usr'
,
'local'
,
'include'
))
os
.
makedirs
(
os
.
path
.
join
(
universal
,
'usr'
,
'local'
,
'include'
))
for
recipe
in
LIBRARY_RECIPES
:
for
recipe
in
LIBRARY_RECIPES
:
buildRecipe
(
recipe
,
universal
,
(
'i386'
,
'ppc'
,))
buildRecipe
(
recipe
,
universal
,
(
'i386'
,
'ppc'
,))
def
buildPythonDocs
():
def
buildPythonDocs
():
# This stores the documentation as Resources/English.lproj/Docuentation
# This stores the documentation as Resources/English.lproj/Docuentation
# inside the framwork. pydoc and IDLE will pick it up there.
# inside the framwork. pydoc and IDLE will pick it up there.
print
"Install python documentation"
print
"Install python documentation"
rootDir
=
os
.
path
.
join
(
WORKDIR
,
'_root'
)
rootDir
=
os
.
path
.
join
(
WORKDIR
,
'_root'
)
version
=
getVersion
()
version
=
getVersion
()
docdir
=
os
.
path
.
join
(
rootDir
,
'pydocs'
)
docdir
=
os
.
path
.
join
(
rootDir
,
'pydocs'
)
name
=
'html-
%
s.tar.bz2'
%
(
getFullVersion
(),)
name
=
'html-
%
s.tar.bz2'
%
(
getFullVersion
(),)
sourceArchive
=
os
.
path
.
join
(
DEPSRC
,
name
)
sourceArchive
=
os
.
path
.
join
(
DEPSRC
,
name
)
if
os
.
path
.
exists
(
sourceArchive
):
if
os
.
path
.
exists
(
sourceArchive
):
print
"Using local copy of
%
s"
%
(
name
,)
print
"Using local copy of
%
s"
%
(
name
,)
else
:
else
:
print
"Downloading
%
s"
%
(
name
,)
print
"Downloading
%
s"
%
(
name
,)
downloadURL
(
'http://www.python.org/ftp/python/doc/
%
s/
%
s'
%
(
downloadURL
(
'http://www.python.org/ftp/python/doc/
%
s/
%
s'
%
(
getFullVersion
(),
name
),
sourceArchive
)
getFullVersion
(),
name
),
sourceArchive
)
print
"Archive for
%
s stored as
%
s"
%
(
name
,
sourceArchive
)
print
"Archive for
%
s stored as
%
s"
%
(
name
,
sourceArchive
)
extractArchive
(
os
.
path
.
dirname
(
docdir
),
sourceArchive
)
extractArchive
(
os
.
path
.
dirname
(
docdir
),
sourceArchive
)
os
.
rename
(
os
.
rename
(
os
.
path
.
join
(
os
.
path
.
join
(
os
.
path
.
dirname
(
docdir
),
'Python-Docs-
%
s'
%
(
getFullVersion
(),)),
os
.
path
.
dirname
(
docdir
),
'Python-Docs-
%
s'
%
(
getFullVersion
(),)),
docdir
)
docdir
)
def
buildPython
():
def
buildPython
():
print
"Building a universal python"
print
"Building a universal python"
buildDir
=
os
.
path
.
join
(
WORKDIR
,
'_bld'
,
'python'
)
buildDir
=
os
.
path
.
join
(
WORKDIR
,
'_bld'
,
'python'
)
rootDir
=
os
.
path
.
join
(
WORKDIR
,
'_root'
)
rootDir
=
os
.
path
.
join
(
WORKDIR
,
'_root'
)
if
os
.
path
.
exists
(
buildDir
):
if
os
.
path
.
exists
(
buildDir
):
shutil
.
rmtree
(
buildDir
)
shutil
.
rmtree
(
buildDir
)
if
os
.
path
.
exists
(
rootDir
):
if
os
.
path
.
exists
(
rootDir
):
shutil
.
rmtree
(
rootDir
)
shutil
.
rmtree
(
rootDir
)
os
.
mkdir
(
buildDir
)
os
.
mkdir
(
buildDir
)
os
.
mkdir
(
rootDir
)
os
.
mkdir
(
rootDir
)
os
.
mkdir
(
os
.
path
.
join
(
rootDir
,
'empty-dir'
))
os
.
mkdir
(
os
.
path
.
join
(
rootDir
,
'empty-dir'
))
curdir
=
os
.
getcwd
()
curdir
=
os
.
getcwd
()
os
.
chdir
(
buildDir
)
os
.
chdir
(
buildDir
)
# Not sure if this is still needed, the original build script
# Not sure if this is still needed, the original build script
# claims that parts of the install assume python.exe exists.
# claims that parts of the install assume python.exe exists.
os
.
symlink
(
'python'
,
os
.
path
.
join
(
buildDir
,
'python.exe'
))
os
.
symlink
(
'python'
,
os
.
path
.
join
(
buildDir
,
'python.exe'
))
# Extract the version from the configure file, needed to calculate
# Extract the version from the configure file, needed to calculate
# several paths.
# several paths.
version
=
getVersion
()
version
=
getVersion
()
print
"Running configure..."
print
"Running configure..."
runCommand
(
"
%
s -C --enable-framework --enable-universalsdk=
%
s LDFLAGS='-g -L'
%
s/libraries/usr/local/lib OPT='-g -O3 -I'
%
s/libraries/usr/local/include 2>&1"
%
(
runCommand
(
"
%
s -C --enable-framework --enable-universalsdk=
%
s LDFLAGS='-g -L'
%
s/libraries/usr/local/lib OPT='-g -O3 -I'
%
s/libraries/usr/local/include 2>&1"
%
(
shellQuote
(
os
.
path
.
join
(
SRCDIR
,
'configure'
)),
shellQuote
(
os
.
path
.
join
(
SRCDIR
,
'configure'
)),
shellQuote
(
SDKPATH
),
shellQuote
(
WORKDIR
),
shellQuote
(
SDKPATH
),
shellQuote
(
WORKDIR
),
shellQuote
(
WORKDIR
)))
shellQuote
(
WORKDIR
)))
print
"Running make"
print
"Running make"
runCommand
(
"make"
)
runCommand
(
"make"
)
print
"Runing make frameworkinstall"
print
"Runing make frameworkinstall"
runCommand
(
"make frameworkinstall DESTDIR=
%
s"
%
(
runCommand
(
"make frameworkinstall DESTDIR=
%
s"
%
(
shellQuote
(
rootDir
)))
shellQuote
(
rootDir
)))
print
"Runing make frameworkinstallextras"
print
"Runing make frameworkinstallextras"
runCommand
(
"make frameworkinstallextras DESTDIR=
%
s"
%
(
runCommand
(
"make frameworkinstallextras DESTDIR=
%
s"
%
(
shellQuote
(
rootDir
)))
shellQuote
(
rootDir
)))
print
"Copy required shared libraries"
print
"Copy required shared libraries"
if
os
.
path
.
exists
(
os
.
path
.
join
(
WORKDIR
,
'libraries'
,
'Library'
)):
if
os
.
path
.
exists
(
os
.
path
.
join
(
WORKDIR
,
'libraries'
,
'Library'
)):
runCommand
(
"mv
%
s/*
%
s"
%
(
runCommand
(
"mv
%
s/*
%
s"
%
(
shellQuote
(
os
.
path
.
join
(
shellQuote
(
os
.
path
.
join
(
WORKDIR
,
'libraries'
,
'Library'
,
'Frameworks'
,
WORKDIR
,
'libraries'
,
'Library'
,
'Frameworks'
,
'Python.framework'
,
'Versions'
,
getVersion
(),
'Python.framework'
,
'Versions'
,
getVersion
(),
'lib'
)),
'lib'
)),
shellQuote
(
os
.
path
.
join
(
WORKDIR
,
'_root'
,
'Library'
,
'Frameworks'
,
shellQuote
(
os
.
path
.
join
(
WORKDIR
,
'_root'
,
'Library'
,
'Frameworks'
,
'Python.framework'
,
'Versions'
,
getVersion
(),
'Python.framework'
,
'Versions'
,
getVersion
(),
'lib'
))))
'lib'
))))
print
"Fix file modes"
print
"Fix file modes"
frmDir
=
os
.
path
.
join
(
rootDir
,
'Library'
,
'Frameworks'
,
'Python.framework'
)
frmDir
=
os
.
path
.
join
(
rootDir
,
'Library'
,
'Frameworks'
,
'Python.framework'
)
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
frmDir
):
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
frmDir
):
for
dn
in
dirnames
:
for
dn
in
dirnames
:
os
.
chmod
(
os
.
path
.
join
(
dirpath
,
dn
),
0775
)
os
.
chmod
(
os
.
path
.
join
(
dirpath
,
dn
),
0775
)
for
fn
in
filenames
:
for
fn
in
filenames
:
if
os
.
path
.
islink
(
fn
):
if
os
.
path
.
islink
(
fn
):
continue
continue
# "chmod g+w $fn"
# "chmod g+w $fn"
p
=
os
.
path
.
join
(
dirpath
,
fn
)
p
=
os
.
path
.
join
(
dirpath
,
fn
)
st
=
os
.
stat
(
p
)
st
=
os
.
stat
(
p
)
os
.
chmod
(
p
,
stat
.
S_IMODE
(
st
.
st_mode
)
|
stat
.
S_IXGRP
)
os
.
chmod
(
p
,
stat
.
S_IMODE
(
st
.
st_mode
)
|
stat
.
S_IXGRP
)
# We added some directories to the search path during the configure
# We added some directories to the search path during the configure
# phase. Remove those because those directories won't be there on
# phase. Remove those because those directories won't be there on
# the end-users system.
# the end-users system.
path
=
os
.
path
.
join
(
rootDir
,
'Library'
,
'Frameworks'
,
'Python.framework'
,
path
=
os
.
path
.
join
(
rootDir
,
'Library'
,
'Frameworks'
,
'Python.framework'
,
'Versions'
,
version
,
'lib'
,
'python
%
s'
%
(
version
,),
'Versions'
,
version
,
'lib'
,
'python
%
s'
%
(
version
,),
'config'
,
'Makefile'
)
'config'
,
'Makefile'
)
fp
=
open
(
path
,
'r'
)
fp
=
open
(
path
,
'r'
)
data
=
fp
.
read
()
data
=
fp
.
read
()
fp
.
close
()
fp
.
close
()
data
=
data
.
replace
(
'-L
%
s/libraries/usr/local/lib'
%
(
WORKDIR
,),
''
)
data
=
data
.
replace
(
'-L
%
s/libraries/usr/local/lib'
%
(
WORKDIR
,),
''
)
data
=
data
.
replace
(
'-I
%
s/libraries/usr/local/include'
%
(
WORKDIR
,),
''
)
data
=
data
.
replace
(
'-I
%
s/libraries/usr/local/include'
%
(
WORKDIR
,),
''
)
fp
=
open
(
path
,
'w'
)
fp
=
open
(
path
,
'w'
)
fp
.
write
(
data
)
fp
.
write
(
data
)
fp
.
close
()
fp
.
close
()
# Add symlinks in /usr/local/bin, using relative links
# Add symlinks in /usr/local/bin, using relative links
usr_local_bin
=
os
.
path
.
join
(
rootDir
,
'usr'
,
'local'
,
'bin'
)
usr_local_bin
=
os
.
path
.
join
(
rootDir
,
'usr'
,
'local'
,
'bin'
)
to_framework
=
os
.
path
.
join
(
'..'
,
'..'
,
'..'
,
'Library'
,
'Frameworks'
,
to_framework
=
os
.
path
.
join
(
'..'
,
'..'
,
'..'
,
'Library'
,
'Frameworks'
,
'Python.framework'
,
'Versions'
,
version
,
'bin'
)
'Python.framework'
,
'Versions'
,
version
,
'bin'
)
if
os
.
path
.
exists
(
usr_local_bin
):
if
os
.
path
.
exists
(
usr_local_bin
):
shutil
.
rmtree
(
usr_local_bin
)
shutil
.
rmtree
(
usr_local_bin
)
os
.
makedirs
(
usr_local_bin
)
os
.
makedirs
(
usr_local_bin
)
for
fn
in
os
.
listdir
(
for
fn
in
os
.
listdir
(
os
.
path
.
join
(
frmDir
,
'Versions'
,
version
,
'bin'
)):
os
.
path
.
join
(
frmDir
,
'Versions'
,
version
,
'bin'
)):
os
.
symlink
(
os
.
path
.
join
(
to_framework
,
fn
),
os
.
symlink
(
os
.
path
.
join
(
to_framework
,
fn
),
os
.
path
.
join
(
usr_local_bin
,
fn
))
os
.
path
.
join
(
usr_local_bin
,
fn
))
os
.
chdir
(
curdir
)
os
.
chdir
(
curdir
)
def
patchFile
(
inPath
,
outPath
):
def
patchFile
(
inPath
,
outPath
):
data
=
fileContents
(
inPath
)
data
=
fileContents
(
inPath
)
data
=
data
.
replace
(
'$FULL_VERSION'
,
getFullVersion
())
data
=
data
.
replace
(
'$FULL_VERSION'
,
getFullVersion
())
data
=
data
.
replace
(
'$VERSION'
,
getVersion
())
data
=
data
.
replace
(
'$VERSION'
,
getVersion
())
data
=
data
.
replace
(
'$MACOSX_DEPLOYMENT_TARGET'
,
'10.3 or later'
)
data
=
data
.
replace
(
'$MACOSX_DEPLOYMENT_TARGET'
,
'10.3 or later'
)
data
=
data
.
replace
(
'$ARCHITECTURES'
,
"i386, ppc"
)
data
=
data
.
replace
(
'$ARCHITECTURES'
,
"i386, ppc"
)
data
=
data
.
replace
(
'$INSTALL_SIZE'
,
installSize
())
data
=
data
.
replace
(
'$INSTALL_SIZE'
,
installSize
())
fp
=
open
(
outPath
,
'wb'
)
fp
=
open
(
outPath
,
'wb'
)
fp
.
write
(
data
)
fp
.
write
(
data
)
fp
.
close
()
fp
.
close
()
def
patchScript
(
inPath
,
outPath
):
def
patchScript
(
inPath
,
outPath
):
data
=
fileContents
(
inPath
)
data
=
fileContents
(
inPath
)
data
=
data
.
replace
(
'@PYVER@'
,
getVersion
())
data
=
data
.
replace
(
'@PYVER@'
,
getVersion
())
fp
=
open
(
outPath
,
'wb'
)
fp
=
open
(
outPath
,
'wb'
)
fp
.
write
(
data
)
fp
.
write
(
data
)
fp
.
close
()
fp
.
close
()
os
.
chmod
(
outPath
,
0755
)
os
.
chmod
(
outPath
,
0755
)
def
packageFromRecipe
(
targetDir
,
recipe
):
def
packageFromRecipe
(
targetDir
,
recipe
):
curdir
=
os
.
getcwd
()
curdir
=
os
.
getcwd
()
try
:
try
:
pkgname
=
recipe
[
'name'
]
pkgname
=
recipe
[
'name'
]
srcdir
=
recipe
.
get
(
'source'
)
srcdir
=
recipe
.
get
(
'source'
)
pkgroot
=
recipe
.
get
(
'topdir'
,
srcdir
)
pkgroot
=
recipe
.
get
(
'topdir'
,
srcdir
)
postflight
=
recipe
.
get
(
'postflight'
)
postflight
=
recipe
.
get
(
'postflight'
)
readme
=
textwrap
.
dedent
(
recipe
[
'readme'
])
readme
=
textwrap
.
dedent
(
recipe
[
'readme'
])
isRequired
=
recipe
.
get
(
'required'
,
True
)
isRequired
=
recipe
.
get
(
'required'
,
True
)
print
"- building package
%
s"
%
(
pkgname
,)
print
"- building package
%
s"
%
(
pkgname
,)
# Substitute some variables
# Substitute some variables
textvars
=
dict
(
textvars
=
dict
(
VER
=
getVersion
(),
VER
=
getVersion
(),
FULLVER
=
getFullVersion
(),
FULLVER
=
getFullVersion
(),
)
)
readme
=
readme
%
textvars
readme
=
readme
%
textvars
if
pkgroot
is
not
None
:
if
pkgroot
is
not
None
:
pkgroot
=
pkgroot
%
textvars
pkgroot
=
pkgroot
%
textvars
else
:
else
:
pkgroot
=
'/'
pkgroot
=
'/'
if
srcdir
is
not
None
:
if
srcdir
is
not
None
:
srcdir
=
os
.
path
.
join
(
WORKDIR
,
'_root'
,
srcdir
[
1
:])
srcdir
=
os
.
path
.
join
(
WORKDIR
,
'_root'
,
srcdir
[
1
:])
srcdir
=
srcdir
%
textvars
srcdir
=
srcdir
%
textvars
if
postflight
is
not
None
:
if
postflight
is
not
None
:
postflight
=
os
.
path
.
abspath
(
postflight
)
postflight
=
os
.
path
.
abspath
(
postflight
)
packageContents
=
os
.
path
.
join
(
targetDir
,
pkgname
+
'.pkg'
,
'Contents'
)
packageContents
=
os
.
path
.
join
(
targetDir
,
pkgname
+
'.pkg'
,
'Contents'
)
os
.
makedirs
(
packageContents
)
os
.
makedirs
(
packageContents
)
if
srcdir
is
not
None
:
if
srcdir
is
not
None
:
os
.
chdir
(
srcdir
)
os
.
chdir
(
srcdir
)
runCommand
(
"pax -wf
%
s . 2>&1"
%
(
shellQuote
(
os
.
path
.
join
(
packageContents
,
'Archive.pax'
)),))
runCommand
(
"pax -wf
%
s . 2>&1"
%
(
shellQuote
(
os
.
path
.
join
(
packageContents
,
'Archive.pax'
)),))
runCommand
(
"gzip -9
%
s 2>&1"
%
(
shellQuote
(
os
.
path
.
join
(
packageContents
,
'Archive.pax'
)),))
runCommand
(
"gzip -9
%
s 2>&1"
%
(
shellQuote
(
os
.
path
.
join
(
packageContents
,
'Archive.pax'
)),))
runCommand
(
"mkbom .
%
s 2>&1"
%
(
shellQuote
(
os
.
path
.
join
(
packageContents
,
'Archive.bom'
)),))
runCommand
(
"mkbom .
%
s 2>&1"
%
(
shellQuote
(
os
.
path
.
join
(
packageContents
,
'Archive.bom'
)),))
fn
=
os
.
path
.
join
(
packageContents
,
'PkgInfo'
)
fn
=
os
.
path
.
join
(
packageContents
,
'PkgInfo'
)
fp
=
open
(
fn
,
'w'
)
fp
=
open
(
fn
,
'w'
)
fp
.
write
(
'pmkrpkg1'
)
fp
.
write
(
'pmkrpkg1'
)
fp
.
close
()
fp
.
close
()
rsrcDir
=
os
.
path
.
join
(
packageContents
,
"Resources"
)
rsrcDir
=
os
.
path
.
join
(
packageContents
,
"Resources"
)
os
.
mkdir
(
rsrcDir
)
os
.
mkdir
(
rsrcDir
)
fp
=
open
(
os
.
path
.
join
(
rsrcDir
,
'ReadMe.txt'
),
'w'
)
fp
=
open
(
os
.
path
.
join
(
rsrcDir
,
'ReadMe.txt'
),
'w'
)
fp
.
write
(
readme
)
fp
.
write
(
readme
)
fp
.
close
()
fp
.
close
()
if
postflight
is
not
None
:
if
postflight
is
not
None
:
patchScript
(
postflight
,
os
.
path
.
join
(
rsrcDir
,
'postflight'
))
patchScript
(
postflight
,
os
.
path
.
join
(
rsrcDir
,
'postflight'
))
vers
=
getFullVersion
()
vers
=
getFullVersion
()
major
,
minor
=
map
(
int
,
getVersion
()
.
split
(
'.'
,
2
))
major
,
minor
=
map
(
int
,
getVersion
()
.
split
(
'.'
,
2
))
pl
=
Plist
(
pl
=
Plist
(
CFBundleGetInfoString
=
"MacPython.
%
s
%
s"
%
(
pkgname
,
vers
,),
CFBundleGetInfoString
=
"MacPython.
%
s
%
s"
%
(
pkgname
,
vers
,),
CFBundleIdentifier
=
'org.python.MacPython.
%
s'
%
(
pkgname
,),
CFBundleIdentifier
=
'org.python.MacPython.
%
s'
%
(
pkgname
,),
CFBundleName
=
'MacPython.
%
s'
%
(
pkgname
,),
CFBundleName
=
'MacPython.
%
s'
%
(
pkgname
,),
CFBundleShortVersionString
=
vers
,
CFBundleShortVersionString
=
vers
,
IFMajorVersion
=
major
,
IFMajorVersion
=
major
,
IFMinorVersion
=
minor
,
IFMinorVersion
=
minor
,
IFPkgFormatVersion
=
0.10000000149011612
,
IFPkgFormatVersion
=
0.10000000149011612
,
IFPkgFlagAllowBackRev
=
False
,
IFPkgFlagAllowBackRev
=
False
,
IFPkgFlagAuthorizationAction
=
"RootAuthorization"
,
IFPkgFlagAuthorizationAction
=
"RootAuthorization"
,
IFPkgFlagDefaultLocation
=
pkgroot
,
IFPkgFlagDefaultLocation
=
pkgroot
,
IFPkgFlagFollowLinks
=
True
,
IFPkgFlagFollowLinks
=
True
,
IFPkgFlagInstallFat
=
True
,
IFPkgFlagInstallFat
=
True
,
IFPkgFlagIsRequired
=
isRequired
,
IFPkgFlagIsRequired
=
isRequired
,
IFPkgFlagOverwritePermissions
=
False
,
IFPkgFlagOverwritePermissions
=
False
,
IFPkgFlagRelocatable
=
False
,
IFPkgFlagRelocatable
=
False
,
IFPkgFlagRestartAction
=
"NoRestart"
,
IFPkgFlagRestartAction
=
"NoRestart"
,
IFPkgFlagRootVolumeOnly
=
True
,
IFPkgFlagRootVolumeOnly
=
True
,
IFPkgFlagUpdateInstalledLangauges
=
False
,
IFPkgFlagUpdateInstalledLangauges
=
False
,
)
)
writePlist
(
pl
,
os
.
path
.
join
(
packageContents
,
'Info.plist'
))
writePlist
(
pl
,
os
.
path
.
join
(
packageContents
,
'Info.plist'
))
pl
=
Plist
(
pl
=
Plist
(
IFPkgDescriptionDescription
=
readme
,
IFPkgDescriptionDescription
=
readme
,
IFPkgDescriptionTitle
=
recipe
.
get
(
'long_name'
,
"MacPython.
%
s"
%
(
pkgname
,)),
IFPkgDescriptionTitle
=
recipe
.
get
(
'long_name'
,
"MacPython.
%
s"
%
(
pkgname
,)),
IFPkgDescriptionVersion
=
vers
,
IFPkgDescriptionVersion
=
vers
,
)
)
writePlist
(
pl
,
os
.
path
.
join
(
packageContents
,
'Resources'
,
'Description.plist'
))
writePlist
(
pl
,
os
.
path
.
join
(
packageContents
,
'Resources'
,
'Description.plist'
))
finally
:
finally
:
os
.
chdir
(
curdir
)
os
.
chdir
(
curdir
)
def
makeMpkgPlist
(
path
):
def
makeMpkgPlist
(
path
):
vers
=
getFullVersion
()
vers
=
getFullVersion
()
major
,
minor
=
map
(
int
,
getVersion
()
.
split
(
'.'
,
2
))
major
,
minor
=
map
(
int
,
getVersion
()
.
split
(
'.'
,
2
))
pl
=
Plist
(
pl
=
Plist
(
CFBundleGetInfoString
=
"MacPython
%
s"
%
(
vers
,),
CFBundleGetInfoString
=
"MacPython
%
s"
%
(
vers
,),
CFBundleIdentifier
=
'org.python.MacPython'
,
CFBundleIdentifier
=
'org.python.MacPython'
,
CFBundleName
=
'MacPython'
,
CFBundleName
=
'MacPython'
,
CFBundleShortVersionString
=
vers
,
CFBundleShortVersionString
=
vers
,
IFMajorVersion
=
major
,
IFMajorVersion
=
major
,
IFMinorVersion
=
minor
,
IFMinorVersion
=
minor
,
IFPkgFlagComponentDirectory
=
"Contents/Packages"
,
IFPkgFlagComponentDirectory
=
"Contents/Packages"
,
IFPkgFlagPackageList
=
[
IFPkgFlagPackageList
=
[
dict
(
dict
(
IFPkgFlagPackageLocation
=
'
%
s.pkg'
%
(
item
[
'name'
]),
IFPkgFlagPackageLocation
=
'
%
s.pkg'
%
(
item
[
'name'
]),
IFPkgFlagPackageSelection
=
'selected'
IFPkgFlagPackageSelection
=
'selected'
)
)
for
item
in
PKG_RECIPES
for
item
in
PKG_RECIPES
],
],
IFPkgFormatVersion
=
0.10000000149011612
,
IFPkgFormatVersion
=
0.10000000149011612
,
IFPkgFlagBackgroundScaling
=
"proportional"
,
IFPkgFlagBackgroundScaling
=
"proportional"
,
IFPkgFlagBackgroundAlignment
=
"left"
,
IFPkgFlagBackgroundAlignment
=
"left"
,
)
)
writePlist
(
pl
,
path
)
writePlist
(
pl
,
path
)
def
buildInstaller
():
def
buildInstaller
():
# Zap all compiled files
# Zap all compiled files
for
dirpath
,
_
,
filenames
in
os
.
walk
(
os
.
path
.
join
(
WORKDIR
,
'_root'
)):
for
dirpath
,
_
,
filenames
in
os
.
walk
(
os
.
path
.
join
(
WORKDIR
,
'_root'
)):
for
fn
in
filenames
:
for
fn
in
filenames
:
if
fn
.
endswith
(
'.pyc'
)
or
fn
.
endswith
(
'.pyo'
):
if
fn
.
endswith
(
'.pyc'
)
or
fn
.
endswith
(
'.pyo'
):
os
.
unlink
(
os
.
path
.
join
(
dirpath
,
fn
))
os
.
unlink
(
os
.
path
.
join
(
dirpath
,
fn
))
outdir
=
os
.
path
.
join
(
WORKDIR
,
'installer'
)
outdir
=
os
.
path
.
join
(
WORKDIR
,
'installer'
)
if
os
.
path
.
exists
(
outdir
):
if
os
.
path
.
exists
(
outdir
):
shutil
.
rmtree
(
outdir
)
shutil
.
rmtree
(
outdir
)
os
.
mkdir
(
outdir
)
os
.
mkdir
(
outdir
)
pkgroot
=
os
.
path
.
join
(
outdir
,
'MacPython.mpkg'
,
'Contents'
)
pkgroot
=
os
.
path
.
join
(
outdir
,
'MacPython.mpkg'
,
'Contents'
)
pkgcontents
=
os
.
path
.
join
(
pkgroot
,
'Packages'
)
pkgcontents
=
os
.
path
.
join
(
pkgroot
,
'Packages'
)
os
.
makedirs
(
pkgcontents
)
os
.
makedirs
(
pkgcontents
)
for
recipe
in
PKG_RECIPES
:
for
recipe
in
PKG_RECIPES
:
packageFromRecipe
(
pkgcontents
,
recipe
)
packageFromRecipe
(
pkgcontents
,
recipe
)
rsrcDir
=
os
.
path
.
join
(
pkgroot
,
'Resources'
)
rsrcDir
=
os
.
path
.
join
(
pkgroot
,
'Resources'
)
fn
=
os
.
path
.
join
(
pkgroot
,
'PkgInfo'
)
fn
=
os
.
path
.
join
(
pkgroot
,
'PkgInfo'
)
fp
=
open
(
fn
,
'w'
)
fp
=
open
(
fn
,
'w'
)
fp
.
write
(
'pmkrpkg1'
)
fp
.
write
(
'pmkrpkg1'
)
fp
.
close
()
fp
.
close
()
os
.
mkdir
(
rsrcDir
)
os
.
mkdir
(
rsrcDir
)
makeMpkgPlist
(
os
.
path
.
join
(
pkgroot
,
'Info.plist'
))
makeMpkgPlist
(
os
.
path
.
join
(
pkgroot
,
'Info.plist'
))
pl
=
Plist
(
pl
=
Plist
(
IFPkgDescriptionTitle
=
"Universal MacPython"
,
IFPkgDescriptionTitle
=
"Universal MacPython"
,
IFPkgDescriptionVersion
=
getVersion
(),
IFPkgDescriptionVersion
=
getVersion
(),
)
)
writePlist
(
pl
,
os
.
path
.
join
(
pkgroot
,
'Resources'
,
'Description.plist'
))
writePlist
(
pl
,
os
.
path
.
join
(
pkgroot
,
'Resources'
,
'Description.plist'
))
for
fn
in
os
.
listdir
(
'resources'
):
for
fn
in
os
.
listdir
(
'resources'
):
if
fn
.
endswith
(
'.jpg'
):
if
fn
.
endswith
(
'.jpg'
):
shutil
.
copy
(
os
.
path
.
join
(
'resources'
,
fn
),
os
.
path
.
join
(
rsrcDir
,
fn
))
shutil
.
copy
(
os
.
path
.
join
(
'resources'
,
fn
),
os
.
path
.
join
(
rsrcDir
,
fn
))
else
:
else
:
patchFile
(
os
.
path
.
join
(
'resources'
,
fn
),
os
.
path
.
join
(
rsrcDir
,
fn
))
patchFile
(
os
.
path
.
join
(
'resources'
,
fn
),
os
.
path
.
join
(
rsrcDir
,
fn
))
shutil
.
copy
(
"../../../LICENSE"
,
os
.
path
.
join
(
rsrcDir
,
'License.txt'
))
shutil
.
copy
(
"../../../LICENSE"
,
os
.
path
.
join
(
rsrcDir
,
'License.txt'
))
def
installSize
(
clear
=
False
,
_saved
=
[]):
def
installSize
(
clear
=
False
,
_saved
=
[]):
if
clear
:
if
clear
:
del
_saved
[:]
del
_saved
[:]
if
not
_saved
:
if
not
_saved
:
data
=
captureCommand
(
"du -ks
%
s"
%
(
data
=
captureCommand
(
"du -ks
%
s"
%
(
shellQuote
(
os
.
path
.
join
(
WORKDIR
,
'_root'
))))
shellQuote
(
os
.
path
.
join
(
WORKDIR
,
'_root'
))))
_saved
.
append
(
"
%
d"
%
((
0.5
+
(
int
(
data
.
split
()[
0
])
/
1024.0
)),))
_saved
.
append
(
"
%
d"
%
((
0.5
+
(
int
(
data
.
split
()[
0
])
/
1024.0
)),))
return
_saved
[
0
]
return
_saved
[
0
]
def
buildDMG
():
def
buildDMG
():
"""
"""
Create DMG containing the rootDir
Create DMG containing the rootDir
"""
"""
outdir
=
os
.
path
.
join
(
WORKDIR
,
'diskimage'
)
outdir
=
os
.
path
.
join
(
WORKDIR
,
'diskimage'
)
if
os
.
path
.
exists
(
outdir
):
if
os
.
path
.
exists
(
outdir
):
shutil
.
rmtree
(
outdir
)
shutil
.
rmtree
(
outdir
)
imagepath
=
os
.
path
.
join
(
outdir
,
imagepath
=
os
.
path
.
join
(
outdir
,
'python-
%
s-macosx'
%
(
getFullVersion
(),))
'python-
%
s-macosx'
%
(
getFullVersion
(),))
if
INCLUDE_TIMESTAMP
:
if
INCLUDE_TIMESTAMP
:
imagepath
=
imagepath
+
'
%04
d-
%02
d-
%02
d'
%
(
time
.
localtime
()[:
3
])
imagepath
=
imagepath
+
'
%04
d-
%02
d-
%02
d'
%
(
time
.
localtime
()[:
3
])
imagepath
=
imagepath
+
'.dmg'
imagepath
=
imagepath
+
'.dmg'
os
.
mkdir
(
outdir
)
os
.
mkdir
(
outdir
)
runCommand
(
"hdiutil create -volname 'Univeral MacPython
%
s' -srcfolder
%
s
%
s"
%
(
runCommand
(
"hdiutil create -volname 'Univeral MacPython
%
s' -srcfolder
%
s
%
s"
%
(
getFullVersion
(),
getFullVersion
(),
shellQuote
(
os
.
path
.
join
(
WORKDIR
,
'installer'
)),
shellQuote
(
os
.
path
.
join
(
WORKDIR
,
'installer'
)),
shellQuote
(
imagepath
)))
shellQuote
(
imagepath
)))
return
imagepath
return
imagepath
def
setIcon
(
filePath
,
icnsPath
):
def
setIcon
(
filePath
,
icnsPath
):
"""
"""
Set the custom icon for the specified file or directory.
Set the custom icon for the specified file or directory.
For a directory the icon data is written in a file named 'Icon
\r
' inside
For a directory the icon data is written in a file named 'Icon
\r
' inside
the directory. For both files and directories write the icon as an 'icns'
the directory. For both files and directories write the icon as an 'icns'
resource. Furthermore set kHasCustomIcon in the finder flags for filePath.
resource. Furthermore set kHasCustomIcon in the finder flags for filePath.
"""
"""
ref
,
isDirectory
=
Carbon
.
File
.
FSPathMakeRef
(
icnsPath
)
ref
,
isDirectory
=
Carbon
.
File
.
FSPathMakeRef
(
icnsPath
)
icon
=
Carbon
.
Icn
.
ReadIconFile
(
ref
)
icon
=
Carbon
.
Icn
.
ReadIconFile
(
ref
)
del
ref
del
ref
#
#
# Open the resource fork of the target, to add the icon later on.
# Open the resource fork of the target, to add the icon later on.
# For directories we use the file 'Icon\r' inside the directory.
# For directories we use the file 'Icon\r' inside the directory.
#
#
ref
,
isDirectory
=
Carbon
.
File
.
FSPathMakeRef
(
filePath
)
ref
,
isDirectory
=
Carbon
.
File
.
FSPathMakeRef
(
filePath
)
if
isDirectory
:
if
isDirectory
:
tmpPath
=
os
.
path
.
join
(
filePath
,
"Icon
\r
"
)
tmpPath
=
os
.
path
.
join
(
filePath
,
"Icon
\r
"
)
if
not
os
.
path
.
exists
(
tmpPath
):
if
not
os
.
path
.
exists
(
tmpPath
):
fp
=
open
(
tmpPath
,
'w'
)
fp
=
open
(
tmpPath
,
'w'
)
fp
.
close
()
fp
.
close
()
tmpRef
,
_
=
Carbon
.
File
.
FSPathMakeRef
(
tmpPath
)
tmpRef
,
_
=
Carbon
.
File
.
FSPathMakeRef
(
tmpPath
)
spec
=
Carbon
.
File
.
FSSpec
(
tmpRef
)
spec
=
Carbon
.
File
.
FSSpec
(
tmpRef
)
else
:
else
:
spec
=
Carbon
.
File
.
FSSpec
(
ref
)
spec
=
Carbon
.
File
.
FSSpec
(
ref
)
try
:
try
:
Carbon
.
Res
.
HCreateResFile
(
*
spec
.
as_tuple
())
Carbon
.
Res
.
HCreateResFile
(
*
spec
.
as_tuple
())
except
MacOS
.
Error
:
except
MacOS
.
Error
:
pass
pass
# Try to create the resource fork again, this will avoid problems
# Try to create the resource fork again, this will avoid problems
# when adding an icon to a directory. I have no idea why this helps,
# when adding an icon to a directory. I have no idea why this helps,
# but without this adding the icon to a directory will fail sometimes.
# but without this adding the icon to a directory will fail sometimes.
try
:
try
:
Carbon
.
Res
.
HCreateResFile
(
*
spec
.
as_tuple
())
Carbon
.
Res
.
HCreateResFile
(
*
spec
.
as_tuple
())
except
MacOS
.
Error
:
except
MacOS
.
Error
:
pass
pass
refNum
=
Carbon
.
Res
.
FSpOpenResFile
(
spec
,
fsRdWrPerm
)
refNum
=
Carbon
.
Res
.
FSpOpenResFile
(
spec
,
fsRdWrPerm
)
Carbon
.
Res
.
UseResFile
(
refNum
)
Carbon
.
Res
.
UseResFile
(
refNum
)
# Check if there already is an icon, remove it if there is.
# Check if there already is an icon, remove it if there is.
try
:
try
:
h
=
Carbon
.
Res
.
Get1Resource
(
'icns'
,
kCustomIconResource
)
h
=
Carbon
.
Res
.
Get1Resource
(
'icns'
,
kCustomIconResource
)
except
MacOS
.
Error
:
except
MacOS
.
Error
:
pass
pass
else
:
else
:
h
.
RemoveResource
()
h
.
RemoveResource
()
del
h
del
h
# Add the icon to the resource for of the target
# Add the icon to the resource for of the target
res
=
Carbon
.
Res
.
Resource
(
icon
)
res
=
Carbon
.
Res
.
Resource
(
icon
)
res
.
AddResource
(
'icns'
,
kCustomIconResource
,
''
)
res
.
AddResource
(
'icns'
,
kCustomIconResource
,
''
)
res
.
WriteResource
()
res
.
WriteResource
()
res
.
DetachResource
()
res
.
DetachResource
()
Carbon
.
Res
.
CloseResFile
(
refNum
)
Carbon
.
Res
.
CloseResFile
(
refNum
)
# And now set the kHasCustomIcon property for the target. Annoyingly,
# And now set the kHasCustomIcon property for the target. Annoyingly,
# python doesn't seem to have bindings for the API that is needed for
# python doesn't seem to have bindings for the API that is needed for
# this. Cop out and call SetFile
# this. Cop out and call SetFile
os
.
system
(
"/Developer/Tools/SetFile -a C
%
s"
%
(
os
.
system
(
"/Developer/Tools/SetFile -a C
%
s"
%
(
shellQuote
(
filePath
),))
shellQuote
(
filePath
),))
if
isDirectory
:
if
isDirectory
:
os
.
system
(
'/Developer/Tools/SetFile -a V
%
s'
%
(
os
.
system
(
'/Developer/Tools/SetFile -a V
%
s'
%
(
shellQuote
(
tmpPath
),
shellQuote
(
tmpPath
),
))
))
def
main
():
def
main
():
# First parse options and check if we can perform our work
# First parse options and check if we can perform our work
parseOptions
()
parseOptions
()
checkEnvironment
()
checkEnvironment
()
os
.
environ
[
'MACOSX_DEPLOYMENT_TARGET'
]
=
'10.3'
os
.
environ
[
'MACOSX_DEPLOYMENT_TARGET'
]
=
'10.3'
if
os
.
path
.
exists
(
WORKDIR
):
if
os
.
path
.
exists
(
WORKDIR
):
shutil
.
rmtree
(
WORKDIR
)
shutil
.
rmtree
(
WORKDIR
)
os
.
mkdir
(
WORKDIR
)
os
.
mkdir
(
WORKDIR
)
# Then build third-party libraries such as sleepycat DB4.
# Then build third-party libraries such as sleepycat DB4.
buildLibraries
()
buildLibraries
()
# Now build python itself
# Now build python itself
buildPython
()
buildPython
()
buildPythonDocs
()
buildPythonDocs
()
fn
=
os
.
path
.
join
(
WORKDIR
,
"_root"
,
"Applications"
,
fn
=
os
.
path
.
join
(
WORKDIR
,
"_root"
,
"Applications"
,
"MacPython
%
s"
%
(
getVersion
(),),
"Update Shell Profile.command"
)
"MacPython
%
s"
%
(
getVersion
(),),
"Update Shell Profile.command"
)
shutil
.
copy
(
"scripts/postflight.patch-profile"
,
fn
)
shutil
.
copy
(
"scripts/postflight.patch-profile"
,
fn
)
os
.
chmod
(
fn
,
0755
)
os
.
chmod
(
fn
,
0755
)
folder
=
os
.
path
.
join
(
WORKDIR
,
"_root"
,
"Applications"
,
"MacPython
%
s"
%
(
folder
=
os
.
path
.
join
(
WORKDIR
,
"_root"
,
"Applications"
,
"MacPython
%
s"
%
(
getVersion
(),))
getVersion
(),))
os
.
chmod
(
folder
,
0755
)
os
.
chmod
(
folder
,
0755
)
setIcon
(
folder
,
"../Icons/Python Folder.icns"
)
setIcon
(
folder
,
"../Icons/Python Folder.icns"
)
# Create the installer
# Create the installer
buildInstaller
()
buildInstaller
()
# And copy the readme into the directory containing the installer
# And copy the readme into the directory containing the installer
patchFile
(
'resources/ReadMe.txt'
,
os
.
path
.
join
(
WORKDIR
,
'installer'
,
'ReadMe.txt'
))
patchFile
(
'resources/ReadMe.txt'
,
os
.
path
.
join
(
WORKDIR
,
'installer'
,
'ReadMe.txt'
))
# Ditto for the license file.
# Ditto for the license file.
shutil
.
copy
(
'../../../LICENSE'
,
os
.
path
.
join
(
WORKDIR
,
'installer'
,
'License.txt'
))
shutil
.
copy
(
'../../../LICENSE'
,
os
.
path
.
join
(
WORKDIR
,
'installer'
,
'License.txt'
))
fp
=
open
(
os
.
path
.
join
(
WORKDIR
,
'installer'
,
'Build.txt'
),
'w'
)
fp
=
open
(
os
.
path
.
join
(
WORKDIR
,
'installer'
,
'Build.txt'
),
'w'
)
print
>>
fp
,
"# BUILD INFO"
print
>>
fp
,
"# BUILD INFO"
print
>>
fp
,
"# Date:"
,
time
.
ctime
()
print
>>
fp
,
"# Date:"
,
time
.
ctime
()
print
>>
fp
,
"# By:"
,
pwd
.
getpwuid
(
os
.
getuid
())
.
pw_gecos
print
>>
fp
,
"# By:"
,
pwd
.
getpwuid
(
os
.
getuid
())
.
pw_gecos
fp
.
close
()
fp
.
close
()
# Custom icon for the DMG, shown when the DMG is mounted.
# Custom icon for the DMG, shown when the DMG is mounted.
shutil
.
copy
(
"../Icons/Disk Image.icns"
,
shutil
.
copy
(
"../Icons/Disk Image.icns"
,
os
.
path
.
join
(
WORKDIR
,
"installer"
,
".VolumeIcon.icns"
))
os
.
path
.
join
(
WORKDIR
,
"installer"
,
".VolumeIcon.icns"
))
os
.
system
(
"/Developer/Tools/SetFile -a C
%
s"
%
(
os
.
system
(
"/Developer/Tools/SetFile -a C
%
s"
%
(
os
.
path
.
join
(
WORKDIR
,
"installer"
,
".VolumeIcon.icns"
)))
os
.
path
.
join
(
WORKDIR
,
"installer"
,
".VolumeIcon.icns"
)))
# And copy it to a DMG
# And copy it to a DMG
buildDMG
()
buildDMG
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
main
()
main
()
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