def _build_from_spec(self, instance, spec_filename, patches=None):
        pkg_dir = instance.get_option('app_dir')
        if sh.isfile(sh.joinpths(pkg_dir, "setup.py")):
            self._write_python_tarball(instance, pkg_dir, ENSURE_NOT_MISSING)
        else:
            self._write_git_tarball(instance, pkg_dir, spec_filename)
        self._copy_sources(instance)
        if patches:
            self._copy_patches(patches)
        cmdline = [self.specprint_executable]
        cmdline.extend(['-f', spec_filename])
        spec_details = json.loads(sh.execute(cmdline)[0])
        rpm_requires = []
        for k in ('requires', 'requirenevrs'):
            try:
                rpm_requires.extend(spec_details['headers'][k])
            except (__HOLE__, TypeError):
                pass
        if rpm_requires:
            buff = six.StringIO()
            buff.write("# %s\n" % instance.name)
            if rpm_requires:
                for req in rpm_requires:
                    buff.write("%s\n" % req)
                buff.write("\n")
            sh.append_file(self.rpm_build_requires_filename, buff.getvalue())
        self._copy_startup_scripts(instance, spec_details)
        self._copy_systemd_scripts(instance, spec_details)
        cmdline = [
            self.rpmbuild_executable,
            "-bs",
            "--define", "_topdir %s" % self.rpmbuild_dir,
            spec_filename,
        ]
        out_filename = sh.joinpths(self.log_dir, "rpmbuild-%s.log" % instance.name)
        sh.execute_save_output(cmdline, out_filename)
dataset/ETHPy150Open openstack/anvil/anvil/packaging/yum.py/YumDependencyHandler._build_from_spec