Permalink
Browse files

v1.1

  • Loading branch information...
1 parent e794348 commit ea7cb63494f146dceea20f4a6c496c842f39b462 @utahta committed Aug 29, 2011
View
@@ -9,3 +9,4 @@ pythonbrew.egg-info
dist
__pycache__
*.swp
+.idea
View
@@ -1,3 +1,6 @@
+* 1.1
+ - Added --framework, --universal and --static options to install command.
+
* 1.0
- Added systemwide install support. (issue #31)
- Fixed issue #41 Handle venv binary with the symlink command.
View
@@ -173,6 +173,11 @@ See more details below
Changelog
=========
+1.1 (2011-08-29)
+----------------
+
+- Added --framework, --universal and --static options to install command.
+
1.0 (2011-08-08)
----------------
@@ -3,8 +3,6 @@
from pythonbrew.installer.pythoninstaller import PythonInstaller,\
PythonInstallerMacOSX
from pythonbrew.util import is_macosx
-from pythonbrew.exceptions import UnknownVersionException,\
- AlreadyInstalledException, NotSupportedVersionException
class InstallCommand(Command):
name = "install"
@@ -61,7 +59,28 @@ def __init__(self):
default=0,
help="Enable parallel make."
)
-
+ self.parser.add_option(
+ "--framework",
+ dest="framework",
+ action="store_true",
+ default=False,
+ help="Build (MacOSX|Darwin) framework."
+ )
+ self.parser.add_option(
+ "--universal",
+ dest="universal",
+ action="store_true",
+ default=False,
+ help="Build for both 32 & 64 bit Intel."
+ )
+ self.parser.add_option(
+ "--static",
+ dest="static",
+ action="store_true",
+ default=False,
+ help="Build static libraries."
+ )
+
def run_command(self, options, args):
if not args:
self.parser.print_help()
@@ -74,11 +93,7 @@ def run_command(self, options, args):
else:
p = PythonInstaller(arg, options)
p.install()
- except UnknownVersionException:
+ except:
continue
- except AlreadyInstalledException:
- continue
- except NotSupportedVersionException:
- continue
-
+
InstallCommand()
@@ -6,7 +6,7 @@
from pythonbrew.log import logger
from pythonbrew.downloader import Downloader, get_pythonbrew_update_url,\
get_stable_version, get_headerinfo_from_url
-from pythonbrew.util import rm_r, extract_downloadfile, Link, is_gzip, Subprocess
+from pythonbrew.util import rm_r, extract_downloadfile, Link, is_gzip, Subprocess, Version
class UpdateCommand(Command):
name = "update"
@@ -75,7 +75,7 @@ def _update_pythonbrew(self, options, args):
else:
version = get_stable_version()
# check for version
- if not options.force and version <= VERSION:
+ if not options.force and Version(version) <= VERSION:
logger.info("You are already running the installed latest version of pythonbrew.")
return
View
@@ -6,7 +6,7 @@
import configparser as ConfigParser
# pythonbrew version
-VERSION = "1.0"
+VERSION = "1.1"
# pythonbrew installer root path
INSTALLER_ROOT = os.path.dirname(os.path.abspath(__file__))
@@ -181,5 +181,7 @@ latest = True
[Python-3.2]
url = http://www.python.org/ftp/python/3.2/Python-3.2.tgz
-latest = True
+[Python-3.2.1]
+url = http://www.python.org/ftp/python/3.2.1/Python-3.2.1.tgz
+latest = True
@@ -2,12 +2,13 @@
import sys
import shutil
import mimetypes
+import re
from pythonbrew.util import makedirs, symlink, Package, is_url, Link,\
unlink, is_html, Subprocess, rm_r,\
is_python25, is_python24, is_python26, is_python27,\
extract_downloadfile, is_archive_file, path_to_fileurl, is_file,\
fileurl_to_path, is_python30, is_python31, is_python32,\
- get_macosx_deployment_target
+ get_macosx_deployment_target, Version
from pythonbrew.define import PATH_BUILD, PATH_DISTS, PATH_PYTHONS,\
ROOT, PATH_LOG, DISTRIBUTE_SETUP_DLSITE,\
PATH_PATCHES_MACOSX_PYTHON25, PATH_PATCHES_MACOSX_PYTHON24,\
@@ -16,7 +17,7 @@
get_headerinfo_from_url
from pythonbrew.log import logger
from pythonbrew.exceptions import UnknownVersionException,\
- AlreadyInstalledException, NotSupportedVersionException
+ NotSupportedVersionException
class PythonInstaller(object):
"""Python installer
@@ -45,11 +46,21 @@ def __init__(self, arg, options):
self.install_dir = os.path.join(PATH_PYTHONS, pkg.name)
self.build_dir = os.path.join(PATH_BUILD, pkg.name)
self.download_file = os.path.join(PATH_DISTS, filename)
-
+
+ self.options = options
+ self.logfile = os.path.join(PATH_LOG, 'build.log')
+ self.patches = []
+
+ if Version(self.pkg.version) >= '3.1':
+ self.configure_options = ['--with-computed-gotos']
+ else:
+ self.configure_options = []
+
+ def install(self):
# cleanup
if os.path.isdir(self.build_dir):
shutil.rmtree(self.build_dir)
-
+
# get content type.
if is_file(self.download_url):
path = fileurl_to_path(self.download_url)
@@ -61,16 +72,11 @@ def __init__(self, arg, options):
# note: maybe got 404 or 503 http status code.
logger.error("Invalid content-type: `%s`" % self.content_type)
return
-
- self.options = options
- self.logfile = os.path.join(PATH_LOG, 'build.log')
- self.configure_options = ''
- self.patches = []
- def install(self):
if os.path.isdir(self.install_dir):
logger.info("You are already installed `%s`" % self.pkg.name)
- raise AlreadyInstalledException
+ return
+
self.download_and_extract()
logger.info("\nThis could take a while. You can run the following command on another shell to track the status:")
logger.info(" tail -f %s\n" % self.logfile)
@@ -114,7 +120,7 @@ def download_and_extract(self):
sys.exit(1)
def patch(self):
- version = self.pkg.version
+ version = Version(self.pkg.version)
# for ubuntu 11.04(Natty)
if is_python24(version):
patch_dir = os.path.join(PATH_PATCHES_ALL, "python24")
@@ -170,7 +176,10 @@ def _add_patches_to_list(self, patch_dir, patch_files):
def configure(self):
s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
- s.check_call("./configure --prefix=%s %s %s" % (self.install_dir, self.options.configure, self.configure_options))
+ cmd = "./configure --prefix=%s %s %s" % (self.install_dir, self.options.configure, ' '.join(self.configure_options))
+ if self.options.verbose:
+ logger.log(cmd)
+ s.check_call(cmd)
def make(self):
jobs = self.options.jobs
@@ -185,22 +194,35 @@ def make(self):
s.check_call("make test")
def make_install(self):
- version = self.pkg.version
+ version = Version(self.pkg.version)
if version == "1.5.2" or version == "1.6.1":
makedirs(self.install_dir)
s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
s.check_call("make install")
def symlink(self):
install_dir = os.path.realpath(self.install_dir)
+ if self.options.framework:
+ # create symlink bin -> /path/to/Frameworks/Python.framework/Versions/?.?/bin
+ bin_dir = os.path.join(install_dir, 'bin')
+ if os.path.exists(bin_dir):
+ rm_r(bin_dir)
+ m = re.match(r'\d\.\d', self.pkg.version)
+ if m:
+ version = m.group(0)
+ symlink(os.path.join(install_dir,'Frameworks','Python.framework','Versions',version,'bin'),
+ os.path.join(bin_dir))
+
path_python = os.path.join(install_dir,'bin','python')
if not os.path.isfile(path_python):
- path_python3 = os.path.join(install_dir,'bin','python3')
- path_python3_0 = os.path.join(install_dir,'bin','python3.0')
- if os.path.isfile(path_python3):
- symlink(path_python3, path_python)
- elif os.path.isfile(path_python3_0):
- symlink(path_python3_0, path_python)
+ src = None
+ for d in os.listdir(os.path.join(install_dir,'bin')):
+ if re.match(r'python\d\.\d', d):
+ src = d
+ break
+ if src:
+ path_src = os.path.join(install_dir,'bin',src)
+ symlink(path_src, path_python)
def install_setuptools(self):
options = self.options
@@ -237,22 +259,34 @@ def __init__(self, arg, options):
super(PythonInstallerMacOSX, self).__init__(arg, options)
# check for version
- version = self.pkg.version
+ version = Version(self.pkg.version)
if version < '2.6' and (version != '2.4.6' and version < '2.5.5'):
logger.error("`%s` is not supported on MacOSX Snow Leopard" % self.pkg.name)
raise NotSupportedVersionException
# set configure options
target = get_macosx_deployment_target()
if target:
- self.configure_options = 'MACOSX_DEPLOYMENT_TARGET=%s' % target
+ self.configure_options.append('MACOSX_DEPLOYMENT_TARGET=%s' % target)
+
+ # set build options
+ if options.framework and options.static:
+ logger.error("Can't specify both framework and static.")
+ raise Exception
+ if options.framework:
+ self.configure_options.append('--enable-framework=%s' % os.path.join(self.install_dir, 'Frameworks'))
+ elif not options.static:
+ self.configure_options.append('--enable-shared')
+ if options.universal:
+ self.configure_options.append('--enable-universalsdk=/')
+ self.configure_options.append('--with-universal-archs=intel')
# note: skip `make test` to avoid hanging test_threading.
if is_python25(version) or is_python24(version):
self.options.no_test = True
def patch(self):
# note: want an interface to the source patching functionality. like a patchperl.
- version = self.pkg.version
+ version = Version(self.pkg.version)
if is_python24(version):
patch_dir = PATH_PATCHES_MACOSX_PYTHON24
self._add_patches_to_list(patch_dir, ['patch-configure', 'patch-Makefile.pre.in',
Oops, something went wrong.

0 comments on commit ea7cb63

Please sign in to comment.