2

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?

OH HAI
  • 23
  • 2

2 Answers2

4

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/

oDDsKooL
  • 1,767
  • 20
  • 23
1

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.

Justin.Wood
  • 695
  • 4
  • 10
  • 1
    You should use `/usr/local/bin` for anything not installed by the package manager (`dpkg` / APT for Debian and Ubuntu). The system maintenance scripts should in theory be able to remove and repopulate `/usr/bin` any time they wish. – tripleee Aug 23 '12 at 07:54