I am looking for companies hosting websites developed in Python 3 and CherryPy. Webfaction looks good, but it is limited to Linux servers, and my site has been designed and tested under Windows. Can anyone summarise (or point me to) the changes I will have to make to my code in order to get it to run under Linux?

I guess if I want to keep my code unchanged I may have to go for a VPS (virtual private server). I will have more control over what I install, but it's a lot more expensive. Has anyone had any experience of this setup with Python?

Many thanks, Alan Harris-Reid

Comments

Are you using anything likely to be Windows-specific? It's hard for us to provide detailed advice without seeing the code, beyond obvious things like "avoid modules containing the word win." CherryPy and Python should insulate you from most cross-platform issues. I would consider just purchasing a month worth of Linux hosting, and doing some testing.

Written by Matthew Flaschen

You could always download Virtualbox and a Linux distribution and try out your code in that environment, locally.

Written by birryree

@Alan it's hard to image wanting to use Windows for a live server when you are not using a .Net framework IMHO.

Written by Josh

Matthew - No, there is nothing Windows specific, but sometimes the code looks for files in a specified path (eg. \dev\python\config\myconfigfile.txt), which I am guessing would fail under Linux. Is it simply a matter of reversing the backslashes to forward slashes? Alternatively is there a test for if Linux: do this else: do that ? Regards.

Written by Alan Harris-Reid

birryree - thanks for the suggestion. I've looked at the Virtualbox site and I am still not clear how it works. Would I need to have the Linux installed on another disk partition? Does Virtualbox enable me to run stuff on Linux while viewing it from within Windows? Regards.

Written by Alan Harris-Reid

Josh - you are right - I don't really care whether the site runs under Linux or Windows, and as there are many more Linux hosts out there (and they are less expensive), that wins it for me. But first I need to know what to look out for in my code which might cause it to fall-over. Regards.

Written by Alan Harris-Reid

For the most part, you won't notice anything, especially if you're using no OS-dependant functionality (Which you said you weren't). As you mentioned, the file paths will change, so yes that would need to be updated in your source. For Virtual Box, it allows you to run another virtual computer - with whatever you want on it (EG, Linux). This will allow you to test everything in linux whilst staying on your windows installation.

Written by TyrantWave

@Matthew: isn't Python3 wsgi still somewhat broken?

Written by Paulo Scardine

@Paulo, it's definitely in flux. There's some information at WSGI for Python 3.

Written by Matthew Flaschen

@TyrantWave - Thanks for that. Is there a Python command for testing which OS is running (eg. if linux, use '/', else use '\')? Re. VirtualBox, does this mean that I will have to install Linux on another partition of the same HDD (can't use 2 HDDs on my laptop)? Regards.

Written by Alan Harris-Reid

@Paulo - It's not so much broken as undefined, but PEP 3333 aims to resolve that. Meanwhile I am using CherryPy 3.2 with Python 3, and have had no serious problems (yet :-) ). Regards.

Written by Alan Harris-Reid

@Alan Harris Reid: thanks for the feedback!

Written by Paulo Scardine

@Alan Harris Reid: import os; print os.name tells you the name of the OS.

Written by TyrantWave

@TyrantWave - Thanks for the OS tip. I've just tried it on my Windows 7 machine and it returns 'nt'!! Still, I suppose Microsoft will get its act together one day and return more meaningful os data :-( Regards.

Written by Alan Harris-Reid

Accepted Answer

You can buy inexpensive VPS hosting and configure it the way you like, Python and all. This way is preferable if you want to tweak other parts of the stack later, e.g. switch to a different WSGI implementation.

Also you can use Amazon EC2 similarly, as @meimimo suggests; it is free to start.

Written by 9000
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki