3

I have a server which executes Python scripts from a certain directory path. Incidently this path is a check-out from the SVN trunk version of the scripts. However, I get the feeling that this isn't the right way to provide and update scripts for a server.

Do you suggest other approaches? (compile, copy, package, ant etc.) In the end a web server will execute some Python script with parameters. How do I do the update process?

Also, I have trouble deciding what is best to handle updated versions which only work for new projects on the server. Therefore, if I update the Python scripts, but only newly created web jobs will know how to handle that. I "delivery" to one of many directories which keep track of versions and the server picks the right one?!

EDIT: I webserver is basically an interface that runs some data analysis. That analysis is the actual scripts that take some parameters and mingle data. I don't really change the web interface. I only need to update the data scripts stored on webserver. Indeed, in some advanced version the web server should also pick the right version of my data scripts. However, at the moment I have no idea which would be the easiest way.

Gere
  • 12,075
  • 18
  • 62
  • 94
  • I think this is an the area of ci or continues deployment. I heared jenkins/hudson is the way to go with this, but didn't try this myself. if the issue would be only pushing updated scripts to server then some build tool: make/ant/buildbot(python build tool) etc would be the way to go – alonisser Mar 22 '12 at 16:32
  • and an article about that from coding horror -:http://www.codinghorror.com/blog/2006/10/the-build-server-your-projects-heart-monitor.html – alonisser Mar 22 '12 at 16:35
  • If you are not happy with the reply, could you maybe add some information about your specific case? E.g. Whether "new projects" means new websites with their own code base or rather new functionality that is installed side-by-side in one code base, whether you have some plugin system in place that manages the different scripts (hence "the server picks the right one"), etc. – Dirk Mar 23 '12 at 11:09
  • Done. Hope I've been more clear :) The web interface stays the same - I just need to update the underlying data scripts that are being run on request. – Gere Mar 23 '12 at 14:23
  • If updated versions only work for new projects, you probably want to be using [`virtualenv`](http://pypi.python.org/pypi/virtualenv) for each project, and then install specific versions of the scripts in each project with e.g. a pip requirements file. (Depending on your server setup, of course; this makes sense if they're separate WSGI interfaces, for example.) – Danica Mar 23 '12 at 14:49
  • ok, so in that case you are more interested in knowing how to include dynamic inclusion and handling of scipts in your application; for this you can look at the following SO question: http://stackoverflow.com/questions/932069/building-a-minimal-plugin-architecture-in-python Let me know if this helps you out – Dirk Mar 24 '12 at 10:26

1 Answers1

2

The canonical way of distributing Python code/functionality is by using a PyPi compliant package manager.

A list of available PyPi implementations on python.org:

http://wiki.python.org/moin/PyPiImplementations

Note that for this to work you need to distribute your code as "Eggs"; you can find out how to do this here: http://peak.telecommunity.com/DevCenter/setuptools

A great blog post on the usage of eggs and the different parts in packaging: http://mxm-mad-science.blogspot.com/2008/02/python-eggs-simple-introduction.html

Dirk
  • 2,348
  • 17
  • 23
  • Do package managers do more than collect a package? Because it is also my job to actual "install" whatever te current version is. It is not users downloading a package. – Gere Mar 22 '12 at 17:26
  • The package manager is a server that keeps the packages and allows you for instance to use easy_install to get them (similar to checking out code from a version control system). This also allows you to choose the version to get. See http://peak.telecommunity.com/DevCenter/EasyInstall – Dirk Mar 22 '12 at 17:50
  • Actually installing the code can be done manually, using a shell script, using the API of the package manager or using a Build server such as Travis or Jekyll. – Dirk Mar 22 '12 at 17:53
  • Hmm, but if you just install the code, it's not much better than me copying the files to the server. I don't need to pack, but I rather need to manage updates for something which in the end is a web app. Ideally I'd also keep different versions simultaneously. – Gere Mar 22 '12 at 21:29
  • Packaging can be a broad subject, but in my opinion if you need versioning, then you need some kind of packaging (to keep a version history and an easy way of falling back). In the page mentioned above, you can find a suggestion on how to manage side-by-side script versions (rename with the version number: http://peak.telecommunity.com/DevCenter/EasyInstall#managing-scripts), but I do not know enough of your situation to assess if that is the best way. Alternatively it is possible to use easy_install to get the scripts directly from SVN but that is indeed not better than copying the files. – Dirk Mar 23 '12 at 10:28