简体   繁体   中英

Distribute a simple python script

I have a simple python script which reads a text file and do some processing on it. I need to distribute this code. So any one with Ubuntu operating system could run it. I import some modules as follows.

import pandas
import httpbl
from prettytable import from_csv

etc...

My question is how to make these packages installable with my script in any other users machine(Ubuntu).

There are lot of questions asked and I found this as the closest match. But any way I do not have much knowledge on doing this.

You should checkout setuptools: http://pythonhosted.org/setuptools/ which can do exactly what you're looking for.

As an example (this is just a script in the same directory called "recat"):

from setuptools import setup

setup(
    name = 'recat',
    version = '0.1',
    packages = [],
    author = 'Name',
    author_email = 'email',
    description = 'Replay log files simply and easily',
    license = 'GPLv3',
    keywords = 'log replay',
    url = 'URL',
    scripts = ['recat']
)

You might also consider creating a Ubuntu package out of it. The FPM project can help you with that: https://github.com/jordansissel/fpm

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