在已经使用 Python 2.7 的系统上从源代码编译 Python 2.7.3 [英] Compile Python 2.7.3 from source on a system with Python 2.7 already

查看:28
本文介绍了在已经使用 Python 2.7 的系统上从源代码编译 Python 2.7.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从源代码编译 Python 2.7.3.操作系统是 OpenSUSE 11.4 x86_64,它已经提供了 Python 2.7.我想将 2.7.3 用于最新的安全补丁,但它是一个共享系统,因此我无法修改系统 Python 解释器.

I wish to compile Python 2.7.3 from source. The OS is OpenSUSE 11.4 x86_64, which already provides Python 2.7. I'd like to use 2.7.3 for the latest security patches, but it's a shared system so I can't tinker with the system Python interpreter.

我使用 ./configure --prefix=/opt/python --enable-shared 编译.没有配置错误,所以我make.再次没有错误.我做了一个 make install(我认为我不需要 make altinstall,因为 /opt/python 中的这个安装前缀不在还没用).

I compile using ./configure --prefix=/opt/python --enable-shared. No configure errors, so I make. Again no errors. I do a make install (I don't think I need make altinstall, since this installation prefix in /opt/python isn't in use yet).

当我尝试运行新的二进制文件 /opt/python/bin/python 时,Python 宣布其版本为 2.7,而不是 2.7.3.我发现纠正此问题的唯一方法是移动系统的 /usr/lib64/libpython2.7.so.1.0,并将其符号链接到 /opt/python/lib/python/libpython2.7.so.1.0.这有效并且 Python 宣布它是 2.7.3,但这破坏了 Python 系统.

When I try to run the new binary /opt/python/bin/python, Python announces its version as 2.7, not 2.7.3. The only way I've found to correct this is to move the system's /usr/lib64/libpython2.7.so.1.0, and symlink it to /opt/python/lib/python/libpython2.7.so.1.0. This works and Python announces it is 2.7.3, but this breaks the system Python.

无论如何我可以让两者共存,例如通过让 /opt/python 使用它自己的 libpython?除了在运行时提供 LD_LIBRARY_PATH 之外.有编译时解决方案吗?谢谢.

Is there anyway I can get the two to coexist, e.g. by getting the /opt/python to use its own libpython? Other than supplying LD_LIBRARY_PATH at runtime. Is there a compile time solution? Thanks.

推荐答案

为了避免每次启动 Python 时都必须使用 LD_LIBRARY_PATH 指定运行时库路径,您可以在构建时使用-rpath 链接器选项:

To avoid having to specify the runtime library path using LD_LIBRARY_PATH each time Python is started, you can specify it at build time using the -rpath linker option:

./configure --enable-shared --prefix=/opt/python \
            LDFLAGS=-Wl,-rpath=/opt/python/lib

这篇关于在已经使用 Python 2.7 的系统上从源代码编译 Python 2.7.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆