Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy a simple python application in linux for shared, company environment?

I have written an (obviously) excellent tool in python (under linux) that I would like to share with my co-workers. We work on different machines, but with the same, shared environment. Also, we are users, so there is no way of easily installing dependencies.

Now here's the catch: I like python, my users don't care. They do have access to company-wide installation of python (a simple one), but they don't want to care (well, that's understandable, not everyone is a programmer).

The question is: In such shared environment, where python interpreter is available, but the modules to my application are not, what could be the simplest way of sharing my tool with other users?

As you may imagine, my users don't want to install anything (especially in the user-space), configuring path would be probably on the edge of acceptance. The solution should not package EVERYTHING like a freeze, that's probably an overkill...

For the user it should be: copying a certain tar.gz or going to the app folder (shared), running the app, done.

So maybe the modules should somehow be embedded in the app? Or should I host (in my shared home) the modules in a library and setup some paths? Or maybe a virtualenv could help, if the users could copy the whole env with the path?

I hope you see my problem :D

Thanks!

like image 744
ronszon Avatar asked Mar 12 '11 07:03

ronszon


People also ask

How do I distribute a Python program?

The most convenient way to deliver a Python application to a user is to provide them with an executable—either a single file or a directory with an easily identified executable somewhere in it.


3 Answers

For "the same, shared environment" you could do:

  1. Install your-script to /your/shared/home/virtualenv

    $ pip install your-app.tar.gz -E /your/shared/home/virtualenv
    
  2. Make a link:

    $ ln -s /your/shared/home/virtualenv/bin/your-script /shared/app/folder/
    
  3. Your co-workers can invoke the script as /shared/app/folder/your-script or add /shared/app/folder/ to PATH.

Features:

  • you choose which version of your script is available by controlling where the symlink points to. Old versions could be run as /your/shared/home/virtualenv-old-version/bin/your-script
  • you could use Python extensions written in C
  • if you install into the virtualenv via pip install -e .; it makes available the version from your working directory

In general it is not a preferable option to install Python apps.

like image 77
jfs Avatar answered Oct 17 '22 06:10

jfs


Assuming your standard installs are Python 2.6 or later and you don't use any C extension modules, you can just throw it all in a zipfile, include a __main__.py file and then prepend a shell header to the zipfile. Your scenario is precisely why this feature was added.

See http://bugs.python.org/issue1739468 for more details on how to set that up.

like image 25
ncoghlan Avatar answered Oct 17 '22 08:10

ncoghlan


you can use pyinstaller to create a stand-alone executables
see:http://www.pyinstaller.org/

like image 1
sami Avatar answered Oct 17 '22 06:10

sami