{"id":4505,"date":"2023-05-09T15:51:33","date_gmt":"2023-05-09T07:51:33","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/?p=4505"},"modified":"2023-05-09T15:51:33","modified_gmt":"2023-05-09T07:51:33","slug":"cython%e6%89%93%e5%8c%85exe%e5%8e%9f%e7%90%86%e7%ae%80%e4%bb%8b","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/exekaifa\/4505.html","title":{"rendered":"cython\u6253\u5305exe\u539f\u7406\u7b80\u4ecb"},"content":{"rendered":"<p>Cython\u662f\u4e00\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5b83\u662fPython\u8bed\u8a00\u7684\u6269\u5c55\u3002\u5b83\u5141\u8bb8Python\u7a0b\u5e8f\u5458\u7f16<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/28\/13\/01907526144.jpg\" \/><\/figure>\n<\/p>\n<p>\u5199\u4f7f\u7528C\u8bed\u8a00\u8bed\u6cd5\u7684Python\u6269\u5c55\uff0c\u4ece\u800c\u63d0\u9ad8Python\u4ee3\u7801\u7684\u6027\u80fd\u3002Cython\u8fd8\u5177\u6709\u751f\u6210\u539f\u751fC\u4ee3\u7801\u7684\u529f\u80fd\uff0c\u8fd9\u4f7f\u5f97Python\u7a0b\u5e8f\u5458\u53ef\u4ee5\u5c06\u4ed6\u4eec\u7684Python\u4ee3\u7801\u7f16\u8bd1\u6210\u5feb\u901f\u7684\u672c\u673a\u4ee3\u7801\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Cython\u5c06Python\u4ee3\u7801\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<p>Cython\u7684\u539f\u7406<\/p>\n<p>Cython\u7f16\u8bd1\u5668\u5c06Cython\u4ee3\u7801\u8f6c\u6362\u4e3aC\u4ee3\u7801\uff0c\u5e76\u4f7f\u7528C\u7f16\u8bd1\u5668\u5c06\u5176\u7f16\u8bd1\u4e3a\u672c\u673a\u4ee3\u7801\u3002\u8fd9\u610f\u5473\u7740Cython\u4ee3\u7801\u53ef\u4ee5\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\uff0c\u800c\u65e0\u9700Python\u89e3\u91ca\u5668\u3002\u7531\u4e8eCython\u4ee3\u7801\u662fPython\u4ee3\u7801\u7684\u6269\u5c55\uff0c\u56e0\u6b64\u5b83\u53ef\u4ee5\u8bbf\u95eePython\u7684\u6240\u6709\u5e93\u548c\u6a21\u5757\u3002\u8fd9\u4f7f\u5f97Cython\u6210\u4e3aPython\u7a0b\u5e8f\u5458\u7684\u6709\u7528\u5de5\u5177\uff0c\u53ef\u4ee5\u63d0\u9ad8Python\u4ee3\u7801\u7684\u6027\u80fd\u3002<\/p>\n<p>Cython\u6253\u5305exe\u7684\u6b65\u9aa4<\/p>\n<p>\u4e0b\u9762\u662f\u4f7f\u7528Cython\u5c06Python\u4ee3\u7801\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u7684\u6b65\u9aa4\uff1a<\/p>\n<p>1. \u7f16\u5199Python\u4ee3<a href=\"https:\/\/exe.yimenapp.com\/tool-3583.html\">asp\u5f00\u53d1\u8f6f\u4ef6<\/a>\u7801\u5e76\u4fdd\u5b58\u4e3a.py\u6587\u4ef6\u3002<\/p>\n<p>2. \u5b89\u88c5Cython\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528pip\u5b89\u88c5Cython\uff0c\u547d\u4ee4\u4e3a&#8221;pip install Cython&#8221;\u3002<\/p>\n<p>3. \u7f16\u5199Cython\u4ee3\u7801\u5e76\u5c06\u5176\u4fdd\u5b58\u4e3a.pyx\u6587\u4ef6\u3002Cython\u4ee3\u7801\u5e94\u8be5\u7c7b\u4f3c\u4e8ePython\u4ee3\u7801\uff0c\u4f46\u662f\u5e94\u8be5\u4f7f\u7528C\u8bed\u8a00\u8bed\u6cd5\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528Python\u7684\u6807\u51c6\u5e93\u548c\u6a21\u5757\uff0c\u4f46\u662f\u60a8\u9700\u8981\u4f7f\u7528Cython\u7684\u8bed\u6cd5\u6765\u8c03\u7528\u5b83\u4eec\u3002<\/p>\n<p>4. \u521b\u5efa\u4e00\u4e2asetup.py\u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u544a\u8bc9Cython\u5982\u4f55\u5c06\u4ee3\u7801\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8bsetup.py\u6587\u4ef6\uff1a<\/p>\n<p>&#8220;`python<\/p>\n<p>from distutils.core import setup<\/p>\n<p>from Cython.Build import cythonize<\/p>\n<p>setup(<\/p>\n<p>    ext_modules = cythonize(&#8220;example.pyx&#8221;)<\/p>\n<p>)<\/p>\n<p>&#8220;`<\/p>\n<p>5. \u6253\u5f00\u547d\u4ee4\u884c\u5e76\u5bfc\u822a\u5230\u5305\u542b.pyx\u6587\u4ef6\u548csetup.py\u6587\u4ef6\u7684\u6587\u4ef6\u5939<a href=\"https:\/\/exe.yimenapp.com\/tool-3056.html\">\u7a0b\u5e8f\u5236\u4f5cexe<\/a>\u3002<\/p>\n<p>6. \u8fd0\u884c\u547d\u4ee4&#8221;python setup.py build_ext &#8211;inplace&#8221;\u3002\u8fd9\u4e2a\u547d\u4ee4\u5c06\u4f7f\u7528setup.py\u6587\u4ef6\u4e2d\u7684\u4fe1\u606f\u5c06.pyx\u6587\u4ef6\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<p>7. \u8fd0\u884c\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u5b83\uff0c\u6216\u8005\u53cc\u51fb\u5b83\u4ee5\u5728Windows\u4e0a\u8fd0\u884c\u5b83\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>Cython\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5c06Python\u4ee3\u7801\u7f16\u8bd1\u6210\u5feb\u901f\u7684\u672c\u673a\u4ee3\u7801\u3002\u4f7f\u7528Cython\u6253\u5305Python\u4ee3\u7801\u6210\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u9700\u8981\u4e00\u4e9b\u989d\u5916\u7684\u6b65\u9aa4\uff0c\u4f46\u662f\u8fd9\u4e2a\u8fc7\u7a0b\u5e76\u4e0d\u96be\u3002\u5982\u679c\u60a8\u9700\u8981\u63d0\u9ad8Python\u4ee3\u7801\u7684\u6027\u80fd\uff0c\u90a3\u4e48Cython\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cython\u662f\u4e00\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5b83\u662fPython\u8bed\u8a00\u7684\u6269\u5c55\u3002\u5b83\u5141\u8bb8Python\u7a0b\u5e8f\u5458\u7f16\u5199\u4f7f\u7528C\u8bed\u8a00\u8bed\u6cd5\u7684Python\u6269\u5c55\uff0c\u4ece\u800c\u63d0\u9ad8Python\u4ee3\u7801\u7684\u6027\u80fd\u3002Cython\u8fd8\u5177\u6709\u751f\u6210\u539f\u751fC\u4ee3\u7801\u7684\u529f\u80fd\uff0c\u8fd9\u4f7f\u5f97P<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[6029,3096,980,3500,802],"class_list":["post-4505","post","type-post","status-publish","format-standard","hentry","category-exekaifa","tag-exe","tag-slnexe","tag-980","tag-3500","tag-802"],"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/4505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=4505"}],"version-history":[{"count":0,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/4505\/revisions"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=4505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=4505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=4505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}