release 0.10

This commit is contained in:
utahta
2011-08-08 02:51:43 +09:00
parent 7bdb546fa4
commit 770715b536
30 changed files with 482 additions and 255 deletions
+30 -4
View File
@@ -3,10 +3,10 @@ from pythonbrew.log import logger
from pythonbrew.define import INSTALLER_ROOT, ROOT, PATH_ETC
def install_pythonbrew():
PythonbrewInstaller().install(INSTALLER_ROOT)
# pythonbrew is only for bash
PythonbrewInstaller.install(INSTALLER_ROOT)
# for bash
shrc = yourshrc = "bashrc"
logger.info("""
logger.log("""
Well-done! Congratulations!
The pythonbrew is installed as:
@@ -33,4 +33,30 @@ Enjoy pythonbrew at %(ROOT)s!!
""" % {'ROOT':ROOT, 'yourshrc':yourshrc, 'shrc':shrc, 'PATH_ETC':PATH_ETC})
def upgrade_pythonbrew():
PythonbrewInstaller().install(INSTALLER_ROOT)
PythonbrewInstaller.install(INSTALLER_ROOT)
def systemwide_pythonbrew():
PythonbrewInstaller.install(INSTALLER_ROOT)
PythonbrewInstaller.systemwide_install()
logger.log("""
Well-done! Congratulations!
The pythonbrew is installed as:
%(ROOT)s
After that, exit this shell, start a new one, and install some fresh
pythons:
pythonbrew install 2.7.2
pythonbrew install 3.2
For further instructions, run:
pythonbrew help
The default help messages will popup and tell you what to do!
Enjoy pythonbrew at %(ROOT)s!!
""" % {'ROOT':ROOT})
+46 -9
View File
@@ -6,15 +6,17 @@ from pythonbrew.util import makedirs, rm_r
from pythonbrew.define import PATH_BUILD, PATH_BIN, PATH_DISTS, PATH_PYTHONS,\
PATH_ETC, PATH_SCRIPTS, PATH_SCRIPTS_PYTHONBREW,\
PATH_SCRIPTS_PYTHONBREW_COMMANDS, PATH_BIN_PYTHONBREW,\
ROOT, PATH_LOG, PATH_PATCHES, PATH_ETC_CONFIG,\
PATH_SCRIPTS_PYTHONBREW_INSTALLER, PATH_VENVS
PATH_LOG, PATH_PATCHES, PATH_ETC_CONFIG,\
PATH_SCRIPTS_PYTHONBREW_INSTALLER, PATH_VENVS, PATH_HOME_ETC, ROOT
import stat
import time
class PythonbrewInstaller(object):
"""pythonbrew installer:
"""
def install(self, installer_root):
@staticmethod
def install(installer_root):
# create directories
makedirs(PATH_PYTHONS)
makedirs(PATH_BUILD)
@@ -23,6 +25,7 @@ class PythonbrewInstaller(object):
makedirs(PATH_BIN)
makedirs(PATH_LOG)
makedirs(PATH_VENVS)
makedirs(PATH_HOME_ETC)
# create script directories
rm_r(PATH_SCRIPTS)
@@ -61,12 +64,46 @@ if __name__ == "__main__":
os.chmod(PATH_BIN_PYTHONBREW, stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR|stat.S_IRGRP|stat.S_IXGRP|stat.S_IROTH|stat.S_IXOTH)
# create a bashrc for pythonbrew
fp = open(os.path.join(PATH_ETC,'bashrc'), 'w')
for line in open(os.path.join(installer_root,'etc','bashrc')):
line = line.replace('@ROOT@', ROOT)
fp.write(line)
fp.close()
shutil.copy(os.path.join(installer_root,'etc','bashrc'), os.path.join(PATH_ETC,'bashrc'))
# copy config.cfg
shutil.copy(os.path.join(installer_root,'etc','config.cfg'), PATH_ETC_CONFIG)
@staticmethod
def systemwide_install():
profile = """\
#begin-pythonbrew
if [ -n "${BASH_VERSION:-}" -o -n "${ZSH_VERSION:-}" ] ; then
export PYTHONBREW_ROOT=%(root)s
source "${PYTHONBREW_ROOT}/etc/bashrc"
fi
#end-pythonbrew
""" % {'root': ROOT}
if os.path.isdir('/etc/profile.d'):
fp = open('/etc/profile.d/pythonbrew.sh', 'w')
fp.write(profile)
fp.close()
elif os.path.isfile('/etc/profile'):
# create backup
shutil.copy('/etc/profile', '/tmp/profile.pythonbrew.%s' % int(time.time()))
output = []
is_copy = True
fp = open('/etc/profile', 'r')
for line in fp:
if line.startswith('#begin-pythonbrew'):
is_copy = False
continue
elif line.startswith('#end-pythonbrew'):
is_copy = True
continue
if is_copy:
output.append(line)
fp.close()
output.append(profile)
fp = open('/etc/profile', 'w')
fp.write(''.join(output))
fp.close()
+8 -8
View File
@@ -38,7 +38,7 @@ class PythonInstaller(object):
pkg = Package(name, options.alias)
self.download_url = get_python_version_url(pkg.version)
if not self.download_url:
logger.info("Unknown python version: `%s`" % pkg.name)
logger.error("Unknown python version: `%s`" % pkg.name)
raise UnknownVersionException
filename = Link(self.download_url).filename
self.pkg = pkg
@@ -83,11 +83,11 @@ 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.info(" pythonbrew install --force %s" % self.pkg.version)
logger.log(" pythonbrew install --force %s" % self.pkg.version)
sys.exit(1)
self.symlink()
self.install_setuptools()
logger.info("Installed %(pkgname)s successfully. Run the following command to switch to %(pkgname)s."
logger.info("\nInstalled %(pkgname)s successfully. Run the following command to switch to %(pkgname)s."
% {"pkgname":self.pkg.name})
logger.info(" pythonbrew switch %s" % self.pkg.alias)
@@ -107,7 +107,7 @@ class PythonInstaller(object):
dl.download(base_url, self.download_url, self.download_file)
except:
unlink(self.download_file)
logger.info("\nInterrupt to abort. `%s`" % (self.download_url))
logger.error("Failed to download.\n%s" % (sys.exc_info()[1]))
sys.exit(1)
# extracting
if not extract_downloadfile(self.content_type, self.download_file, self.build_dir):
@@ -154,7 +154,7 @@ class PythonInstaller(object):
else:
s.shell("patch -p0 < %s" % patch)
except:
logger.error("Failed to patch `%s`" % self.build_dir)
logger.error("Failed to patch `%s`.\n%s" % (self.build_dir, sys.exc_info()[1]))
sys.exit(1)
def _add_patches_to_list(self, patch_dir, patch_files):
@@ -206,7 +206,7 @@ class PythonInstaller(object):
options = self.options
pkgname = self.pkg.name
if options.no_setuptools:
logger.info("Skip installation of setuptools.")
logger.log("Skip installation of setuptools.")
return
download_url = DISTRIBUTE_SETUP_DLSITE
filename = Link(download_url).filename
@@ -228,7 +228,7 @@ class PythonInstaller(object):
s.check_call([easy_install, 'pip'])
except:
logger.error("Failed to install setuptools. See %s/build.log to see why." % (ROOT))
logger.info("Skip installation of setuptools.")
logger.log("Skip installation of setuptools.")
class PythonInstallerMacOSX(PythonInstaller):
"""Python installer for MacOSX
@@ -239,7 +239,7 @@ class PythonInstallerMacOSX(PythonInstaller):
# check for version
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)
logger.error("`%s` is not supported on MacOSX Snow Leopard" % self.pkg.name)
raise NotSupportedVersionException
# set configure options
target = get_macosx_deployment_target()