Hi Julien,
zlib can be a bit of a pain. Qt compiles and includes its own version
of zlib when it is compiled in Sire, and Python will sometimes and
sometimes not include zlib... Obviously zlib is needed to install
easy_install, pip etc... The cmake file I wrote to compile Python
should have it build in its own local copy of zlib, so it is useful to
know that this is failing on CentOS 6.5. To understand how to fix it,
I will take you now through how Python is bundled and installed with
Sire (which is very similar to how everything is bundled and
installed).
First, the bundled software is distributed as a tarball in the
"bundled" directory, e.g. python/bundled/python3.tar.gz. Each bundle
comes with an install_xxx.cmake file, e.g. install_python.cmake which
is used to configure and install the bundle. This cmake file is used
to unpack, configure, install and then set the cmake flags to link
with the libraries in each bundle. The first thing the cmake file does
is see if the bundle has been already compiled and installed into the
sire.app/bundled directory. If it has, it just sets the paths and
exits. If the bundle has not been installed, then it will then unpack
the tarball for that bundle into the build_bundled directory, e.g.
BUILD_DIR/python/build_bundled/python3. It will then run the configure
and make commands for this bundle in this build_bundled directory. In
the case of Python, it runs configure with the options placed in
${PYTHON_OPTIONS}, e.g. --enable-shared --prefix=${BUNDLE_STAGEDIR}
CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER}
LDFLAGS=-WL,-rpath='$$ORIGIN/../lib'
(the last part configures python so that it has an RPATH that lets it
find all of its libraries in install_directory/../lib, e.g. if
installed in
sire.app/bundled/bin, it will look in
sire.app/bundled/lib)
cmake will then compile using the command "make -k -j ${NCORES}", and,
once complete, will run "make install" (which will install to
${BUNDLE_STAGEDIR} which is actually ${CMAKE_INSTALL_PREFIX}/bundled,
i.e. /path/to/
sire.app/bundled.
After this is complete, for the install_python.cmake, it will then try
to unpack and install setuptools and pip using a similar process.
However, this doesn't always work, which is why it sometimes has to be
performed manually.
Finally(!), every time cmake is run, on Apple, it will set the @rpath
on all of the bundled libraries etc. This is needed because RPATH is a
lot harder to use on OS X than Linux, as you have to actually change
the internal name of the library to allow RPATH to work (OS X links by
looking for the internal name of the library, which is not the file
name. You have to use the "install_name_tool" with OS X, which is
called ${CMAKE_INSTALL_NAME_TOOL} to set the name of the library to
"@rpath/libSomething.dylib", rather than the default
"libSomething.dylib". This is why you will see a lot of "if (APPLE)"
sections drifting around the CMakeLists.txt files...
Your assessment of the problem (missing zlib) is correct. Normally,
python has, in my experience, compiled up and used its own internal
copy of zlib which is bundled automatically in
bundled/lib/python3.3/lib-dynload/zlib.***
It looks like CentOS 6.5, for some reason, has made python not
automatically compile and install its own copy of zlib. Either python
detected that zlib was available and so used the system version (and
then this
sire.app was copied to another machine), or it compiled
against a zlib, and then the RPATH stuff somehow made python forget
where zlib was installed. The solution is to find out the configure
option when compiling python to force it to compile and use its own
internal copy of zlib. Once you know which configure option to use,
then add it to ${PYTHON_OPTIONS} list in
SOURCE_DIR/python/bundled/install_python.cmake. You then have to be
careful to recompile and reinstall to new directories (i.e. create a
new build directory and make sure that you are installing to a new
directory, e.g. $HOME/
sire.app doesn't exist). Otherwise either python
won't compile (it will use the old version), or the new configure
won't run or will have problems.
I hope this helps,
Best wishes,
Christopher