简体   繁体   中英

How to create a rpm for python application

I have a simple application (just one .py file), that is using cherrypy & flask-restful to present a web service. My development environment is Windows. I use Python 3.5.2 and also create and use virtualenv to work on my project.

I have a need to deploy this on Linux systems. I was asked to create a "RPM" for this so that it can be installed and run on Linux machines.

I have googled and read several pieces of documentation:

But I'm very unclear on the steps that needs to be done to deploy this on a Linux system. Thanks in advance for all your help.

This is a mini demo structure output by tree command, color_print is the package name and directory

.
├── color_print
│   ├── color_print.py
│   └── __init__.py
├── __init__.py
└── setup.py

Here is an example setup.py for demo

from setuptools import setup

setup(name='color_print',
    version='0.1',
    description='Color String',
    url='http://github/xxxx/color_print/',
    author='Joe Bob',
    author_email='joe.bob@gmail.com',
    license='MIT',
    packages=['color_print'],
    zip_safe=False)

There is no need to change directory, run this one command to build rpms

python setup.py bdist_rpm

Here is the output, it is that easy:

-bash-4.1$ find . -name "*.spec"
./build/bdist.linux-x86_64/rpm/SPECS/color_print.spec
-bash-4.1$ find . -name "*.rpm"
./dist/color_print-0.1-1.noarch.rpm
./dist/color_print-0.1-1.src.rpm

In reality, you will definitely need to modify the spec files manually. and run

rpmbuild -ba ./build/bdist.linux-x86_64/rpm/SPECS/color_print.spec

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM