gpt4 book ai didi

python - mysqldb 构建错误

转载 作者:行者123 更新时间:2023-12-01 06:18:41 25 4
gpt4 key购买 nike

我记得在我的 32 位 Mac 上使用 Leopard 10.5.7 安装了 Python + Django + MySQL + MySQLdb。我在 Mac Snow Leopard 上尝试了相同的过程。但不幸的是遇到了很多错误......我不知道,但奇怪的事情正在发生。请查看错误日志:

Amit-Vermas-MacBook:mysql-python-1.2.2 amitverma$ python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.3-i386-2.5
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.3-i386-2.5/_mysql.o -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
In file included from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:57,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyport.h:761:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
In file included from _mysql.c:35:
/usr/local/mysql/include/my_config.h:1050:1: warning: "HAVE_WCSCOLL" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyconfig.h:721:1: warning: this is the location of the previous definition
In file included from _mysql.c:35:
/usr/local/mysql/include/my_config.h:1168:1: warning: "SIZEOF_LONG" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyconfig.h:811:1: warning: this is the location of the previous definition
In file included from _mysql.c:35:
/usr/local/mysql/include/my_config.h:1177:1: warning: "SIZEOF_PTHREAD_T" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyconfig.h:820:1: warning: this is the location of the previous definition
error: command 'gcc-4.0' failed with exit status 1
Amit-Vermas-MacBook:mysql-python-1.2.2 amitverma$

最佳答案

这是我个人的 makefile 规则

MYSQLDB_VERSION=1.2.3c1
MYSQLDB_TARGET=$(BUILD_FLAGS_DIR)/mysqldb
MYSQLDB_PACKAGE=MySQL-python-$(MYSQLDB_VERSION).tar.gz
MYSQLDB_PACKAGE_URL=http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/$(MYSQLDB_VERSION)/$(MYSQLDB_PACKAGE)

.PHONY: mysqldb mysqldb-download
mysqldb: $(MYSQLDB_TARGET)
mysqldb-download: $(DOWNLOAD_DIR)/$(MYSQLDB_PACKAGE)

$(MYSQLDB_TARGET): $(INIT_TARGET) $(MYSQLDB_DEPS) $(DOWNLOAD_DIR)/$(MYSQLDB_PACKAGE)
-rm -rf $(UNPACK_DIR)/MySQL-python-$(MYSQLDB_VERSION)
tar -m -C $(UNPACK_DIR) -xzvf $(DOWNLOAD_DIR)/$(MYSQLDB_PACKAGE)
-cd $(UNPACK_DIR)/MySQL-python-$(MYSQLDB_VERSION); \
for patch in $(PATCH_DIR)/mysqldb-$(MYSQLDB_VERSION)_$(ARCH)_*; \
do patch -p1 < $$patch; \
done
cd $(UNPACK_DIR)/MySQL-python-$(MYSQLDB_VERSION); export CC="gcc -m64" FC="g95 -m64" CPPFLAGS="-I$(RUNTIME_DIR)/include" CFLAGS="-m64 -I$(RUNTIME_DIR)/include" LD_LIBRARY_PATH=$(RUNTIME_DIR)/lib64:$(RUNTIME_DIR)/lib:$$LD_LIBRARY_PATH PATH=$(RUNTIME_DIR)/bin:$$PATH PYTHONPATH=$(RUNTIME_DIR)/lib/python2.5/site-packages/; $(RUNTIME_DIR)/bin/python2.5 setup.py install --prefix=$(RUNTIME_DIR)
touch $(MYSQLDB_TARGET)

$(DOWNLOAD_DIR)/$(MYSQLDB_PACKAGE):
for package in $(MYSQLDB_PACKAGE_URL); \
do \
echo -n "Downloading $$package... "; \
cd $(DOWNLOAD_DIR); curl -L -O $$package; \
echo "done"; \
done
touch $@

ALL_RUNTIME_TARGETS+=$(MYSQLDB_TARGET)
ALL_DOWNLOAD_TARGETS+=$(DOWNLOAD_DIR)/$(MYSQLDB_PACKAGE)

还有补丁

$ more mysqldb-1.2.3c1_x86_64-apple-darwin10_patch-000 
diff -Naur MySQL-python-1.2.3c1/setup.py MySQL-python-1.2.3c1.new/setup.py
--- MySQL-python-1.2.3c1/setup.py 2008-10-18 02:12:31.000000000 +0200
+++ MySQL-python-1.2.3c1.new/setup.py 2009-10-08 22:59:05.000000000 +0200
@@ -13,6 +13,8 @@
from setup_windows import get_config

metadata, options = get_config()
+options["extra_compile_args"].remove("-arch")
+options["extra_compile_args"].remove("x86_64")
metadata['ext_modules'] = [Extension(sources=['_mysql.c'], **options)]
metadata['long_description'] = metadata['long_description'].replace(r'\n', '')
setup(**metadata)

这对我有用。我不能保证,但是……也许你会在里面发现一些有趣的提示。

请注意,我使用的是自定义编译器(由于过时的原因太丑陋而无法深入研究)

关于python - mysqldb 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1835658/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com