0

I have developed a program with Python language and I want to finally provide this program as an executable file for Windows.(as a .exe file) To protect the my code, various searches on the Internet and Google suggested that I use the Cython library which is the link of the sites I read: https://ron.sh/compiling-python-code-with-cython/

In the example of this site, there are codes in the setup.py file and it executes this file with the following command python setup.py build_ext --inplace And after executing this command, the following files will be added to the path of the program

module.c

module.cp37-win_amd64.pyd

According to the explanations I have given and the example of the website itself, my problems are these First, module.cp37-win_amd64.pyd is not generated for me Second, how can I use the module.c file and call the function inside this file? In the following, the example given on the site uses the following code snippet

from module import hello

if __name__ == '__main__':
     hello()

Message for me:

DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or c heck PEP 632 for potential alternatives

from distutils.core import setup

Compiling mytest.py because it changed.

[1/1] Cythonizing module.py

running build_ext

building 'module' extension

error: Unable to find vcvarsall.bat

I use Windows for Python programming

But from module import hello is imported from the module.py file, not from the module.c file, and if I want to give the program as an executable file to the user, he can see my codes.

I thank anyone who can help me to solve this problem and protect my code

Navrang
  • 41
  • 4
  • What does happen when you call `python setup.py build_ext --inplace`? What messages are shown, and what files are generated? – DavidW Feb 21 '23 at 17:56
  • @DavidW Thank you for your time, I edited the message that is displayed for me and put it in the question – Navrang Feb 22 '23 at 03:32
  • You need to make sure you have visual studio installed (see https://wiki.python.org/moin/WindowsCompilers for what version and components you need). You'll probably find it easiest to run setup.py from a visual studio command prompt because it'll have the path set up right – DavidW Feb 22 '23 at 06:49
  • @DavidW I want to do this to obfuscate my Python codes and turn them into executable files (.exe). Is this correct? Is there another way to obfuscate my code? For example pyarmor better? – Navrang Feb 22 '23 at 07:17
  • 1
    I don't recommend using Cython to make exe files mainly because it isn't designed to bundle and dependencies you use so they aren't usually self contained. I know nothing about obfuscation so won't comment on that. But it's an accidental side effect of Cython not what Cython is designed for – DavidW Feb 22 '23 at 07:45

0 Answers0