Page 1 of 1
How do I compile apps with Python?
Posted: Sun 24 Jun 2012, 03:05
by Tman
These, days when I play with Puppy stuff, I am trying to compile different apps. Having learned the basics of how to use GCC compiler, I thought I'd try to learn how to compile Python apps.
Can anyone please tell me what the basic steps to compiling Python apps are?
More specifically, what is the Python equivalent to the following code?
Code: Select all
./configure --prefix=/usr ...etc
make install
make install DESTDIR=/my/custom/folder
So far, I've only discovered the following:
Code: Select all
python setup.py --fcompiler=gnu build
python setup.py install
I not 100% sure if the code above is correct. (input needed)
What code do I need to install the app to a custom folder, so that I can use dir2pet on it?
Posted: Sun 24 Jun 2012, 11:37
by tallboy
Python is an high-level, interpreted languge, so no compilation is necessary.
http://docs.python.org/tutorial/index.html
tallboy
Posted: Sun 24 Jun 2012, 12:58
by muggins
Python apps will often come with
setup.py
Code: Select all
./setup.py
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied
# ./setup.py --help
Common commands: (see '--help-commands' for more)
setup.py build will build the package underneath 'build/'
setup.py install will install the package
Global options:
--verbose (-v) run verbosely (default)
--quiet (-q) run quietly (turns verbosity off)
--dry-run (-n) don't actually do anything
--help (-h) show detailed help message
--command-packages list of packages that provide distutils commands
Information display options (just display information, ignore any commands)
--help-commands list all available commands
--name print package name
--version (-V) print package version
--fullname print <package name>-<version>
--author print the author's name
--author-email print the author's email address
--maintainer print the maintainer's name
--maintainer-email print the maintainer's email address
--contact print the maintainer's name if known, else the author's
--contact-email print the maintainer's email address if known, else the
author's
--url print the URL for this package
--license print the license of the package
--licence alias for --license
--description print the package description
--long-description print the long package description
--platforms print the list of platforms
--classifiers print the list of classifiers
--keywords print the list of keywords
--provides print the list of packages/modules provided
--requires print the list of packages/modules required
--obsoletes print the list of packages/modules made obsolete
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
Problems arise when the python you've installed is missing certain modules the particular app needs etc.
Posted: Sun 24 Jun 2012, 20:29
by disciple
You might also come across "Python eggs" which require "EasyInstall"
Posted: Mon 25 Jun 2012, 02:41
by Tman
Thank you tallboy, muggins and disciple for the info. It is much appreciated. I didn't know python programs don't need to be compiled. So I guess, they are kind-of like bash scripts then?
So I assume that when I use setup.py, I will just look for a "build" folder and use dir2pet on it, after I have renamed it.
I did come across
http://cx-freeze.sourceforge.net/ which looks interesting...
It is supposed to turn Python apps into binaries. I haven't tried it out yet, though.
Posted: Mon 25 Jun 2012, 03:26
by disciple
So I guess, they are kind-of like bash scripts then?
Yes, they are Python scripts.
As you might have noticed in Muggins post, you don't need to run `python some_script.py`. You can just run `path_to_some_script.py`, and it will run, as long as it is executable.
But some programs that are mainly Python might have parts written in another language like C, to get better performance than Python can provide. In that case the C parts would obviously be compiled. Also, Python programs often have dependencies which are Python bindings of C libraries. These are also compiled IIRC.