Пример #1
0
    def __init__(self, version, options):
        if options.file is not None:
            if not (is_archive_file(options.file)
                    and os.path.isfile(options.file)):
                logger.error('invalid file specified: %s' % options.file)
                raise RuntimeError
            self.download_url = path_to_fileurl(options.file)
        elif options.url is not None:
            if not is_url(options.url):
                logger.error('invalid URL specified: %s' % options.url)
                raise RuntimeError
            self.download_url = options.url
        else:
            if version not in self.supported_versions:
                logger.error(
                    "Unsupported Python version: `%s`, you may install it anyway by supplying the download or file URL"
                    % version)
                raise UnknownVersionException
            self.download_url = self.get_version_url(version)
        self.pkg = Package(version, options.type)
        self.install_dir = os.path.join(PATH_PYTHONS, self.pkg.name)
        self.build_dir = os.path.join(PATH_BUILD, self.pkg.name)
        filename = Link(self.download_url).filename
        self.download_file = os.path.join(PATH_DISTS, filename)

        self.options = options
        self.logfile = os.path.join(PATH_LOG, 'build.log')
        self.patches = []
        self.configure_options = []
Пример #2
0
    def run_command(self, options, args):
        if not args or len(args) > 1:
            self.parser.print_help()
            return

        pkg = Package(args[0], options.type)
        pkgname = pkg.name
        if not is_installed(pkg):
            logger.error("`%s` is not installed." % pkgname)
            return
        logger.log(os.path.join(PATH_PYTHONS, pkgname, 'bin', 'python'))
Пример #3
0
 def run_command(self, options, args):
     if args:
         # Uninstall pythons
         for arg in args:
             pkg = Package(arg, options.type)
             pkgname = pkg.name
             if not is_installed(pkg):
                 logger.error("`%s` is not installed." % pkgname)
                 continue
             rm_r(os.path.join(PATH_PYTHONS, pkgname))
     else:
         self.parser.print_help()
Пример #4
0
    def __init__(self, version, options):
        # create directories
        makedirs(PATH_BUILD)
        makedirs(PATH_DISTS)
        makedirs(PATH_LOG)

        if options.file is not None:
            if not (is_archive_file(options.file)
                    and os.path.isfile(options.file)):
                logger.error('invalid file specified: %s' % options.file)
                raise RuntimeError
            self.download_url = path_to_fileurl(options.file)
        elif options.url is not None:
            if not is_url(options.url):
                logger.error('invalid URL specified: %s' % options.url)
                raise RuntimeError
            self.download_url = options.url
        else:
            self.download_url = self.get_version_url(version)
            if version not in self.supported_versions:
                logger.warning(
                    "Unsupported Python version: `%s`, trying with the following URL anyway: %s"
                    % (version, self.download_url))

        self.pkg = Package(version, options.type)
        if options.external_path:
            if not os.path.isabs(options.external_path):
                options.external_path = os.path.join(
                    os.path.abspath(os.path.curdir), options.external_path)
            self.install_dir = os.path.join(options.external_path,
                                            self.pkg.name)
        else:
            self.install_dir = os.path.join(PATH_PYTHONS, self.pkg.name)
        self.build_dir = os.path.join(PATH_BUILD, self.pkg.name)
        filename = Link(self.download_url).filename
        self.download_file = os.path.join(PATH_DISTS, filename)

        # cleanup
        if os.path.isdir(self.build_dir):
            shutil.rmtree(self.build_dir)

        if os.path.isdir(self.install_dir):
            if options.reinstall:
                shutil.rmtree(self.install_dir)
            else:
                raise AlreadyInstalledError("You have already installed `%s`" %
                                            self.pkg.name)

        self.options = options
        self.logfile = os.path.join(PATH_LOG, 'build.log')
        self.patches = []
        self.configure_options = []
Пример #5
0
    def run_command(self, options, args):
        if not args or len(args) > 1:
            self.parser.print_help()
            sys.exit(1)

        pkg = Package(args[0], options.type)
        pkgname = pkg.name
        if not is_installed(pkg):
            logger.error("`%s` is not installed." % pkgname)
            sys.exit(1)
        for bin in ('python3', 'python', 'pypy3', 'pypy'):
            path = os.path.join(PATH_PYTHONS, pkgname, 'bin', bin)
            if os.path.exists(path):
                break
        else:
            # fallback
            path = os.path.join(PATH_PYTHONS, pkgname, 'bin', 'python')
        logger.log(path)