ronszon
ronszon

Reputation: 3317

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!

Upvotes: 5

Views: 7281

Answers (4)

jfs
jfs

Reputation: 414179

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.

Upvotes: 3

ncoghlan
ncoghlan

Reputation: 41486

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.

Upvotes: 3

sami
sami

Reputation: 551

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

Upvotes: 1

PaulMcG
PaulMcG

Reputation: 63709

What is the nature of your application? Is it a simple "plug in some values, get an answer" kind of thing? Or is it more interactive/graphical? If the former, your app could be packaged up as a utility on UtilityMill. Then your users could just access your app thru a standard browser.

Upvotes: 0

Related Questions