久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <small id='bMrNd'></small><noframes id='bMrNd'>

    <i id='bMrNd'><tr id='bMrNd'><dt id='bMrNd'><q id='bMrNd'><span id='bMrNd'><b id='bMrNd'><form id='bMrNd'><ins id='bMrNd'></ins><ul id='bMrNd'></ul><sub id='bMrNd'></sub></form><legend id='bMrNd'></legend><bdo id='bMrNd'><pre id='bMrNd'><center id='bMrNd'></center></pre></bdo></b><th id='bMrNd'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='bMrNd'><tfoot id='bMrNd'></tfoot><dl id='bMrNd'><fieldset id='bMrNd'></fieldset></dl></div>

    1. <tfoot id='bMrNd'></tfoot>

      <legend id='bMrNd'><style id='bMrNd'><dir id='bMrNd'><q id='bMrNd'></q></dir></style></legend>
          <bdo id='bMrNd'></bdo><ul id='bMrNd'></ul>

        在 Cython 中制作可執行文件

        Making an executable in Cython(在 Cython 中制作可執行文件)

            <legend id='Eju2T'><style id='Eju2T'><dir id='Eju2T'><q id='Eju2T'></q></dir></style></legend>
            • <i id='Eju2T'><tr id='Eju2T'><dt id='Eju2T'><q id='Eju2T'><span id='Eju2T'><b id='Eju2T'><form id='Eju2T'><ins id='Eju2T'></ins><ul id='Eju2T'></ul><sub id='Eju2T'></sub></form><legend id='Eju2T'></legend><bdo id='Eju2T'><pre id='Eju2T'><center id='Eju2T'></center></pre></bdo></b><th id='Eju2T'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Eju2T'><tfoot id='Eju2T'></tfoot><dl id='Eju2T'><fieldset id='Eju2T'></fieldset></dl></div>
                <tbody id='Eju2T'></tbody>

              <tfoot id='Eju2T'></tfoot>
                • <bdo id='Eju2T'></bdo><ul id='Eju2T'></ul>

                  <small id='Eju2T'></small><noframes id='Eju2T'>

                  本文介紹了在 Cython 中制作可執行文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  一直在玩 cython.通常使用 Python 編程,但在前世使用過 C.我不知道如何制作獨立的可執行文件.

                  Been playing with cython. Normally program in Python, but used C in a previous life. I can't figure out how to make a free-standing executable.

                  我已經下載了 cython,我可以制作一個 .pyx 文件(這只是一個帶有 .pyx 擴展名的普通 Python 文件),它在 Python shell 中執行,使用:導入pyximport;pyximport.install()

                  I've downloaded cython, and I can make a .pyx file (that's just a normal Python file with a .pyx extension), that executes in the Python shell, using: import pyximport; pyximport.install()

                  我可以在命令行生成一個 .c 文件:cython file.pyx我可以通過構建標準 setup.py 并執行來生成 .so 文件:

                  I can generate a .c file at the command line with: cython file.pyx I can generate a .so file by building a standard setup.py and executing:

                  setup.py build_ext --inplace
                  

                  我嘗試使用帶有各種選項的 gcc 從 .so 文件中制作可執行文件,但總是有大量丟失的文件、頭文件等.我嘗試從幾乎所有地方指向頭文件,但沒有成功,現在不太熟悉所有 gcc 選項的作用,或者即使我應該使用 gcc.

                  I've tried making an executable out of the .so file using gcc with various options, but always have tons of missing files, headers, etc. Have tried pointing to headers from virtually everywhere, but with no success, and am not really familiar with what all the gcc options do, or even if I should be using gcc.

                  我在這里與我可以在 Python shell 中運行我的程序,但不能在命令行中運行我的程序,(我不希望用戶必須進入 shell,導入模塊等).

                  I've having a disconnect here with the fact that I can run my program in the Python shell, but not at the command line, (I don't want users to have to get into the shell, import modules, etc).

                  我在這里錯過了什么?

                  推薦答案

                  你想要的是 Cython 編譯器的 --embed 標志.沒有大量文檔,但 this 是我能夠做到的尋找.它確實鏈接到一個簡單的工作示例.

                  What you want is the --embed flag for the Cython compiler. There isn't a ton of documentation on it, but this is what I was able to find. It does link to a simple working example.

                  要將 Cython 源代碼編譯為 C 文件,然后可以編譯為可執行文件,您可以使用 cython myfile.pyx --embed 之類的命令,然后使用您使用的任何 C 編譯器進行編譯.

                  To compile the Cython source code to a C file that can then be compiled to an executable you use a command like cython myfile.pyx --embed and then compile with whichever C compiler you are using.

                  當您編譯 C 源代碼時,您仍然需要包含包含 Python 頭文件的目錄并鏈接到系統上相應的 Python 共享庫(一個類似 libpython27.so 的文件或 libpython27.a 如果您使用的是 Python 2.7).

                  When you compile the C source code, you will still need to include the directory with the Python headers and link to the corresponding Python shared library on your system (a file named something like libpython27.so or libpython27.a if you are using Python 2.7).

                  以下是有關如何獲取包含正確標頭和鏈接到正確庫的命令的更多說明.

                  Here are some more instructions on how to get the commands for including the proper headers and linking against the proper libraries.

                  正如我之前所說,您需要像這樣運行 Cython 編譯器:

                  As I said earlier, you need to run the Cython compiler like this:

                  cython <cython_file> --embed
                  

                  要使用 gcc 進行編譯,您需要找到系統中 python 頭文件的位置(您可以通過運行 distutils.sysconfig.get_python_inc() 獲取此位置(您必須導入首先).它可能只是 Python 安裝目錄中的 /include 子目錄.

                  To compile using gcc, you will need to find where the python headers are on your system (you can get this location by running distutils.sysconfig.get_python_inc() (you'll have to import it first). It is probably just the /include subdirectory in your Python installation directory.

                  您還必須找到 python 共享庫.對于 Python 2.7,它將是 Windows 上的 libpython27.a 或 Linux 上的 libpython2.7.so.

                  You will also have to find the python shared library. For Python 2.7 it would be libpython27.a on Windows or libpython2.7.so on Linux.

                  你的 gcc 命令將是

                  Your gcc command will then be

                  gcc <C_file_from_cython> -I<include_directory> -L<directory_containing_libpython> -l<name_of_libpython_without_lib_on_the_front> -o <output_file_name>
                  

                  包含 -fPIC 標志可能是明智的.在 Windows 64 位機器上,您還必須包含標志 -D MS_WIN64 告訴 mingw 為 64 位窗口編譯.

                  It may be wise to include the -fPIC flag. On Windows 64 bit machines you will also have to include the flags -D MS_WIN64 that tells mingw to compile for 64 bit windows.

                  如果您正在編譯依賴于 NumPy 的內容,您還需要包含包含 NumPy 標頭的目錄.您可以通過運行 numpy.get_include() 找到此文件夾(同樣,在導入 numpy 之后).然后你的 gcc 命令就變成了

                  If you are compiling something that depends on NumPy, you will also need to include the directory containing the NumPy headers. You can find this folder by running numpy.get_include() (again, after importing numpy). Your gcc command then becomes

                  gcc <C_file_from_cython> -I<include_directory> -I<numpy_include_directory> -L<directory_containing_libpython> -l<name_of_libpython_without_lib_on_the_front> -o <output_file_name>
                  

                  這個 gcc 命令選項 guide 可能會有所幫助.

                  This gcc command option guide may be helpful.

                  另外,如果可能,我建議您使用 Cython 內存視圖.這樣您就不必包含 NumPy 標頭并將 NumPy pxd 文件包含在 Cython 文件中.它還使 C 編譯器更容易優化切片操作.

                  Also, I would recommend you use Cython memory views if possible. That will make it so that you won't have to include the NumPy headers and include the NumPy pxd file in your Cython file. It also makes slicing operations easier for the C compiler to optimize.

                  這篇關于在 Cython 中制作可執行文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                  Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                  How to refresh sys.path?(如何刷新 sys.path?)
                  Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)
                      <bdo id='4xZ57'></bdo><ul id='4xZ57'></ul>
                      <i id='4xZ57'><tr id='4xZ57'><dt id='4xZ57'><q id='4xZ57'><span id='4xZ57'><b id='4xZ57'><form id='4xZ57'><ins id='4xZ57'></ins><ul id='4xZ57'></ul><sub id='4xZ57'></sub></form><legend id='4xZ57'></legend><bdo id='4xZ57'><pre id='4xZ57'><center id='4xZ57'></center></pre></bdo></b><th id='4xZ57'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4xZ57'><tfoot id='4xZ57'></tfoot><dl id='4xZ57'><fieldset id='4xZ57'></fieldset></dl></div>
                      <legend id='4xZ57'><style id='4xZ57'><dir id='4xZ57'><q id='4xZ57'></q></dir></style></legend>
                    • <tfoot id='4xZ57'></tfoot>

                      <small id='4xZ57'></small><noframes id='4xZ57'>

                            <tbody id='4xZ57'></tbody>
                            主站蜘蛛池模板: 成年人视频在线免费观看 | www.伊人.com | 色悠悠久 | 99久久免费精品国产免费高清 | 久久99精品久久久久久国产越南 | 99一级毛片 | 午夜日韩精品 | 91成人精品| 91影片| av片毛片 | 亚洲字幕在线观看 | 狠狠的干狠狠的操 | 亚洲高清在线 | 亚洲在线免费 | 日日想夜夜操 | 国产精品久久久久婷婷二区次 | 国产人成在线观看 | 蜜桃毛片 | 国产1区| 精品网站999 | 91一区二区三区 | av福利网 | 免费午夜视频 | 欧美精品福利 | 国产精品视频免费观看 | 亚洲人成人一区二区在线观看 | 97超碰人人 | 日本aⅴ中文字幕 | 亚洲二区视频 | 黄色一级毛片 | 91精品欧美久久久久久久 | 久久国产精品网站 | 91社区在线观看高清 | 亚洲视频一区在线 | 成人免费看片网 | 久久久久久久亚洲精品 | 亚洲成人网在线播放 | 99久9| 国产999精品久久久久久 | 日本视频免费观看 | av影音资源 |