Python Forum
Question about exporting Python
Thread Rating:
  • 4 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about exporting Python
#1
Python can be saved as a .py file which can be run by Python. This .py is a file that is interpreted.

But you cannot distribute .py files because
1) Users can read the file
2) Users need Python to run it

So you compile Python to a binary file (.exe) and then distribute it.

But.. at this point the binary file is no longer "interpreted" but is "compiled". So Python should be a compiled language right? Why is it interpreted? The only time you're interpreting is when testing..
Reply
#2
why do you think you *must* distribute in compiled form?
user may have python already installed (either included with the OS or installed afterwards by user for whatever reason), or install it when needed.
also you can bundle python interpreter with your application and user doesn't need to install it separately or even know which python interpreter is used.
As to the user reading the file - if they are motivated enough they can decompile, so this is more or less irrelevant
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Everybody can read the code of the linux system. It doesn't prevent it from being widely distributed. Of course Linus Torvalds is not as wealthy as Bill Gates...
Reply
#4
And to not focus only on "Why do you think you need to distribute compiled code?"

read Is Python interpreted or compiled? Yes.
and also A Crash Course in Interpreted vs. Compiled Languages
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
Buran that you've mentioned that you can bundle an interpreter to an executable,

-> How to do this? Can the interpreter be included in one binary file along with the application or does this have to be separate? How to do this if you were to do it either way?

-> Why would you do this? Are there any advantages? I thought that compiling would be better than interpreting for distributions.. no?

Lot of big companies use Python and they need not be open source, because they are a business after all. So how do they use Python? Do they compile Python or do they use it backend at their servers or something?

Is compiling Python popular - do big companies do it?


Quote:If they're motivated enough they can decompile
I'm confused.. decompile the .exe? How?

[quote]Python can be included with OS[/code]
Oh really I didn't know about that! What OS have Python in them by default?
Reply
#6
(Jan-12-2019, 01:21 PM)Nwb Wrote: How to do this? Can the interpreter be included in one binary file along with the application or does this have to be separate? How to do this if you were to do it either way?
pynsist

(Jan-12-2019, 01:21 PM)Nwb Wrote: Why would you do this? Are there any advantages? I thought that compiling would be better than interpreting for distributions.. no?
advantages and disadvantages. What I mean - there are alternatives - find what suit you best for every particular case. i.e. my point is - I don't say compiling is bad or unpopular. Just that it's not mandatory when distribute code.

(Jan-12-2019, 01:21 PM)Nwb Wrote: Lot of big companies use Python and they need not be open source, because they are a business after all. So how do they use Python? Do they compile Python or do they use it backend at their servers or something?

As I said - when one is motivated software can be cracked - there are tons of commercial software available online for free. I don't say it is good to violate license and there might be risks, e.g. viruses, malware, etc. The point is - there is no guarantee. You may try other methods, e.g. code obfuscation. It may make it more difficult to understand the code, but no guarantees that it will prevent copyright infringements.


(Jan-12-2019, 01:21 PM)Nwb Wrote: I'm confused.. decompile the .exe? How?

https://stackoverflow.com/questions/2731...e-assembly
https://stackoverflow.com/questions/6287...-by-py2exe

these are just an examples, you can google further - https://www.google.com/search?q=decompil...python+exe



(Jan-12-2019, 01:21 PM)Nwb Wrote: Oh really I didn't know about that! What OS have Python in them by default?

Linux - comes with both python 2 and python 3 preinstalled. In fact Linux OS is running on python2

Same for MacOS, but it comes with just python 2.
(Jan-12-2019, 01:21 PM)Nwb Wrote: Lot of big companies use Python and they need not be open source, because they are a business after all. So how do they use Python? Do they compile Python or do they use it backend at their servers or something?

What you are asking is how they monetize. Of course every company choose their own path, but even open-source software can generate revenue. Just under different model. for example you may offer outstanding for-payment priority support 24/7, on-the-premises training, certification for experts, etc. Also if you make it free for personal use, but paid for commercial - the most companies would buy license instead of violating the law and terms. Yes, there will be also companies that will not pay, but you get the point.
For example - Linux is open source, yet there are paid commercial distros
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
Ohh. I thought Python compilers actually compile the code.. I didn't realize they just bundle the interpreter with the source code.

On the contrary C generates machine code when it is compiled to an executable. This can only be traced back to assembly.

If you can trace Python compiled code back to Python code, then wouldn't that mean Python should not be used to program distributed files that are very important? Suppose a video game or a bank application.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020