setuptools的扩展,通过nuitka运行包以生成编译的、更快的、模糊的二进制模块。
nuitka-setuptools的Python项目详细描述
setuptools的扩展,通过nuitka运行包以生成编译的、更快的、模糊的二进制模块。
nuitka[http://nuitka.net/pages/overview.html]是一个具有完全语言支持和cpython兼容性的python编译器。
It’s fully compatible with Python 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, and 3.6.
You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.
此模块提供了一些钩子,可以添加到python packages setup.py中,以自动运行部分/全部代码 在构建二进制dist时通过nuitka。这通常是通过python setup.py bdist戋wheel完成的 创建用于分发的控制盘。
有了nuitka setuptools,这个控制盘就没有纯python了,只包含编译后的代码,不仅速度更快 (引用:nuitka的速度是cpython的2倍以上)但是代码安全性相对较高。
基本用法:setup.py:
import sys from setuptools import setup # Get the long description from the README file with open(path.join(path.dirname(__file__), 'README.rst'), 'r') as f: long_description = f.read() packages = ['mod', 'pkg'] if any('bdist' in arg for arg in sys.argv): from nuitka_setuptools import Nuitka, Compile build_settings = dict( # Compile module cmdclass={'build_ext': Nuitka}, ext_modules=Compile(packages), ) else: build_settings = {} setup( name='nuitka_setuptools', py_modules=['nuitka_setuptools'], description='Extension to setuptools to run your package through nuitka to ' 'produce compiled, faster, obfuscated binary modules.', long_description=long_description, author='Andrew Leech', author_email='andrew@alelec.net', url='https://gitlab.com/alelec/nuitka-setuptools', use_scm_version=True, include_package_data=True, install_requires=['setuptools_scm'], setup_requires=['setuptools_scm'], cmdclass={'build_ext': Nuitka}, ext_modules=Compile(['nuitka_setuptools']), **build_settings )