Python RPM软件包生成失败,并显示'rpm:-ba:未知选项'-rpmbuild可用

问题描述 投票:0回答:1

我的问题与this one非常相似。但这在几个关键点上有所不同,那里的解决方案不起作用。

我有一个简单的Python 3项目,其程序包包含一些简单的类。我需要将此项目打包为RPM并将其发布在私人仓库中。

环境:

Mac OS X 10.15.3 (Catalina)
Python 3.7.3
rpm 4.15.1

Package           Version
----------------- -------
astroid           2.3.3  
coverage          5.0.4  
isort             4.3.21 
lazy-object-proxy 1.4.3  
mccabe            0.6.1  
pip               20.0.2 
pylint            2.4.4  
setuptools        46.1.3 
six               1.12.0 
typed-ast         1.4.1  
wheel             0.34.2 
wrapt             1.11.2

我在项目根目录中有一个setup.py文件:

import setuptools

with open("README.md", "r") as fh:  # README.md exists alongside, is readable and has few ASCII text
    long_description = fh.read()

setuptools.setup(
    name="my_util",
    version="0.2.0",
    author="Andrei Rinea",
    author_email="[email protected]",
    description="Utils",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://example.com/",
    packages=setuptools.find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3.7",
        "Operating System :: OS Independent",
        "License :: Other/Proprietary License"
    ],
    python_requires='>=3.7',
    license='(C) ACME Example 2020',
    platforms='any'
)

我跑步时

python setup.py bdist_rpm

我最终遇到错误:

... (successfully making directories, copying files etc.)
...
copying dist/my_util-0.2.0.tar.gz -> build/bdist.macosx-10.15-x86_64/rpm/SOURCES
building RPMs
rpm -ba --define _topdir /Users/andrei/Work/my-util/build/bdist.macosx-10.15-x86_64/rpm --clean build/bdist.macosx-10.15-x86_64/rpm/SPECS/my_util.spec
rpm: -ba: unknown option
error: command 'rpm' failed with exit status 1

[rpmbuild在路径中可用:

% rpmbuild --version

RPM version 4.15.1

我在整个Google上进行了搜索,但结果并不多,最接近的是开头链接的Stackoverflow问题。那是在Linux上,似乎为那个家伙安装了rpm-build(在OS X上似乎包含在rpm中)是可行的。

最新编辑:Distutils版本:

% python3
Python 3.7.3 (default, Nov 15 2019, 04:04:52) 
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils
>>> print (distutils.__version__)
3.7.3
python python-3.x rpm rpmbuild python-packaging
1个回答
0
投票

问题是distutils 3.7.3仅在rpmbuild/bin中找到它时才使用/usr/bin,如您所见in its source code

rpm_cmd = ['rpm']
if os.path.exists('/usr/bin/rpmbuild') or \
   os.path.exists('/bin/rpmbuild'):
    rpm_cmd = ['rpmbuild']

如果您可以将其符号链接到该位置,则可能是最简单的答案。否则,您可能需要修补bdist_rpm.py的副本。

© www.soinside.com 2019 - 2024. All rights reserved.