mirror of
https://github.com/kennethreitz-archive/python-build.git
synced 2026-06-05 23:30:18 +00:00
release 0.8
This commit is contained in:
@@ -3,17 +3,17 @@ from pythonbrew.basecommand import Command
|
||||
from pythonbrew.define import PATH_BUILD, PATH_DISTS
|
||||
from pythonbrew.util import rm_r
|
||||
|
||||
class CleanCommand(Command):
|
||||
name = "clean"
|
||||
class CleanupCommand(Command):
|
||||
name = "cleanup"
|
||||
usage = "%prog"
|
||||
summary = "Remove stale source folders and archives"
|
||||
|
||||
def run_command(self, options, args):
|
||||
self._clean(PATH_BUILD)
|
||||
self._clean(PATH_DISTS)
|
||||
self._cleanup(PATH_BUILD)
|
||||
self._cleanup(PATH_DISTS)
|
||||
|
||||
def _clean(self, root):
|
||||
def _cleanup(self, root):
|
||||
for dir in os.listdir(root):
|
||||
rm_r(os.path.join(root, dir))
|
||||
|
||||
CleanCommand()
|
||||
CleanupCommand()
|
||||
@@ -22,6 +22,6 @@ class HelpCommand(Command):
|
||||
for command in commands:
|
||||
logger.info(" %s: %s" % (command.name, command.summary))
|
||||
logger.info("\nFurther Instructions:")
|
||||
logger.info(" http://github.com/utahta/pythonbrew")
|
||||
logger.info(" https://github.com/utahta/pythonbrew")
|
||||
|
||||
HelpCommand()
|
||||
|
||||
@@ -2,7 +2,7 @@ from pythonbrew.basecommand import Command
|
||||
from pythonbrew.log import logger
|
||||
from pythonbrew.installer.pythoninstaller import PythonInstaller,\
|
||||
PythonInstallerMacOSX
|
||||
from pythonbrew.util import is_macosx_snowleopard
|
||||
from pythonbrew.util import is_macosx
|
||||
from pythonbrew.exceptions import UnknownVersionException,\
|
||||
AlreadyInstalledException, NotSupportedVersionException
|
||||
|
||||
@@ -18,7 +18,21 @@ class InstallCommand(Command):
|
||||
dest="force",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Force install of python.(skip make test)"
|
||||
help="Force installation of python."
|
||||
)
|
||||
self.parser.add_option(
|
||||
"-n", "--no-test",
|
||||
dest="no_test",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Skip `make test`."
|
||||
)
|
||||
self.parser.add_option(
|
||||
"-v", "--verbose",
|
||||
dest="verbose",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Display log information on the console."
|
||||
)
|
||||
self.parser.add_option(
|
||||
"-C", "--configure",
|
||||
@@ -28,11 +42,11 @@ class InstallCommand(Command):
|
||||
help="Options passed directly to configure."
|
||||
)
|
||||
self.parser.add_option(
|
||||
"-n", "--no-setuptools",
|
||||
"--no-setuptools",
|
||||
dest="no_setuptools",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Skip install of setuptools."
|
||||
help="Skip installation of setuptools."
|
||||
)
|
||||
self.parser.add_option(
|
||||
"--as",
|
||||
@@ -50,10 +64,10 @@ class InstallCommand(Command):
|
||||
|
||||
def run_command(self, options, args):
|
||||
if args:
|
||||
# Install pythons
|
||||
# installing python
|
||||
for arg in args:
|
||||
try:
|
||||
if is_macosx_snowleopard():
|
||||
if is_macosx():
|
||||
p = PythonInstallerMacOSX(arg, options)
|
||||
else:
|
||||
p = PythonInstaller(arg, options)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from pythonbrew.basecommand import Command
|
||||
from pythonbrew.define import PATH_PYTHONS
|
||||
from pythonbrew.util import Package
|
||||
from pythonbrew.log import logger
|
||||
from subprocess import Popen
|
||||
|
||||
class PyCommand(Command):
|
||||
name = "py"
|
||||
@@ -40,13 +40,11 @@ class PyCommand(Command):
|
||||
logger.info('*** %s ***' % d)
|
||||
path = os.path.join(PATH_PYTHONS, d, 'bin', args[0])
|
||||
if os.path.isfile(path) and os.access(path, os.X_OK):
|
||||
p = Popen([path] + args[1:])
|
||||
p.wait()
|
||||
subprocess.call([path] + args[1:])
|
||||
else:
|
||||
path = os.path.join(PATH_PYTHONS, d, 'bin', 'python')
|
||||
if os.path.isfile(path) and os.access(path, os.X_OK):
|
||||
p = Popen([path] + args)
|
||||
p.wait()
|
||||
subprocess.call([path] + args)
|
||||
else:
|
||||
logger.info('%s: No such file or directory.' % path)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from pythonbrew.define import PATH_DISTS, VERSION, ROOT,\
|
||||
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, unpack_downloadfile, Link, is_gzip, Subprocess
|
||||
from pythonbrew.util import rm_r, extract_downloadfile, Link, is_gzip, Subprocess
|
||||
|
||||
class UpdateCommand(Command):
|
||||
name = "update"
|
||||
@@ -16,11 +16,18 @@ class UpdateCommand(Command):
|
||||
def __init__(self):
|
||||
super(UpdateCommand, self).__init__()
|
||||
self.parser.add_option(
|
||||
'--head',
|
||||
dest='head',
|
||||
'--master',
|
||||
dest='master',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Update the pythonbrew to the github version.'
|
||||
help='Update the pythonbrew to the `master` branch on github.'
|
||||
)
|
||||
self.parser.add_option(
|
||||
'--develop',
|
||||
dest='develop',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Update the pythonbrew to the `develop` branch on github.'
|
||||
)
|
||||
self.parser.add_option(
|
||||
'--config',
|
||||
@@ -61,9 +68,10 @@ class UpdateCommand(Command):
|
||||
logger.info("The config.cfg has been updated.")
|
||||
|
||||
def _update_pythonbrew(self, options, args):
|
||||
# pythonbrew update
|
||||
if options.head:
|
||||
version = 'head'
|
||||
if options.master:
|
||||
version = 'master'
|
||||
elif options.develop:
|
||||
version = 'develop'
|
||||
else:
|
||||
version = get_stable_version()
|
||||
# check for version
|
||||
@@ -77,10 +85,10 @@ class UpdateCommand(Command):
|
||||
sys.exit(1)
|
||||
headinfo = get_headerinfo_from_url(download_url)
|
||||
content_type = headinfo['content-type']
|
||||
# head is only for gzip.
|
||||
if not options.head and not is_gzip(content_type, Link(download_url).filename):
|
||||
logger.error("Invalid content-type: `%s`" % content_type)
|
||||
sys.exit(1)
|
||||
if not options.master and not options.develop:
|
||||
if not is_gzip(content_type, Link(download_url).filename):
|
||||
logger.error("content type should be gzip. content-type:`%s`" % content_type)
|
||||
sys.exit(1)
|
||||
|
||||
filename = "pythonbrew-%s" % version
|
||||
distname = "%s.tgz" % filename
|
||||
@@ -94,13 +102,13 @@ class UpdateCommand(Command):
|
||||
|
||||
extract_dir = os.path.join(PATH_BUILD, filename)
|
||||
rm_r(extract_dir)
|
||||
if not unpack_downloadfile(content_type, download_file, extract_dir):
|
||||
if not extract_downloadfile(content_type, download_file, extract_dir):
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
logger.info("Installing %s into %s" % (extract_dir, ROOT))
|
||||
s = Subprocess()
|
||||
s.check_call('%s %s/pythonbrew_install.py --upgrade' % (sys.executable, extract_dir))
|
||||
s.check_call([sys.executable, os.path.join(extract_dir,'pythonbrew_install.py'), '--upgrade'])
|
||||
except:
|
||||
logger.error("Failed to update pythonbrew.")
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user