Python 停止rpmbuild重新写入需要

Python 停止rpmbuild重新写入需要,python,rpm,rhel,rpmbuild,Python,Rpm,Rhel,Rpmbuild,我正在从Python包构建一个二进制RPM。这个包使用一个定制的.spec文件,这是一个硬要求。(python setup.py bdist\u rpm不够灵活。) 例如,.spec文件的一个片段如下所示: %else %if 0%{?rhel} >= 7 BuildRequires: python2-devel BuildRequires: python-setuptools Requires: python(abi) = 2.7 Requires: python2-boto >

我正在从Python包构建一个二进制RPM。这个包使用一个定制的
.spec
文件,这是一个硬要求。(
python setup.py bdist\u rpm
不够灵活。)

例如,
.spec
文件的一个片段如下所示:

%else
%if 0%{?rhel} >= 7

BuildRequires: python2-devel
BuildRequires: python-setuptools

Requires: python(abi) = 2.7
Requires: python2-boto >= 2.5.0
Requires: python2-cryptography < 3
%prep
%setup -q -n %{name}-%{unmangled_version}

%build
%if %{with_python2}
%py2_build
%endif
%if %{with_python3}
%py3_build
%endif

%install
%if %{with_python2}
%{__python2} setup.py install --single-version-externally-managed -O1 --root=%{buildroot} --record=INSTALLED_FILES
%endif
%if %{with_python3}
%{__python3} setup.py install --single-version-externally-managed -O1 --root=%{buildroot} --record=INSTALLED_FILES
%endif
为了简化,我们可以忽略条件检查,只指定一个无条件检查:

Requires: PyYAML
问题在于
rpmbuild
在某个地方将
要求:
转换为一组完全不同的要求。

$ rpm -qp --requires /root/rpmbuild/RPMS/noarch/path-to-project3.0.0-1.noarch.rpm
/bin/bash
/usr/bin/env
/usr/bin/python
/usr/bin/python2
python(abi) = 2.7
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1
设置并构建将放入
dist/
的RPM:

$yum更新-y
$yum安装-y制造
$make setup\u build
$make rpm
检查要求,请参阅
。忽略spec
文件中的要求:

[root@xxxxxxio]#rpm-qp--需要dist/myproj-0.1-1.noarch.rpm
python(abi)=2.7

rpmlib(CompressedFileNames)请提供一个在构建时不进行更改而生成此行为的。可以是一个完全空的包,不需要文件。@CharlesDuffy现在在/usr/lib/rpm下添加了noods,看起来像
/usr/lib/rpm/fileattrs/python.attr
/usr/lib/rpm/pythondeps.sh
可能有用…看起来像
%define\u python\u需要%{nil}
让我走到了一半,但是仍然从输入specfile中删除了所有要求,只留下rpmlib的内容。您仍然没有提供完整的project.spec。我感觉您将requires放在了错误的位置(在某些%if中)。请提供一个在构建时不进行更改而产生此行为的。可以是一个完全空的包,不需要文件。@CharlesDuffy现在在/usr/lib/rpm下添加了noods,看起来像
/usr/lib/rpm/fileattrs/python.attr
/usr/lib/rpm/pythondeps.sh
可能有用…看起来像
%define\u python\u需要%{nil}
让我走到了一半,但是仍然从输入specfile中删除了所有要求,只留下rpmlib的内容。您仍然没有提供完整的project.spec。我有一种感觉,您将需求放在了错误的位置(在某些%if中)。