1

I have a python project, that does have a setup.py file. Now I am able to create an rpm using python setup.py bdist_rpm. I installed the several python dependencies using pip. Now when I take the resulted rpm to another machine/host, I am getting several python package related error, like:

pkg_resources.DistributionNotFound: The 'enum34<2,>=1.0.4' distribution was not found and is required by xyz

Anybody has any idea how to resolve this issue? Is using bdist_rpm is the best way to create rpm out of a python project? Should I use something else to statically bind all the dependencies in the rpm itself?

Edit: Adding 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',
    ],
)
7
  • maybe you should post the contents of your setup.py file; because that doesn't look very good. Commented Jun 30, 2016 at 6:43
  • @ChrisMaes I have edited the question. Commented Jun 30, 2016 at 6:49
  • how are you installing the created rpm? using rpm, zypper or something else? I think all that message is saying is: you have dependencies that are not installed; so you have to make sure they get installed. If you use zypper with the correct repositories; zypper will take care of that for you. (or yum ) Commented Jun 30, 2016 at 6:58
  • I am using yum, those dependencies were install using pip, does yum take care of that? Commented Jun 30, 2016 at 7:07
  • I think yum does not know about the "packages" you installed using pip. Commented Jun 30, 2016 at 7:19

2 Answers 2

1

Jordan Sissel's FPM project is really handy for making RPM/DEB from a bunch of different source types, python included. Take a look at the wiki page for python for some instructions on this. It's pretty good at handling dependencies for you too.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the suggestion, but I want the dependencies to be installed statically, so that I don't have to do it again on the next machine. Is there any way to do that?
I did have a little hack on this earlier (gist.github.com/boyvinall/1349b056c6d1c730ae1ffe440d5aa918) but was trickier than I thought. I wouldn't bundle everything into a single rpm but to ensure that required dependent packages are also available so that they get installed when you install this one. Make sure that you use the same package names as provided by your distro.
1

I highly recommend you pyp2rpm for generating python packages.

Staticaly linked modules -- that is called bundling and it is bad. You will regret it sooner or later. If you want to use dependencies which are not in distribution, you can use https://copr.fedorainfracloud.org/coprs/g/copr/PyPI2/ which contains lots of PyPI modules packaged as RPM.

1 Comment

looks nice, not seen that before :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.