looking into python...

Steven D'Aprano steve at pearwood.info
Thu Mar 3 08:39:09 EST 2016


On Thu, 3 Mar 2016 09:45 pm, crankypuss wrote:

> Ben Finney wrote:
> 
>> crankypuss <invalid at invalid.invalid> writes:
>> 
>>> "Python code can be packaged into stand-alone executable programs for
>>> some of the most popular operating systems, allowing the distribution
>>> of Python-based software for use on those environments without
>>> requiring the installation of a Python interpreter." (wikipedia)
>>>
>>> How correct is that?  Which "most popular operating systems" are
>>> those?
>> 
>> Python's web site covers this. The Python environment is available for
>> download <URL:https://www.python.org/downloads/> for all major
>> operating systems.
> 
> Looking at https://www.python.org/downloads/release/python-344/
> it appears that "all major operating systems" includes "Mac OS X",
> "Windows", and "Source release".  I'm seeing nothing about Android, or
> BlackBerry OS-10, or mainframes, or linux.  Presumably the source code
> has been pre-built for linux in various distro repositories.  Maybe I'm
> missing the obvious as usual.

Yes, all the major Linux distros (Red Hat, Centos, Fedora, Debian, Ubuntu,
Mint, Suse, ...) will either install Python by default or at least provide
it through their official package management software.

Likewise, FreeBSD and OpenBSD certainly have Python available.

I doubt Blackberry has Python available, but that's hardly a major or
important platform.

For Android, the answer is mixed. I don't have an Android device to try it
on, but I'm told that it is possible to install Python on Android, but it
may be difficult. Probably the easiest way is to install Kivy:

https://kivy.org/

Kivy is a cross-platform Python development system that runs on OS X, Linux,
Windows, iOS (iPad, iPhone) and Android.

For mainframes, the answer is maybe". If your mainframe supports the C89
standard, it will probably work. If it can run x86 machine code, or emulate
it in a VM, that's probably the way to go.

Some older versions of Python supported mainframes like VMS, but in 2011,
support for OS\2, VMS and Windows 2000 was dropped:

http://blog.python.org/2011/05/python-33-to-drop-support-for-os2.html

There is a Nokia project called PyS60 that runs Python on Nokia Series 60
mobile phones. I don't know if it is still maintained.

Classic Mac OS (System 9 and older) was supported in older Python versions,
but not the more recent ones.

I don't think there has ever been a version of Python that ran on DOS :-)



> Referring back to the wikipedia quote at the start of the post, I'm
> interested in how Python code is packaged into stand-alone executables.

I'm only really familiar with the situation on Linux. On Linux, you usually
wouldn't bother. Since Python is almost always already installed on the
system, and even if it is not, it's usually only a single command away
(like `yum install python`, say), there's very little point in packaging
your scripts or applications up in a stand-alone exe file.

Somewhat intermediate between stand-alone exe applications and a directory
full of scripts is to create a package, compress it into a zip file, and
run that zip file with the Python interpreter installed on your system.
Since it relies on there being an external Python interpreter, it's not
exactly stand-alone, but it may be close enough for what you're doing.

Python packages are dead-simple: create a directory called "foo", and put a
file inside it called "__init__.py". It can even be an empty file. That's a
package. Obviously there is more to it than that, but that's the basics.



-- 
Steven




More information about the Python-list mailing list