How do I static compile python?
E.g. you're working in an "enterprise-y" environment with servers running Centos 5.xxx.
You'd like to compile a newer version of python into a nfs share that can be mounted on all servers and not have any lissing libraries, you dont need to set the LD_LIBRARY_PATH.
Or do something like what ActiveState does with their ActivePython distro.
Any ideas people?
So far, I've found 2 links that could potentially help:- StaticPython StackOverflow
StaticPython seems nice, but I'd like to do something like what ActiveState does, so I could install other libraries myself.
11 comments · 67% upvoted · other discussions
Use virtualenv. The same virtualenv can be moved around to different machines if they have the same architecture.
shavenwarthog 3 points · Jul 2011
Seconded. Using pip and virtualenv your app can use a "private" Python, with specific versions of packages that don't interfere with the system-level libraries.
The terminology can be confusing. Here's my post that minimally goes over them: http://johntellsall.blogspot.com/2011/06/proper-way-to-install-pip-virtualenv.html
lost-theory 2 points · Jul 2011
Also, I don't think StaticPython you linked to will work for what you need:
mindrunner [OP] 1 points · Jul 2011
Thanks. But assuming I want a newer version of Python, I'd have to compile it into a separate path, e.g by using the ./configure --prefix=/opt/something
That would result in me having to set the LD_LIBRARY_PATH right? My main aim is to not touch the rpm database (hence no EPEL packages) or add stuff to the /etc/ld.conf.
Or am I understanding this wrong?
shavenwarthog 1 points · Jul 2011
My understanding is that pip/virtualenv will also recompile a private Python binary for you. If that doesn't work, try "buildout", which is also awesome.
rfkelly 3 points · Jul 2011
No, pip/virtualenv don't recompile Python, they just symlink to an existing install. This is usually what you want.
I have an on-again-off-again project called "myppy" that compiles a private python into a virtualenv-like setup:
It tries to make things portable across different flavours of linux, by removing certain options and using the autopackage compiler tools to avoid dependencies on newer glibc features. Might do what the OP wants slightly better than virtualenv.
mindrunner [OP] 1 points · Aug 2011
This looks interesting. I'll give it a try :)
rfkelly 1 points · Aug 2011
Be warned, it's pretty rough round the edges and underdocumented. That said, it should do what it says on the tin. Feel free to shoot me any questions or bugs you run into.
lost-theory 1 points · Jul 2011
I've been able to install some C extensions nicely without LD_LIBRARY_PATH (lxml, mysqldb), but others (libyaml) I've had to set LD_LIBRARY_PATH manually before running the interpreter.
If you want to avoid using RPM, ldconfig, the system-wide version of Python, etc. then I think you pretty much have to do something like this.
What C extensions are you going to install? For the bigger ones (numpy, lxml, etc.) there should be a pretty well accepted way to install to a virtualenv with a locally built version of python.