update 0.6

This commit is contained in:
utahta
2010-11-14 03:27:13 +09:00
parent 97b101f33c
commit c7aeaa9fcd
44 changed files with 2688 additions and 33 deletions
+63 -14
View File
@@ -4,11 +4,13 @@ import glob
import shutil
import re
from pythonbrew.util import makedirs, symlink, Package, is_url, splitext, Link,\
unlink, is_gzip, is_html, untar_file, Subprocess, rm_r
unlink, is_gzip, is_html, untar_file, Subprocess, rm_r,\
is_macosx_snowleopard, is_python25, is_python24, is_python26
from pythonbrew.define import PATH_BUILD, PATH_BIN, PATH_DISTS, PATH_PYTHONS,\
PATH_ETC, PATH_SCRIPTS, PATH_SCRIPTS_PYTHONBREW,\
PATH_SCRIPTS_PYTHONBREW_COMMANDS, INSTALLER_ROOT, PATH_BIN_PYTHONBREW,\
PATH_BIN_PYBREW, ROOT, PATH_LOG, DISTRIBUTE_SETUP_DLSITE, PATH_PATCHES
PATH_BIN_PYBREW, ROOT, PATH_LOG, DISTRIBUTE_SETUP_DLSITE, PATH_PATCHES,\
PATH_PATCHES_MACOSX_PYTHON25, PATH_PATCHES_MACOSX_PYTHON24
from pythonbrew.downloader import get_python_package_url, Downloader,\
get_response_from_url
from pythonbrew.log import logger
@@ -23,16 +25,15 @@ def install_pythonbrew():
makedirs(PATH_SCRIPTS)
makedirs(PATH_SCRIPTS_PYTHONBREW)
makedirs(PATH_SCRIPTS_PYTHONBREW_COMMANDS)
makedirs(PATH_PATCHES)
for path in glob.glob("%s/*.py" % INSTALLER_ROOT):
for path in glob.glob(os.path.join(INSTALLER_ROOT,"*.py")):
shutil.copy(path, PATH_SCRIPTS_PYTHONBREW)
for path in glob.glob("%s/commands/*.py" % INSTALLER_ROOT):
for path in glob.glob(os.path.join(INSTALLER_ROOT,"commands","*.py")):
shutil.copy(path, PATH_SCRIPTS_PYTHONBREW_COMMANDS)
# for path in glob.glob("%s/patches" % INSTALLER_ROOT):
# shutil.copytree(path, PATH_PATCHES)
rm_r(PATH_PATCHES)
shutil.copytree(os.path.join(INSTALLER_ROOT,"patches"), PATH_PATCHES)
fp = open("%s/pythonbrew_main.py" % PATH_SCRIPTS, "w")
fp.write("""import pythonbrew
@@ -78,12 +79,14 @@ class PythonInstaller(object):
if os.path.isdir(self.install_dir):
logger.info("You are already installed `%s`" % self.pkg.name)
sys.exit()
self.ensure()
self.download()
logger.info("")
logger.info("This could take a while. You can run the following command on another shell to track the status:")
logger.info(" tail -f %s" % self.logfile)
logger.info("")
self.unpack()
self.patch()
logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir))
try:
self.configure()
@@ -92,7 +95,7 @@ class PythonInstaller(object):
except:
rm_r(self.install_dir)
logger.error("Failed to install %s. See %s to see why." % (self.pkg.name, self.logfile))
logger.error(" pythonbrew install --force %s" % self.pkg.version)
logger.info(" pythonbrew install --force %s" % self.pkg.version)
sys.exit(1)
self.install_setuptools()
logger.info("Installed %(pkgname)s successfully. Run the following command to switch to %(pkgname)s."
@@ -100,6 +103,13 @@ class PythonInstaller(object):
logger.info("")
logger.info(" pythonbrew switch %s" % self.pkg.version)
def ensure(self):
if is_macosx_snowleopard():
version = self.pkg.version
if version < '2.6' and (version != '2.4.6' and version != '2.5.5'):
logger.info("`%s` is not supported on MacOSX Snow Leopard" % self.pkg.name)
sys.exit()
def download(self):
content_type = self.content_type
if is_html(content_type):
@@ -128,9 +138,49 @@ class PythonInstaller(object):
else:
logger.error("Cannot determine archive format of %s" % self.download_file)
def patch(self):
version = self.pkg.version
try:
s = Subprocess(log=self.logfile, shell=True, cwd=self.build_dir, print_cmd=False)
patches = []
if is_macosx_snowleopard():
if is_python24(version):
patch_dir = os.path.join(PATH_PATCHES_MACOSX_PYTHON24,'files')
patches = ['patch-configure', 'patch-Makefile.pre.in',
'patch-Lib-cgi.py', 'patch-Lib-site.py',
'patch-setup.py', 'patch-Include-pyport.h',
'patch-Mac-OSX-Makefile.in', 'patch-Mac-OSX-IDLE-Makefile.in',
'patch-Mac-OSX-PythonLauncher-Makefile.in', 'patch-configure-badcflags.diff',
'patch-configure-arch_only.diff', 'patch-macosmodule.diff',
'patch-mactoolboxglue.diff', 'patch-pymactoolbox.diff']
elif is_python25(version):
patch_dir = os.path.join(PATH_PATCHES_MACOSX_PYTHON25,'files')
patches = ['patch-Makefile.pre.in.diff', 'patch-Lib-cgi.py.diff',
'patch-Lib-distutils-dist.py.diff', 'patch-setup.py.diff',
'patch-configure-badcflags.diff', 'patch-configure-arch_only.diff',
'patch-64bit.diff', 'patch-pyconfig.h.in.diff',
'patch-Modules-posixmodule.c.diff']
if patches:
logger.info("Patching %s" % self.pkg.name)
for patch in patches:
s.check_call("patch -p0 < %s" % os.path.join(patch_dir, patch))
except:
logger.error("Failed to patch `%s`" % self.build_dir)
sys.exit(1)
def configure(self):
configure_option = ""
if is_macosx_snowleopard():
version = self.pkg.version
if is_python24(version):
configure_option = '--with-universal-archs="intel" MACOSX_DEPLOYMENT_TARGET=10.6 CPPFLAGS="-D__DARWIN_UNIX03"'
elif is_python25(version):
configure_option = '--with-universal-archs="intel" MACOSX_DEPLOYMENT_TARGET=10.6 CPPFLAGS="-D_DARWIN_C_SOURCE"'
elif is_python26(version):
configure_option = '--with-universal-archs="intel" MACOSX_DEPLOYMENT_TARGET=10.6'
s = Subprocess(log=self.logfile, shell=True, cwd=self.build_dir, print_cmd=False)
s.check_call("./configure --prefix=%s %s" % (self.install_dir, self.options.configure))
s.check_call("./configure --prefix=%s %s %s" % (self.install_dir, self.options.configure, configure_option))
def make(self):
s = Subprocess(log=self.logfile, shell=True, cwd=self.build_dir, print_cmd=False)
@@ -159,11 +209,12 @@ class PythonInstaller(object):
is_python3 = False
download_url = DISTRIBUTE_SETUP_DLSITE
filename = Link(download_url).filename
download_file = os.path.join(PATH_DISTS, filename)
dl = Downloader()
dl.download(filename, download_url, "%s/%s" % (PATH_DISTS, filename))
dl.download(filename, download_url, download_file)
install_dir = "%s/%s" % (PATH_PYTHONS, pkgname)
install_dir = os.path.join(PATH_PYTHONS, pkgname)
if is_python3:
if os.path.isfile("%s/bin/python3" % (install_dir)):
pyexec = "%s/bin/python3" % (install_dir)
@@ -173,7 +224,7 @@ class PythonInstaller(object):
logger.error("Python3 binary not found. `%s`" % (install_dir))
return
else:
pyexec = "%s/bin/python" % (install_dir)
pyexec = os.path.join(install_dir,"bin","python")
try:
s = Subprocess(log=self.logfile, shell=True, cwd=PATH_DISTS, print_cmd=False)
@@ -188,5 +239,3 @@ class PythonInstaller(object):