def install_setuptools(self): options = self.options pkgname = self.pkg.name if options.no_setuptools: logger.info("Skip installation setuptools.") return if re.match("^Python-3.*", pkgname): is_python3 = True else: 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, download_file) install_dir = os.path.join(PATH_PYTHONS, pkgname) path_python = os.path.join(install_dir,"bin","python") try: s = Subprocess(log=self.logfile, cwd=PATH_DISTS) logger.info("Installing distribute into %s" % install_dir) s.check_call("%s %s" % (path_python, filename)) if os.path.isfile("%s/bin/easy_install" % (install_dir)) and not is_python3: logger.info("Installing pip into %s" % install_dir) s.check_call("%s/bin/easy_install pip" % (install_dir)) except: logger.error("Failed to install setuptools. See %s/build.log to see why." % (ROOT)) logger.info("Skip install setuptools.")
def run_command_create(self, options, args): if not os.access(PATH_VENVS, os.W_OK): logger.error( "Can not create a virtual environment in %s.\nPermission denied." % PATH_VENVS) sys.exit(1) if not self._pkgname: logger.error( "Unknown python version: ( 'pythonbrew venv create <project> -p VERSION' )" ) sys.exit(1) virtualenv_options = [] if options.no_site_packages: virtualenv_options.append('--no-site-packages') for arg in args[1:]: target_dir = os.path.join(self._workon_home, arg) logger.info("Creating `%s` environment into %s" % (arg, self._workon_home)) # make command cmd = [self._py, self._venv, '-p', self._target_py] cmd.extend(virtualenv_options) cmd.append(target_dir) # create environment s = Subprocess(verbose=True) s.call(cmd)
def run_command_clone(self, options, args): if len(args) < 3: logger.error("Unrecognized command line argument: ( 'pythonbrew venv clone <source> <target>' )") sys.exit(1) if not os.access(PATH_VENVS, os.W_OK): logger.error("Can not clone a virtual environment in %s.\nPermission denied." % PATH_VENVS) sys.exit(1) if not self._pkgname: logger.error("Unknown python version: ( 'pythonbrew venv clone <source> <target> -p VERSION' )") sys.exit(1) source, target = args[1], args[2] source_dir = os.path.join(self._workon_home, source) target_dir = os.path.join(self._workon_home, target) if not os.path.isdir(source_dir): logger.error('%s does not exist.' % source_dir) sys.exit(1) if os.path.isdir(target_dir): logger.error('Can not overwrite %s.' % target_dir) sys.exit(1) logger.info("Cloning `%s` environment into `%s` on %s" % (source, target, self._workon_home)) # Copies source to target cmd = [self._py, self._venv_clone, source_dir, target_dir] s = Subprocess() s.call(cmd)
def patch(self): version = self.pkg.version try: s = Subprocess(log=self.logfile, cwd=self.build_dir) 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 install_setuptools(self): options = self.options pkgname = self.pkg.name if options.no_setuptools: logger.log("Skip installation of setuptools.") return 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, download_file) install_dir = os.path.join(PATH_PYTHONS, pkgname) path_python = os.path.join(install_dir,"bin","python") try: s = Subprocess(log=self.logfile, cwd=PATH_DISTS, verbose=self.options.verbose) logger.info("Installing distribute into %s" % install_dir) s.check_call([path_python, filename]) # installing pip easy_install = os.path.join(install_dir, 'bin', 'easy_install') if os.path.isfile(easy_install): logger.info("Installing pip into %s" % install_dir) s.check_call([easy_install, 'pip']) except: logger.error("Failed to install setuptools. See %s/build.log to see why." % (ROOT)) logger.log("Skip installation of setuptools.")
def make_install(self): 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 configure(self): s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose) 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 configure(self): s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose) 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 patch(self): version = self.pkg.version try: s = Subprocess(log=self.logfile, cwd=self.build_dir) patches = [] eds = {} if is_python24(version): patch_dir = PATH_PATCHES_MACOSX_PYTHON24 patches = ['patch-configure', 'patch-Makefile.pre.in', 'patch-Lib-cgi.py.diff', 'patch-Lib-site.py.diff', 'patch-setup.py.diff', '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', 'patch-gestaltmodule.c.diff'] elif is_python25(version): patch_dir = PATH_PATCHES_MACOSX_PYTHON25 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-gestaltmodule.c.diff'] eds = {'_localemodule.c.ed': 'Modules/_localemodule.c', 'locale.py.ed': 'Lib/locale.py'} elif is_python26(version): patch_dir = PATH_PATCHES_MACOSX_PYTHON26 patches = ['patch-Lib-cgi.py.diff', 'patch-Lib-distutils-dist.py.diff', 'patch-Mac-IDLE-Makefile.in.diff', 'patch-Mac-Makefile.in.diff', 'patch-Mac-PythonLauncher-Makefile.in.diff', 'patch-Mac-Tools-Doc-setup.py.diff', 'patch-setup.py-db46.diff', 'patch-Lib-ctypes-macholib-dyld.py.diff', 'patch-setup_no_tkinter.py.diff'] eds = {'_localemodule.c.ed': 'Modules/_localemodule.c', 'locale.py.ed': 'Lib/locale.py'} if patches or eds: logger.info("Patching %s" % self.pkg.name) for patch in patches: s.check_call("patch -p0 < %s" % os.path.join(patch_dir, patch)) for (ed, source) in eds.items(): ed = os.path.join(patch_dir, ed) s.check_call('ed - %s < %s' % (source, ed)) except: logger.error("Failed to patch `%s`" % self.build_dir) sys.exit(1)
def _update_pythonbrew(self, options, args): if options.master: version = 'master' elif options.develop: version = 'develop' else: version = get_stable_version() # check for version if not options.force and Version(version) <= VERSION: logger.info( "You are already running the installed latest version of pythonbrew." ) return download_url = get_pythonbrew_update_url(version) if not download_url: logger.error("`pythonbrew-%s` was not found in pypi." % version) sys.exit(1) headinfo = get_headerinfo_from_url(download_url) content_type = headinfo['content-type'] 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 download_file = os.path.join(PATH_DISTS, distname) try: d = Downloader() d.download(distname, download_url, download_file) except: logger.error("Failed to download. `%s`" % download_url) sys.exit(1) extract_dir = os.path.join(PATH_BUILD, filename) rm_r(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([ sys.executable, os.path.join(extract_dir, 'pythonbrew_install.py'), '--upgrade' ]) except: logger.error("Failed to update pythonbrew.") sys.exit(1) logger.info("The pythonbrew has been updated.")
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, cwd=self.build_dir) s.check_call("./configure --prefix=%s %s %s" % (self.install_dir, self.options.configure, configure_option))
def _do_patch(self): try: s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose) if self.patches: logger.info("Patching %s" % self.pkg.name) for patch in self.patches: if type(patch) is dict: for (ed, source) in patch.items(): s.shell('ed - %s < %s' % (source, ed)) else: s.shell("patch -p0 < %s" % patch) except: logger.error("Failed to patch `%s`.\n%s" % (self.build_dir, sys.exc_info()[1])) sys.exit(1)
def _update_pythonbrew(self, options, args): if options.master: version = "master" elif options.develop: version = "develop" else: version = get_stable_version() # check for version if not options.force and Version(version) <= VERSION: logger.info("You are already running the installed latest version of pythonbrew.") return download_url = get_pythonbrew_update_url(version) if not download_url: logger.error("`pythonbrew-%s` was not found in pypi." % version) sys.exit(1) headinfo = get_headerinfo_from_url(download_url) content_type = headinfo["content-type"] 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 download_file = os.path.join(PATH_DISTS, distname) try: d = Downloader() d.download(distname, download_url, download_file) except: logger.error("Failed to download. `%s`" % download_url) sys.exit(1) extract_dir = os.path.join(PATH_BUILD, filename) rm_r(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([sys.executable, os.path.join(extract_dir, "pythonbrew_install.py"), "--upgrade"]) except: logger.error("Failed to update pythonbrew.") sys.exit(1) logger.info("The pythonbrew has been updated.")
def _update_pythonbrew(self, options, args): # pythonbrew update if options.head: version = 'head' else: version = get_stable_version() # check for version if not options.force and version <= VERSION: logger.info("You are already running the installed latest version of pythonbrew.") return download_url = get_pythonbrew_update_url(version) if not download_url: logger.error("`%s` of pythonbrew not found." % version) 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) filename = "pythonbrew-%s" % version distname = "%s.tgz" % filename download_file = os.path.join(PATH_DISTS, distname) try: d = Downloader() d.download(distname, download_url, download_file) except: logger.error("Failed to download. `%s`" % download_url) sys.exit(1) extract_dir = os.path.join(PATH_BUILD, filename) rm_r(extract_dir) if not unpack_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)) except: logger.error("Failed to update pythonbrew.") sys.exit(1) logger.info("The pythonbrew has been updated.")
def make(self): s = Subprocess(log=self.logfile, cwd=self.build_dir) if self.options.force: s.check_call("make") else: s.check_call("make") s.check_call("make test")
def make(self): jobs = self.options.jobs make = ((jobs > 0 and 'make -j%s' % jobs) or 'make') s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose) s.check_call(make) if self.options.test: if self.options.force: # note: ignore tests failure error. s.call("make test") else: s.check_call("make test")
def run_command_create(self, options, args): if not os.access(PATH_VENVS, os.W_OK): logger.error("Can not create a virtual environment in %s.\nPermission denied." % PATH_VENVS) sys.exit(1) virtualenv_options = [] if options.no_site_packages: virtualenv_options.append('--no-site-packages') for arg in args[1:]: target_dir = os.path.join(self._workon_home, arg) logger.info("Creating `%s` environment into %s" % (arg, self._workon_home)) # make command cmd = [self._py, self._venv, '-p', self._target_py] cmd.extend(virtualenv_options) cmd.append(target_dir) # create environment s = Subprocess(verbose=True) s.call(cmd)
def make(self): jobs = self.options.jobs make = ((jobs > 0 and 'make -j%s' % jobs) or 'make') s = Subprocess(log=self.logfile, cwd=self.build_dir) if self.options.force: s.check_call(make) else: s.check_call(make) s.check_call("make test")
def install_setuptools(self): options = self.options pkgname = self.pkg.name if options.no_setuptools: logger.log("Skip installation of setuptools.") return 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, download_file) install_dir = os.path.join(PATH_PYTHONS, pkgname) path_python = os.path.join(install_dir, "bin", "python") try: s = Subprocess(log=self.logfile, cwd=PATH_DISTS, verbose=self.options.verbose) logger.info("Installing distribute into %s" % install_dir) s.check_call([path_python, filename]) # installing pip easy_install = os.path.join(install_dir, 'bin', 'easy_install') if os.path.isfile(easy_install): logger.info("Installing pip into %s" % install_dir) s.check_call([easy_install, 'pip']) except: logger.error( "Failed to install setuptools. See %s/build.log to see why." % (ROOT)) logger.log("Skip installation of setuptools.")
def make(self): jobs = self.options.jobs make = ((jobs > 0 and 'make -j%s' % jobs) or 'make') s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose) s.check_call(make) if not self.options.no_test: if self.options.force: # note: ignore tests failure error. s.call("make test") else: s.check_call("make test")
def _do_patch(self): try: s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose) if self.patches: logger.info("Patching %s" % self.pkg.name) for patch in self.patches: if type(patch) is dict: for (ed, source) in patch.items(): s.shell('ed - "%s" < "%s"' % (source, ed)) else: s.shell('patch -p0 < "%s"' % patch) except: logger.error("Failed to patch `%s`.\n%s" % (self.build_dir, sys.exc_info()[1])) sys.exit(1)
def configure(self): s = Subprocess(log=self.logfile, cwd=self.build_dir) s.check_call("./configure --prefix=%s %s %s" % (self.install_dir, self.options.configure, self.configure_options))