1

I'm developing an application that requires some initial configuration when first deploying(initial params, server adress,...etc). This application is written in a different language than python, but I'm using python because it's the language that's the most commonly pre-installed on linux machines.

I'm thinking of installing the prerequisites at the top of the script like so:

import os
os.system("python setup.py install <package>")
from <package> import <stuff>

But then I'm installing a package on a computer that belongs to a user, only to use it just once. Should I just uninstall it when my script ends? How do I go about this?

SnelleJelle
  • 933
  • 5
  • 18
  • 35

1 Answers1

1

Why not install the python packages from your shell script prior to execution of your program? See this question if you're trying to uninstall these packages afterwards. It looks like if you install with easy_install or pip, you can just use pip uninstall.

Update based on comments: You can also consider deploying your script as a separate application using cx_freeze, py2exe, or some other option (see additional info here: http://docs.python-guide.org/en/latest/shipping/freezing/).

Community
  • 1
  • 1
David C
  • 7,204
  • 5
  • 46
  • 65
  • yes, that seems the best solution but still seems kinda dirty. Is it really the best way to go? Also thanks for including the uninstallation method :p – SnelleJelle Apr 26 '16 at 14:38
  • Another solution is to just ship Python with the prerequisite packages as a stand-alone program. What's better probably depends on the purpose of your program and your end-users. – David C Apr 26 '16 at 14:41
  • If your end-users are all Linux based, consider using freeze or some other packaging: http://docs.python-guide.org/en/latest/shipping/freezing/. – David C Apr 26 '16 at 14:44
  • How do I ship it as a stand-alone program? – SnelleJelle Apr 26 '16 at 14:46
  • hmmn I could use freeze for linux distribution and py2exe for windows distribution and that would cover everything! – SnelleJelle Apr 26 '16 at 14:47
  • ah yes yes that's what I'll do! If you post it as an answer then I'll mark it as solved :p – SnelleJelle Apr 26 '16 at 14:49
  • Edited answer to incorporate comments. – David C Apr 26 '16 at 15:22