#!/usr/bin/python # Copyright (C) 2004 Nicolas Delon # All Rights Reserved # # This file is part of the Prelude program. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to import sys import os import os.path from stat import * import shutil from distutils import sysconfig, dir_util import compileall import py_compile import glob prefix = None for i in range(len(sys.argv)): if sys.argv[i] == "--prefix": prefix = sys.argv[i + 1] if not prefix: prefix = "/usr/local" python_path = "/lib/python%d.%d/" % (sys.version_info[0], sys.version_info[1]) if not os.path.exists(prefix + python_path + "FIC"): dir_util.mkpath(prefix + python_path + "FIC") for file in glob.glob("FIC/*.py"): shutil.copyfile(file, prefix + python_path + file) # we redirect stdout to /dev/null instead of using the "quiet" argument # of compile_dir because it is only available on python2.3 stdout = sys.stdout sys.stdout = open("/dev/null", "w") compileall.compile_dir(prefix + python_path + "FIC") sys.stdout = stdout shutil.copyfile("prelude-fic.py", prefix + python_path + "prelude-fic.py") py_compile.compile(prefix + python_path + "prelude-fic.py") dir_util.mkpath(prefix + "/etc/prelude-fic") if os.path.isfile(prefix + "/etc/prelude-fic/prelude-fic.conf"): shutil.copyfile("prelude-fic.conf", prefix + "/etc/prelude-fic/prelude-fic.conf-dist") else: shutil.copyfile("prelude-fic.conf", prefix + "/etc/prelude-fic/prelude-fic.conf") dir_util.mkpath(prefix + "/bin") file = open(prefix + "/bin/prelude-fic", "w") file.write("""#!/bin/sh cd %s && exec python prelude-fic.py $@ """ % (prefix + python_path)) file.close() os.chmod(prefix + "/bin/prelude-fic", 0755) print "Installation complete."