예제 #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 download(self):
     if os.path.isfile(self.download_file) and sha256(self.download_file) == self.expected_sha256:
         logger.info("Use the previously fetched %s" % (self.download_file))
     else:
         base_url = Link(self.download_url).base_url
         logger.info("Downloading %s as %s" % (base_url, self.download_file))
         try:
             Downloader.fetch(self.download_url, self.download_file, self.expected_sha256)
         except DownloadError:
             logger.error("Failed to download.\n%s" % (sys.exc_info()[1]))
             raise
예제 #3
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 = []
예제 #4
0
 def download(self):
     if os.path.isfile(self.download_file):
         logger.info("Use the previously fetched %s" % (self.download_file))
     else:
         base_url = Link(self.download_url).base_url
         logger.info("Downloading %s as %s" %
                     (base_url, self.download_file))
         try:
             Downloader.fetch(self.download_url, self.download_file)
         except DownloadError:
             unlink(self.download_file)
             logger.error("Failed to download.\n%s" % (sys.exc_info()[1]))
             sys.exit(1)