Next we can quickly configure the Python runtime environment with a super small kb Python package. The following section will introduce the specific operation process.
Python on Windows has not been compiled before. Generally, py2exe and pyinstaller are used for packaging and publishing, and the generated file must be at least 3 MB. In addition, Python only has VS Project files. That is to say, if you want to compile with GCC, you need to write or modify the Makefile yourself. After Mingw32 is installed on Debian, modify the default Makefile to make it support compiling to the Windows version. The source code has been greatly changed, so the process will not be written here, I also forgot how many changes I made. For the compilation method, refer to my previous blog. It is recommended that VS developers easily compile VS instead of making so many changes.
The figure shows the compiled Python environment that runs the previously written Sogou proxy script. This time I used the Python2.3 version. After the compiled file is compressed with UPX, the size is quite small. Comparison:
Python2.3 (Windows): without the library 412KB, with the basic standard library 695KB
Python2.6 (Linux): without the database 1.3 kb, with the basic standard library MB
Python3.3 (Linux): 1 MB Without libraries and 2.1 MB with basic standard Libraries
This time, python of Windows compiled the following built-in modules:
The standard library files are packaged into libpy. dll. This is not a dynamic link library file, but a zip package containing pyc compiled by the standard library.
The compiled python.exeis also renamed as runapp.exe. In addition, the default parameter is not an interactive shell. If you want to interact, you can add a parameter, such as-v.
If no parameter exists by default, the pyc file (Compiled py) named main. app under the current directory will be called ).
All these modifications are made to deploy and embed the Python runtime environment into other applications. It should be noted that, after all, it is not a complete environment, so some features such as the standard library of SSL and emails are not included. I like urllib and SimpleHTTPServer. If not, you can package it into libpy. dll.