I want to deploy a Django application to a cloud computing environment, but I am worried about source code security. Can I deploy only the compiled .pyc files there? According to official python doc, pyc files are 'moderately hard to reverse engineer'.
What are the pros and cons of taking this approach? Is this a standard practice?
I am not using AWS, let me just say that I am in a country where cloud computing can not be trusted at all...
Having a *. pyc file saves the compilation time of converting the python source code to byte code, every time the file is imported.
. py files contain the source code of a program. Whereas, . pyc file contains the bytecode of your program.
What is a PYC file? A PYC file is a compiled output file generated from source code written in Python programming language. When PY file is run using Python interpreter, it is converted to bytecode for execution. At the same time, the compiled bytecode is also saved as .
pyc files are created automatically by the GraalVM Python runtime when no or an invalid . pyc file is found matching the desired . py file. When a Python source file (module) is imported during an execution for the first time, the appropriate .
Deploying .pyc files will not always work. If using Apache/mod_wsgi for example, at least the WSGI script file still needs to be straight Python code.
Some web frameworks also may require the original source code files to be available. Using .pyc files also does little to obscure any sensitive information that may be in templates used by a web framework.
In general, using .pyc files is a very weak defence and tools are available to reverse engineer them to extract information from them.
So technically your application may run, but it would not be regarded as very secure way of protecting your source code.
You are better of using a hosting service you trust. This generally means paying for reputable hosting rather than just the cheapest one you can find.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With