0

I have a program written in python using multiple large modules such as Tensorflow, tesseract, cv2, and others. I need to compile the program fairly often, so the problem is, that all those large modules are compiled again and again, taking lot of time and resources.

Is there a way to compile my code only?

So that I could just replace the old my_program.exe with the new my_program.exe, because those modules stay the same. It's waist of time.

  • i think when you compile it to a binary, you ship the whole python interpreter as well as any modules you have used + finally your own code. Also, if you have the module regularly installed it means you have python installed too, so why don't you use your code uncompiled in that case? – The Fool Jun 13 '21 at 09:15
  • I think it won't be possible because of what's stated here: https://stackoverflow.com/questions/40492518/is-an-import-in-python-considered-to-be-dynamic-linking – The Fool Jun 13 '21 at 09:18
  • 2
    `pyinstaller` is for preparing programs for deployment. If you are perpetually rerunning `pyinstaller` because of frequent changes to your Python code, consider running and testing that code *without* wrapping it in an `.exe`, until you have your code in a sufficiently stable state that it is ready to be deployed. – BoarGules Jun 13 '21 at 10:14
  • Why are you packaging as an exe file at all? – kaya3 Jun 13 '21 at 10:33
  • @The Fool, well, I need to distribute, but I also think it wouldn't be the wizest idea to share my source code, so that's why I need to compile. Thanks for your ansver anyways! – Tomas Foltyn Jun 13 '21 at 15:33
  • You should not rely on obscurity as means of security. If you have any secrets on your code, someone with enough know how can find those secrets even when you compile your program. They can for example use a hex editor to inspect the byte code. I.e. see this https://stackoverflow.com/questions/39559677/pyinstaller-encryption-key – The Fool Jun 13 '21 at 21:01

0 Answers0