Mit cx_Freeze (http://starship.python.net/crew/atuining/cx_Freeze/) lassen sich unter Linux Executables aus Python-Scripten herstellen. Falls man ein größeres Projekt hat, das aus vielen Scripten besteht, kann man die Scriptnamen + Zielordner in eine Textdatei schreiben und mit folgendem Utility in einem Rutsch durchcompilieren lassen.
Code: Alles auswählen
#!/usr/bin/env python
#########################################################################################################################
# cxf_remote.py
# Remote for cx_freeze (http://starship.python.net/crew/atuining/cx_Freeze/).
# Uses the textfile 'comp.txt' and starts a sequence of remotecalls.
#
# Format of 'comp.txt':
# script1.py, destination-folder1
# script2.py, destination-folder2
# script3.py, destination-folder3
# (...)
# Lines with a'#' at the beginning will be ignored
# Runs with 2.4 and higher
'''
The cx_freeze options:
options:
--version show program's version number and exit
-h, --help show this help message and exit
-O optimize generated bytecode as per PYTHONOPTIMIZE; use
-OO in order to remove doc strings
-c, --compress compress byte code in zip files
--base-name=NAME, --base-binary=NAME
file on which to base the target file; if the name of
the file is not an absolute file name, the
subdirectory bases (rooted in the directory in which
the freezer is found) will be searched for a file
matching the name
--init-script=NAME script which will be executed upon startup; if the
name of the file is not an absolute file name, the
subdirectory initscripts (rooted in the directory in
which the freezer is found) will be searched for a
file matching the name
--target-dir=DIR, --install-dir=DIR
the directory in which to place the target file and
any dependent files
--target-name=NAME the name of the file to create instead of the base
name of the script and the extension of the base
binary
--shared-lib-name=NAME
the name of the shared library (DLL) implementing the
Python runtime which is required for a frozen binary
to work
--no-copy-deps, --keep-path
do not copy the dependent files (extensions, shared
libraries, etc.) to the target directory; this also
modifies the default init script to ConsoleKeepPath.py
and means that the target executable requires a Python
installation to execute properly
--default-path=DIRS list of paths separated by the standard path separator
for the platform which will be used to initialize
sys.path prior to running the module finder
--include-path=DIRS list of paths separated by the standard path separator
for the platform which will be used to modify sys.path
prior to running the module finder
--replace-paths=DIRECTIVES
replace all the paths in modules found in the given
paths with the given replacement string; multiple
values are separated by the standard path separator
and each value is of the form path=replacement_string;
path can be * which means all paths not already
specified
--include-modules=NAMES
comma separated list of modules to include
--exclude-modules=NAMES
comma separated list of modules to exclude
--ext-list-file=NAME name of file in which to place the list of dependent
files which were copied into the target directory
-z SPEC, --zip-include=SPEC
name of file to add to the zip file or a specification
of the form name=arcname which will specify the
archive name to use; multiple --zip-include arguments
can be used
'''
##########################################################################################################################
import string,subprocess
freezedir = '/home/PythonScripte/cx_Freeze-3.0.2/FreezePython' # folder of 'FreezePython'
targetdir = " -OO --target-dir='/home/PythonScripte/Executables/'" # destination-folder for the executables
d = open('/home/PythonScripte/comp.txt','r') # the folder of the textfile 'comp.txt'
f = d.readlines()
for fileName in f:
if fileName[0]<>'#':
z = string.find(fileName,'/')
folder = fileName[z:-2]
fileName = fileName[:z-1]
proz = subprocess.Popen(freezedir + targetdir + fileName[:-3] + " '" + folder + fileName + "'",shell=True)