Exemplo n.º 1
0
    def __init__(self, arg, options):
        if is_archive_file(arg):
            name = path_to_fileurl(arg)
        elif os.path.isdir(arg):
            name = path_to_fileurl(arg)
        else:
            name = arg

        if is_url(name):
            self.download_url = name
            filename = Link(self.download_url).filename
            pkg = Package(filename, options.alias)
        else:
            pkg = Package(name, options.alias)
            self.download_url = get_python_version_url(pkg.version)
            if not self.download_url:
                logger.error("Unknown python version: `%s`" % pkg.name)
                raise UnknownVersionException
            filename = Link(self.download_url).filename
        self.pkg = pkg
        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 = []
Exemplo n.º 2
0
    def __init__(self, arg, options):
        super(PythonInstallerMacOSX, self).__init__(arg, options)

        # check for 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.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.test = False
Exemplo n.º 3
0
 def patch(self):
     version = Version(self.pkg.version)
     # for ubuntu 11.04(Natty)
     if is_python24(version):
         patch_dir = os.path.join(PATH_PATCHES_ALL, "python24")
         self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python25(version):
         patch_dir = os.path.join(PATH_PATCHES_ALL, "python25")
         self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python26(version):
         if version < '2.6.6':
             patch_dir = os.path.join(PATH_PATCHES_ALL, "python26")
             self._add_patches_to_list(
                 patch_dir, ['patch-setup.py-for-2.6.5-and-earlier.diff'])
         else:
             patch_dir = os.path.join(PATH_PATCHES_ALL, "common")
             self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python27(version):
         if version < '2.7.2':
             patch_dir = os.path.join(PATH_PATCHES_ALL, "common")
             self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python30(version):
         patch_dir = os.path.join(PATH_PATCHES_ALL, "python30")
         self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python31(version):
         if version < '3.1.4':
             patch_dir = os.path.join(PATH_PATCHES_ALL, "common")
             self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python32(version):
         if version == '3.2':
             patch_dir = os.path.join(PATH_PATCHES_ALL, "python32")
             self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     self._do_patch()
Exemplo n.º 4
0
 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")
Exemplo n.º 5
0
    def patch(self):
        # note: want an interface to the source patching functionality. like a patchperl.
        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',
                '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
            self._add_patches_to_list(patch_dir, [
                '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-configure-no-posix-c-source.diff', 'patch-64bit.diff',
                'patch-pyconfig.h.in.diff', 'patch-gestaltmodule.c.diff', {
                    '_localemodule.c.ed': 'Modules/_localemodule.c'
                }, {
                    'locale.py.ed': 'Lib/locale.py'
                }
            ])
        elif is_python26(version):
            patch_dir = PATH_PATCHES_MACOSX_PYTHON26
            self._add_patches_to_list(patch_dir, [
                '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', {
                    '_localemodule.c.ed': 'Modules/_localemodule.c'
                }, {
                    'locale.py.ed': 'Lib/locale.py'
                }
            ])
        elif is_python27(version):
            if version < '2.7.4':
                patch_dir = PATH_PATCHES_MACOSX_PYTHON27
                self._add_patches_to_list(patch_dir,
                                          ['patch-Modules-posixmodule.diff'])

        self._do_patch()
Exemplo n.º 6
0
 def patch(self):
     version = Version(self.pkg.version)
     # for ubuntu 11.04(Natty)
     if is_python24(version):
         patch_dir = os.path.join(PATH_PATCHES_ALL, "python24")
         self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python25(version):
         patch_dir = os.path.join(PATH_PATCHES_ALL, "python25")
         self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python26(version):
         if version < '2.6.6':
             patch_dir = os.path.join(PATH_PATCHES_ALL, "python26")
             if version < '2.6.3':
                 self._add_patches_to_list(
                     patch_dir,
                     ['patch-Makefile.pre.in-for-2.6.2-and-earlier.diff'])
             self._add_patches_to_list(
                 patch_dir, ['patch-setup.py-for-2.6.5-and-earlier.diff'])
             self._add_patches_to_list(
                 patch_dir,
                 ['patch-_ssl.c-for-ubuntu-oneiric-and-later.diff'])
         else:
             patch_dir = os.path.join(PATH_PATCHES_ALL, "common")
             self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python27(version):
         if version < '2.7.2':
             patch_dir = os.path.join(PATH_PATCHES_ALL, "common")
             self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
         if version == '2.7.3':
             patch_dir = os.path.join(PATH_PATCHES_ALL, "python27")
             self._add_patches_to_list(
                 patch_dir, ['patch-Modules-_sqlite-connection.c.diff'])
         if version == '2.7.4':
             patch_dir = os.path.join(PATH_PATCHES_ALL, "python27")
             self._add_patches_to_list(
                 patch_dir, ['patch-Modules-_sqlite-for-2.7.4.diff'])
     elif is_python30(version):
         patch_dir = os.path.join(PATH_PATCHES_ALL, "python30")
         self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python31(version):
         if version < '3.1.4':
             patch_dir = os.path.join(PATH_PATCHES_ALL, "common")
             self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python32(version):
         if version == '3.2':
             patch_dir = os.path.join(PATH_PATCHES_ALL, "python32")
             self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
     elif is_python34(version):
         if version == '3.4.4':
             patch_dir = os.path.join(PATH_PATCHES_ALL, "python34")
             self._add_patches_to_list(patch_dir,
                                       ['patch-Modules-Setup.dist.diff'])
     self._do_patch()
Exemplo n.º 7
0
    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.")