The Python run environment is configured in Windows with only 700KB

Source: Internet
Author: User

Python on Windows has not been compiled before, and packaging releases typically use Py2exe and pyinstaller, generating files of at least 3MB. And Python has only vs project files, that is, if you want to compile with GCC, you need to write or modify makefile yourself. After I installed Mingw32 in Debian, I modified the default makefile to allow it to be compiled into a Windows version, and the source code has changed a lot, so here is not the process written out, I also forgot how many changes. The compilation method can refer to my previous blog post. It is more convenient to choose vs to compile than to change so much.

The diagram is my compiled Python environment that runs the Sogou proxy script that I wrote earlier. This time I use Python2.3 this version, compiles the file to use UPX to compress after, the volume is still small very considerable. The comparison is as follows:

Python2.3 (Windows): No library 412KB, with basic standard library 695KB
Python2.6 (Linux): Without library 800KB, with basic standard library 1.3MB
Python3.3 (Linux): Without library 1MB, with basic standard library 2.1MB

This Python2.3 version of Windows compiles the following built-in modules:

Standard library files are packaged into the Libpy.dll, this is not a dynamic link library file, but a zip compression package, which has a standard library compiled good PYC.

The compiled Python.exe also renamed to become Runapp.exe. And the default parameter is not an interactive shell, and if you want to interact, you can optionally add a parameter, such as-V.

If there are no parameters by default, a PYc file called Main.app (compiled py) is called in the current directory.

These modifications are made to facilitate the deployment and embedding of the Python runtime environment into other applications. It should be noted that, after all, not a complete environment, so some features such as SSL and emails standard library, are not in it. I like the urllib and simplehttpserver or some, if not, can pack their own into the Libpy.dll

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.