def BuildLayer()

in ftl/python/layer_builder.py [0:0]


    def BuildLayer(self):
        cached_img = None
        if self._cache:
            with ftl_util.Timing('checking_cached_requirements.txt_layer'):
                key = self.GetCacheKey()
                cached_img = self._cache.Get(key)
                self._log_cache_result(False if cached_img is None else True)
        if cached_img:
            self.SetImage(cached_img)
        else:
            python_util.setup_virtualenv(self._virtualenv_dir,
                                         self._virtualenv_cmd,
                                         self._python_cmd,
                                         self._venv_cmd)

            pkg_descriptor = ftl_util.descriptor_parser(
                self._descriptor_files, self._ctx)
            self._pip_download_wheels(pkg_descriptor)
            whls = self._resolve_whls()
            pkg_dirs = [self._whl_to_fslayer(whl) for whl in whls]

            req_txt_imgs = []
            with ftl_util.Timing('uploading_all_package_layers'):
                with concurrent.futures.ThreadPoolExecutor(
                        max_workers=constants.THREADS) as executor:
                    future_to_params = {
                        executor.submit(self._build_pkg, whl_pkg_dir,
                                        req_txt_imgs): whl_pkg_dir
                        for whl_pkg_dir in pkg_dirs
                    }
                    for future in concurrent.futures.as_completed(
                            future_to_params):
                        future.result()

            req_txt_image = ftl_util.AppendLayersIntoImage(req_txt_imgs)

            if req_txt_image:
                self.SetImage(req_txt_image)

                if self._cache:
                    with ftl_util.Timing('uploading_requirements.txt_pkg_lyr'):
                        self._cache.Set(self.GetCacheKey(), self.GetImage())