1

I am working on a project which has below directory structure

MyPythonProject
    -> configs
        -> appconfig.json
    -> logs
        -> app.log
    -> src
        -> file1.py
        -> file2.py
        -> file3.py 
    app.py

app.py is the main executable file which is also depended on python files inside src. I want to convert app.py to app.exe which I can easily do using pyinstaller app.py. This creates a dist folder which has python and all the packages. I can simply copy paste the src, configs and logs into dist and can easily share it with everyone.

But the problem is I do not want to share python files inside src as it is because it can easily accessed by anyone. I want to convert it into binary executable so that no one can convert or de-compile back into .py files.

For this, I can use auto generated .pyc files but I believe this can also be de-compiled back to py. Is there any way I can convert into some kind of binary which can never be de-compiled. Does pyinstaller do this. Is there any command available in pyinstaller which while converting app.py also converts rest of the python files into executable. Please help. Thanks

7
  • You could include the files into one executable using --onefile however I believe pyinstaller can still be decompiled? Commented Sep 18, 2020 at 3:48
  • @PacketLoss Pyinstaller creates exe so I am sure it will be difficult to decompile. I will look at your link. But anyways can you explain a bit more on --onefile. Does using --onefile it also creates exe for other files Commented Sep 18, 2020 at 4:05
  • There is a good answer already on how to use multiple files in --onefile here follow the answer to add more files, then include --onefile to compile into one executable. Commented Sep 18, 2020 at 4:16
  • @PacketLoss I am getting error in commands. Looks like I am not issuing correct commands. I am checking pyinstaller documentation as well but if you can answer, that would be great. Commented Sep 18, 2020 at 5:46
  • Are you importing the files in src? Commented Sep 18, 2020 at 6:00

1 Answer 1

3

If you are importing the additional scripts, pyinstaller will gather those imports and automatically include them.

You can use --onefile to ensure only the exe is created for distribution.

pyinstaller --onefile app.py

Sign up to request clarification or add additional context in comments.

1 Comment

What should I use to prevent exe to be created?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.