如何使用OpenSSL构建Python?

时间:2014-02-14 19:04:32

标签: python openssl

我正在构建自己的Python二进制文件。我想用OpenSSL构建它,因为我的应用程序是在GPL下发布的,显然OpenSSL许可证是incompatible with it

Python configure --help命令表示对于这样的情况有一个--without-PACKAGE选项,但显然这对ssl不起作用:

$ ./configure --without-ssl
configure: WARNING: unrecognized options: --without-ssl

这里有什么想法吗?

编辑:这是描述我的问题的mailing list item,但看起来提供的解决方案有点像黑客。

2 个答案:

答案 0 :(得分:0)

我不建议尝试在没有OpenSSL的情况下构建Python。正如可以用简单的grep验证的那样,如果没有SSL,很多东西都会破坏。

您可能会关注的是使用修改后的GPL分发您的代码,该GPL允许以OpenSSL链接作为例外。此类许可文本的示例在debian-legal:https://lists.debian.org/debian-legal/2004/05/msg00595.html

上的此电子邮件中

编辑:我推荐这个,但你可以通过在./configure之前运行以下命令来阻止任何链接到OpenSSL:

sed -i'' -e '1i\
#error' ./Modules/_ssl.c
sed -i'' -e '1i\
#error' ./Modules/_hashopenssl.c

请注意,这是两个分布在两行上的命令。您也可以手动添加#error作为这些文件的第一行。

答案 1 :(得分:0)

至少在Python 3.6中,如果您在没有依赖库头文件的环境中构建Python,它将简单地跳过需要它的模块,并给出如下消息:

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2                  _curses               _curses_panel
_dbm                  _gdbm                 _lzma
_sqlite3              _ssl                  _tkinter
nis                   readline              spwd
zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.