程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Windows compiling Python

編輯:Python

drainage

        python compile | compile py|xp python|python library |python ssl|python.exe|python|python socket

Write it at the front

In actual development, we often need to python A component or support program compiled into our program , So we need to compile one by ourselves python Interpreter .

compile python

         download py Source code

                py Is an open source interpretation language , We can easily download its source code :

                       python Official website :http://Python Source download

         If you need to compile py Can be in xp Up operation , Latest supportable xp Of python Version is Python 3.4.4.

        Unzip the source code and open

          Find the solution location

        Open the solution

          Here you can set the generation platform , For example, compatibility is required xp. It can be set to 141xp

Test the compiled file

        The generated python_d.exe、python27_d.dll Put the files on one computer py Computers in the environment , Simple execution python -V test

Handle Python Standard library

        Easy to implement py Code testing

                To write pytest.py

print("hello word")

                perform py file , Not output normally

          add to py Standard library

                The above figure is not implemented successfully , Because now we have py Interpreter , however py The standard library file for does not exist , So the library function call failed .

                Find in the source directory Lib Catalog , Copy it to the... Of the experimental machine python2.7.exe Under the table of contents

                  Execute again after copying to the target location py Program , Results the correct .

Compile system related py library

                Continued above , So we happily carry out some py Program

                There was a mistake again , go through Lib No... Was found in the folder _socket Wait for the documents .

                go back to py Source code , See if there are similar words

                 See light suddenly ,py Apart from the encapsulated logic library . The underlying communication library must be related to the operating system api dependent .

                Compile the library to generate the corresponding library file , The suffix is pyd. Put it in DLLs Catalog .

                  There is no error in the previously missing library . Compile all libraries into DLLs Folder is ok .

                Compile here ssl After the pyd Put the library file into DLLs, Try running again .

Python Differences involving documents

Format describe .pypython Source file .pycpyc Is the target file after source file compilation .pyo Optimized source file .pyd It is written in other languages python library

         be relative to py The file is , Translate it into pyc and pyo In essence, py There's no big difference , Only for this module loading speed increased , It doesn't speed up code execution , In general, you don't need to actively compile pyc file , The document says that just call import model that model.py It will be compiled into pyc Then load .

compile _ssl matters needing attention

        compile openssl We need to pay attention to

        Available tutorials :windows compile openssl

        openssl Source code :oepnssl Source download

                Pit avoidance point :

                                1、Perl Own Baidu , Go to the next one on the official website win Just set the environment variables on the installation version .

                                2、 After compilation _ssl The dependency library is set to ssleay.lib, The project itself seems to be crypt.lib.

 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved