从源代码构建python时如何忽略本地python

从源代码构建python时如何忽略本地python

本文介绍了从源代码构建python时如何忽略本地python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用以下命令构建自己的Python版本:

When I try to build my own version of Python using:

./configure --enable-shared --prefix=/app/vendor/python-dev && make && make install

我在安装过程中看到一些错误:

I see some errors during installation:

当链接器尝试使用 /usr/local/lib/libpython2.7.a 而不是新编译的库时,问题开始。

The problem starts when the linker tries to use /usr/local/lib/libpython2.7.a and not the newly compiled library.

如何防止链接器(配置/制作)使用系统上安装的python库?

How can I prevent the linker (configure/make) from using the python libraries installed on the system?

推荐答案

这似乎是 setup.py 脚本的错误特征,该脚本始终包含 / usr / local make 构建目标 sharedmods 时,在搜索路径中找到code>。

This looks to be a misfeature of the setup.py script always including /usr/local in the search path when make builds the target sharedmods.

您必须手动获取 setup.py ,所以...

You'll have to manually frob the setup.py, so do the...

./configure --enable-shared --prefix=/app/vendor/python-dev

...首先,然后编辑 setup.py ,找到第442、443和444行,如下所示。

...first, then edit setup.py, find lines 442, 443, and 444 which should look like this...

if not cross_compiling:
    add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
    add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')

...并注释掉它们,使它们看起来像这样...

...and comment them out so they look like this...

# if not cross_compiling
    # add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
    # add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')

...然后 make 应该可以工作。

...then the make should work.

这篇关于从源代码构建python时如何忽略本地python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 17:38