【发布时间】:2016-06-30 06:26:55
【问题描述】:
我有一个 python 项目,它有一个 setup.py 文件。现在我可以使用python setup.py bdist_rpm 创建一个rpm。我使用 pip 安装了几个 python 依赖项。现在,当我将生成的 rpm 带到另一台机器/主机时,我收到了几个与 python 包相关的错误,例如:
pkg_resources.DistributionNotFound: The 'enum34<2,>=1.0.4' distribution was not found and is required by xyz
有人知道如何解决这个问题吗?
使用bdist_rpm 是从 python 项目中创建 rpm 的最佳方式吗?我应该使用其他东西来静态绑定 rpm 本身中的所有依赖项吗?
编辑:添加 setup.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import codecs
import os
import re
import sys
from setuptools import find_packages
from setuptools import setup
def read(*parts):
path = os.path.join(os.path.dirname(__file__), *parts)
with codecs.open(path, encoding='utf-8') as fobj:
return fobj.read()
def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
install_requires = [
'cached-property >= 1.2.0, < 2',
'docopt >= 0.6.1, < 0.7',
'PyYAML >= 3.10, < 4',
'requests >= 2.6.1, < 2.8',
'texttable >= 0.8.1, < 0.9',
'websocket-client >= 0.32.0, < 1.0',
'docker-py >= 1.8.1, < 2',
'dockerpty >= 0.4.1, < 0.5',
'six >= 1.3.0, < 2',
'jsonschema >= 2.5.1, < 3',
]
tests_require = [
'pytest',
]
if sys.version_info[:2] < (3, 4):
tests_require.append('mock >= 1.0.1')
install_requires.append('enum34 >= 1.0.4, < 2')
setup(
name='docker-compose',
version=find_version("compose", "__init__.py"),
description='Multi-container orchestration for Docker',
url='https://www.docker.com/',
author='Docker, Inc.',
license='Apache License 2.0',
packages=find_packages(exclude=['tests.*', 'tests']),
include_package_data=True,
test_suite='nose.collector',
install_requires=install_requires,
tests_require=tests_require,
entry_points="""
[console_scripts]
docker-compose=compose.cli.main:main
""",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
],
)
【问题讨论】:
-
也许你应该发布你的 setup.py 文件的内容;因为那看起来不太好。
-
@ChrisMaes 我已经编辑了这个问题。
-
你是如何安装创建的 rpm 的?使用
rpm、zypper或其他什么?我认为所有信息都是:您有未安装的依赖项;所以你必须确保它们被安装。如果您将 zypper 与正确的存储库一起使用; zypper 会为您解决这些问题。 (或yum) -
我正在使用 yum,这些依赖项是使用 pip 安装的,yum 会处理吗?
-
我认为 yum 不知道您使用 pip 安装的“软件包”。