Say I have a python code base organized like so:
./mod/:
./__init__.py
./main/main.py
./main/__init__.py
./mytest/__init__.py
The file
mod/main/__init__.py
is empty. And
$ cat mod/main/main.py
import sys
import mytest
def main(argv):
mytest.test()
return
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
And
$ cat mod/mytest/__init__.py
def test():
print('test worked!')
As expected, this works (from within the directory "mod"):
$ python3 -m main.main
test worked!
Now, I want to remove all the .py files, and still be able to run the command that I have above - or something very similar. "Very similar" is defined by not having to change my code structure at all - or, if that cannot be done, as little as possible.
How can I achieve this?
1 Answer 1
the
compileall
utility with the "-b" option did the thing for me.
Sign up to request clarification or add additional context in comments.
Comments
lang-py
.pycfiles aren't obfuscated and almost can't be. Python even comes with a Python disassembler built in, so people who can run your code don't even need to download any additional tools to start taking it apart.