如何使用cython保护Python代码?

问题描述 投票:0回答:0

我用 Python 语言开发了一个程序,我想最终将这个程序作为 Windows 的可执行文件提供。(作为 .exe 文件) 为了保护我的代码,在互联网和谷歌上的各种搜索建议我使用

Cython
库 这是我阅读的网站的链接: https://ron.sh/compiling-python-code-with-cython/

在本站的例子中,

setup.py
文件中有代码,它使用以下命令执行该文件
python setup.py build_ext --inplace
并且执行这条命令后,程序的路径下会添加以下文件

module.c

module.cp37-win_amd64.pyd

根据我给出的解释和网站本身的例子,我的问题是这些 首先,

module.cp37-win_amd64.pyd
不是为我生成的 第二,如何使用
module.c
文件并调用该文件中的函数? 在下面,网站上给出的示例使用以下代码片段

from module import hello

if __name__ == '__main__':
     hello()

给我留言:

弃用警告: distutils 包已弃用并计划在 Python 中删除 3.12.使用 setuptools 或 c 查看 PEP 632 寻找潜在的替代方案

从 distutils.core 导入设置

编译 mytest.py 因为它改变了。

[1/1] Cythonizing 模块.py

运行 build_ext

构建“模块”扩展

错误:无法找到 vcvarsall.bat

我使用 Windows 进行 Python 编程

但是from module import hello是从

module.py
文件导入的,而不是从
module.c
文件导入的,如果我想把程序作为可执行文件给用户,他可以看到我的代码。

我感谢任何能帮助我解决这个问题并保护我的代码的人

python cython source-code-protection
© www.soinside.com 2019 - 2024. All rights reserved.