Use Cython to compile Python so

Source: Internet
Author: User

1. Requirements

In order to ensure the security and efficiency of online code, using Python to write code, PYC can be directly decompile, so the important code compiled so file

2. Work

2.1 Install the relevant library:

-Y gcc Python-devel

2.2 Creating setup.py

# !/usr/bin/env python # Coding=utf-8  from Import Setup  from Import Cythonizesetup (    = cythonize ("xxxx.py"))

2.3 Run

[Email protected]:/xxx/xxx/xxx#python setup.py build_extcompiling xxx.py because it changed. [1/1] cythonizing xxx.pyrunning build_extbuilding'lib.xxx'extensioncreating buildcreating Build/temp.linux-x86_64-2.7x86_64-linux-gnu-gcc-pthread-dndebug-g-fwrapv-o2-wall-wstrict-prototypes-fno-strict-aliasing-wdate-time-d_fortify_ Source=2-g-fstack-protector-strong-wformat-werror=format-security-fpic-i/usr/include/python2.7-c Xxx.c-o build/ temp.linux-x86_64-2.7/xxx.ocreating Build/lib.linux-x86_64-2.7Creating Build/lib.linux-x86_64-2.7/libx86_64-LINUX-GNU-GCC-PTHREAD-SHARED-WL,-O1-WL,-BSYMBOLIC-FUNCTIONS-WL,-BSYMBOLIC-FUNCTIONS-WL,-Z,RELRO- Fno-strict-aliasing-dndebug-g-fwrapv-o2-wall-wstrict-prototypes-wdate-time-d_fortify_source=2-g- Fstack-protector-strong-wformat-werror=format-security-wl,-bsymbolic-functions-wl,-z,relro-wdate-time-d_ Fortify_source=2-g-fstack-protector-strong-wformat-werror=format-security Build/temp.linux-x86_64-2.7/xxx.o-o Build/lib.linux-x86_64-2.7/lib/xxx.so

The build directory will be uploaded in the current directory, with the following structure:

[Email protected]:/spider/codes/lib#  tree build/build/|--lib.linux-x86_64-2.7|   '-- lib|       '-- xxx.so '--temp.linux-x86_64-2.7    '-- XXX.O3 directories, 2 files

2.4 Get so file

Use Cython to compile Python so

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.