OH HAI
OH HAI

Reputation: 23

Structuring a Python App (eventually for deb packaging)

So I've written an app in Python that has a main .py file and recently I've written some libraries that it'll use (some more py files). How would I go about "installing" this in Ubuntu? Before I added the libraries, I simply had a bash script that would copy the main py file to /usr/bin so that the user could run the app with just $ appname.py

And what would be the best way to do this for future deployment as a .deb?

Upvotes: 2

Views: 189

Answers (2)

oDDsKooL
oDDsKooL

Reputation: 1847

I think you could make use of the fact that setup.py know how to install python scripts as regular unix programs:

See this doc: http://docs.python.org/distutils/setupscript.html#installing-scripts

I think overall it depends on how integrated/professional you want your process to be.

Anyway, setuptools/distutils are the pythonic way to go.

If you want to go one step further and install your application via regular debian/ubuntu tools like apt-get/aptitude etc, there are folk out there that have written plugins for setuptools to create regular debian/ubuntu packages.

See this module: http://pypi.python.org/pypi/stdeb/

Upvotes: 4

Justin.Wood
Justin.Wood

Reputation: 715

Assuming that you are installing the app into /opt, and that you have properly handled the imports in the python code itself, simply symlinking the main.py file should suit your needs.

ln -s -T /opt/appname/main.py /usr/bin/appname.py

This will work for .deb deployment as well, just make sure to include the symlink in the deployment script.

Upvotes: 1

Related Questions