Building Python extension with Windows SDK 7.1

Windows ပေါ်မှာ Python 64 bits သုံးနေရင် ပြဿနာက Extension တွေက 64 bits မရှိတဲ့ပြဿနာ ခဏခဏကြုံရတယ်။ 64 bits Build လုပ်ပြီးသားတွေကို Unofficial ပေးတဲ့ဆိုက်တွေလည်းရှိပါတယ် ဒါပေမယ့် လွယ်လွယ်ကူကူနဲ့ Dependency မများရင်ကိုယ်တိုင်လည်း Build လုပ်ယူလို့ရတာပါပဲ။ အဲဒီ့မှာအခက်အခဲရှိတာက MinGW32 ကိုအခုအချိန်မှာ အတော်များများက Support လုပ်တဲ့အတွက် ဘာမှမဖြစ်ပေမယ့် 64 bits လိုချင်တဲ့အတွက် MinGW64 သုံးမယ်ဆိုရင်တော့ ထင်သလောက်အဆင်မပြေပါဘူး MinGW32 ရဲ့ Configuration ဟာ MinGW64 နဲ့တိုက်ရိုက် အဆင်မပြေတာရှိပါတယ်။ ဒီတော့အကောင်းဆုံးကတော့ Visual C++ Compiler နဲ့ Build လုပ်တာအကောင်းဆုံးပါပဲ။ Python 2.7 ဟာ Visual Studio 2008 နဲ့ Build လုပ်ထားတဲ့အတွက် သူအတွက် Extension တွေကိုလည်း အတူတူပဲ VS 2008 နဲ့ပဲ Build လုပ်မှရပါတယ်။ 64 bits Build လုပ်ဖို့အတွက် အနည်းဆုံးအနေနဲ့ Visual C++ Express 2008 အပြင် Windows SDK လိုပါတယ် Windows 7 သုံးနေတဲ့အတွက် Microsoft Windows SDK for Windows 7 and .NET Framework 4 နဲ့ Build လုပ်ပါတယ်။

အဲဒီ့နှစ်ခုကို Install လုပ်ပြီးရင်တော့ ချက်ချင်းသုံးလို့မရသေးပါဘူး 64 bits အတွက် Configure လုပ်ဖို့အတွက် နည်းနည်းကြံရဖန်ရပါတယ်။ Visual Studio ကို Default Path မှာသာ Install လုပ်ထားမယ်ဆိုရင် C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC အောက်မှာ vcvarsall.bat ဆိုတာရှိပါတယ် အဲဒီ့ဖိုင်ထဲမှာ amd64 ဆိုရင် bin/amd64/vcvarsamd64.bat ကိုသွားခေါ်ခိုင်းတယ်။ ဒါပေမယ့် Windows SDK ထဲက 64 bits compiler and linker တွေက bin/amd64 အောက်မှာမရှိပဲ တစ်ခြားနေရာမှာရှိနေပါတယ် အဲဒါကြောင့် C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\ အောက်မှာ amd64 ဆိုပြီး Folder တစ်ခုထပ်ထည့် နောက်ပြီးတော့ amd64 ထဲမှာ vcvarsamd64.bat ဆိုပြီးဖိုင်တစ်ခု အသစ်ထည့်ရပါမယ်။ 64 bits Environment ကို Initialize လုပ်တဲ့ Script တွေက Windows SDK ထဲမှာရှိပြီးသားဖြစ်တဲ့အတွက် အဲဒါကိုပဲလှမ်းခေါ်ရင်ရပါတယ်။ vcvarsamd64.bat ထဲမှာ

call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 /Release

ဆိုပြီးတစ်ကြောင်းထည့်ရေးလိုက်ရင် ရပါပြီ။ ဒါဆိုရင် Python ထဲကနေ Build လုပ်ကြည့်ရင်ရပါပြီ လွယ်လွယ်ကူကူဆိုရင် PyCrypto ရဲ့ Source ကို Download လုပ် setup.py build ဆိုလုပ်ကြည့်ရင် ရနေပါလိမ့်မယ်။

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">