หน้าเว็บ

วันอาทิตย์ที่ 27 กรกฎาคม พ.ศ. 2551

ปัญหา buildout ของ Plone บน Windows ที่มี Visual Studio >= 2005

สำหรับการลง plone โดยใช้วิธี buildout นั้นอาจจะมีปัญหากับเครื่องที่เป็น Windows ที่มี Visual Studio ตั้งแต่เวอร์ชั่น 2005 ขึ้นไป โดย error message จะฟ้องตอนขณะคอมไพล์ Zope ว่า
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

ซึ่งวิธีแก้อย่างแรกคือบน Windows ต้องลง Mingw ก่อน ซึ่งเป็น package ที่รวม gcc compiler สำหรับ Windows เอาไว้
ซึ่งก็จะช่วยแก้ปัญหาได้
แต่สำหรับบางเครื่องที่ผมไปลง เหมือนกับว่ามันไม่ยอมไปเรียก Mingw ทั้งๆที่ได้ set path เอาไว้แล้ว (รวมทั้งสร้างไฟล์ distutil.cfg ให้เรียก compiler=mingw32 แล้วด้วย) ซึ่งไม่แน่ใจว่าเป็นที่เครื่องหรือเป็นที่ผมตั้งค่าไม่เป็น แล้วมันก็เลยยังฟ้อง error อยู่แบบนั้น
วิธีแก้คือไปแก้ไข code ที่มันจะทำการ compile zope โดยไฟล์นั้นจะอยู่ที่ %YOUR_PLONE_DIR%\eggs\plone.recipe.zope2install-2.2-py2.4.egg\plone\recipe\zope2install\ ชื่อไฟล์ว่า __init__.py

ให้แก้ตรงที่ทำการเรียกคำสั่ง setup.py คือ
assert os.spawnl(
os.P_WAIT, options['executable'], options['executable'],
'setup.py',
'build_ext', '-i',
) == 0

เป็น
assert os.spawnl(
os.P_WAIT, options['executable'], options['executable'],
'setup.py',
'build_ext -c mingw32', '-i',
) == 0

คือเป็นการระบุไปเลยว่าให้ใช้ compiler คือ mingw32
โดยในไฟล์จะมีอยู่ 2 ที่ที่เรียก setup.py ก็ให้แก้ทั้ง 2 ที่เลย
แล้วก็ค่อยสั่ง buildout ใหม่อีกรอบ ก็จะสามารถคอมไพล์ได้

ระบบที่ทดสอบ
OS: Windows Server 2003 with Visual Studio 2008 and Mingw32
Plone: 3.06 (install by using buildout)

ไม่มีความคิดเห็น: