How to package and release python projects?

problem description

developed a web website with python+tornado, ready to deploy to the extranet, but the company"s information security requirements can not be released by source code, it must be compiled and released.
the entire system is now in a virtualenv environment.

the environmental background of the problems and what methods you have tried

1. I"ve tried pyinstaller, as a tool for single files, but it"s not very convenient for multiple files, especially those that rely on a lot of them.
2. I have also tried compileall, as a tool to compile all py files into pyc files. But if I run the pyc file directly, I will report that import error, can"t find any other files in the same directory that it depends on.

expect results

I hope all of you who have a similar situation can help solve the problem. I would appreciate it.

Jan.13,2022

I tested that after compileall.compile_dir () compiled the dir directory, I still have to do two things:
1, copy the pyc file from the _ _ pycache__ directory under the dir directory;
2, delete all the py files under the dir directory, and then rename the copied pyc file according to the style of the py file, such as [test.cpython-36.pyc] to [test.pyc].
in this way, you can execute "python test.pyc" normally on the command line, and even if "import module1" exists in test.pyc, it can successfully import module1.pyc in the same dir directory.


itself is a language problem. If you don't want the source code to be released, you shouldn't use python

.
Menu