如何在x86_64主机上构建带有Setup.py的32位Python模块分发 [英] How to Build a 32-bit Python Module Distribution w/ Setup.py on x86_64 Host

查看:372
本文介绍了如何在x86_64主机上构建带有Setup.py的32位Python模块分发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编译 PyEphem 的32位版本。但是,这似乎并不困难,但是,我遇到了一些编译器问题。

  $ CFLAGS = -m32 python setup.py bdist -p i386 
运行bdist
运行bdist_dumb
运行生成
运行build_py
运行build_ext
生成'ephem._libastro'扩展名
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -m32 -fPIC -Ilibastro-3.7.3 -I / usr / include / python2.6 -c extensions / _libastro.c -o build / temp.linux-x86_64-2.6 / extensions / _libastro.o
在/usr/include/python2.6/Python.h:58包含的文件中,
来自扩展名/ _libastro.c:3:
/usr/include/python2.6/pyport.h:685:2:error:#errorLONG_BIT定义对于平台(坏gcc / glibc配置?)出现错误。
error:command'gcc'failed with exit status 1

构建系统运行Ubuntu 10.04。是否Python头文件与本地主机的体系结构绑定?



更新:我发现了一些关于 Python交叉编译

解决方案

你在机器上安装了32位Python吗?我认为如果你从32位python运行它应该没问题,并确保你链接到正确的python.h。



我从来没有试图在Linux上进行交叉编译,但是我已经针对在64位Windows上并排安装的不同python进行了编译。

然后,当然有核安装选项一个32位的虚拟机并从那里编译。


I need to compile a 32-bit distribution of PyEphem. It does not seem like this should be difficult, however, I'm running into some compiler issues.

$ CFLAGS=-m32 python setup.py bdist -p i386
running bdist
running bdist_dumb
running build
running build_py
running build_ext
building 'ephem._libastro' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -m32 -fPIC -Ilibastro-3.7.3 -I/usr/include/python2.6 -c extensions/_libastro.c -o build/temp.linux-x86_64-2.6/extensions/_libastro.o
In file included from /usr/include/python2.6/Python.h:58,
                 from extensions/_libastro.c:3:
/usr/include/python2.6/pyport.h:685:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
error: command 'gcc' failed with exit status 1

The build system is running Ubuntu 10.04. Are the python header files tied to the architecture of the local hosts?

Update: I found some interesting info about Python cross-compiling.

解决方案

Have you installed a 32-bit python on your machine? I think that it should be OK if you run it from 32-bit python, and make sure you're linking to the right python.h.

I've never tried to cross-compile on Linux, but I have compiled against different pythons installed side by side on 64-bit Windows.

Then of course, there's the nuclear option of installing a 32-bit VM and compiling from there.

这篇关于如何在x86_64主机上构建带有Setup.py的32位Python模块分发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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