#!/usr/bin/python """To use this setup script to install Nicotine: # Install nicotine in regular *nix directories python setup.py install # Create exe files for windows in dist subdir python setup.py py2exe """ import sys import os import glob from distutils.core import setup from distutils.sysconfig import get_python_lib # Are we running windows ? if sys.platform.startswith("win"): is_windows = True else: is_windows = False # If we're on windows, try to load py2exe and detects GTK+ path if is_windows: import _winreg try: import py2exe except ImportError: print "Py2exe is required to build Windows binaries." print "Please go to: http://www.py2exe.org/" sys.exit(1) try: k = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\GTK\\2.0") except EnvironmentError: print "You must install the Gtk+ Runtime Environment to create Windows binaries." print "Please go to: http://sourceforge.net/projects/gtk-win/" sys.exit(1) # Compute data_files (GTK for windows, man and stuff for *nix) files=[] if is_windows: # Get Gtk+ path (we need to copy lib, share and etc subdir to binary path gtkdir = _winreg.QueryValueEx(k, "Path")[0].strip(os.sep) for gtksubdir in ["lib","share","etc"]: gtkdirfull = os.path.join(gtkdir,gtksubdir) skip = len(gtkdirfull)+1 for varroot, vardirs, varfiles in os.walk(gtkdirfull): this = (os.path.join(gtksubdir,varroot[skip:]), [os.path.join(varroot, x) for x in varfiles]) if this[1]: files.append(this) # We need to include libjpeg files.append(("",([os.path.join(gtkdir,'bin','jpeg62.dll')]))) else: # Manuals manpages = glob.glob(os.path.join("manpages", "*.1")) for man in manpages: files.append((os.path.join(sys.prefix, "share", "man", "man1"), [man])) files.append((os.path.join(sys.prefix, "share", "pixmaps"), ["files/nicotine-plus-32px.png"])) files.append((os.path.join(sys.prefix, "share", "applications"), ["files/nicotine.desktop"])) # data_files (translations) mo_dirs = glob.glob(os.path.join("languages", "*")) for mo in mo_dirs: p, lang = os.path.split(mo) if lang in ("msgfmtall.py", "mergeall", "nicotine.pot"): continue if is_windows: files.append((os.path.join("share", "locale", lang, "LC_MESSAGES"), [os.path.join(mo, "nicotine.mo")])) else: files.append((os.path.join(sys.prefix, "share", "locale", lang, "LC_MESSAGES"), [os.path.join(mo, "nicotine.mo")])) # data_files (sounds) sound_dirs = glob.glob(os.path.join("sounds", "*")) for sounds in sound_dirs: p, theme = os.path.split(sounds) for file in ["private.ogg", "room_nick.ogg", "details.txt", "license.txt"]: if is_windows: files.append((os.path.join("share", "nicotine", "sounds", theme), [os.path.join(sounds, file)])) else: files.append((os.path.join(sys.prefix, "share", "nicotine", "sounds", theme), [os.path.join(sounds, file)])) # data_files (documentation) doc_files = glob.glob(os.path.join("doc", "*")) for file in doc_files: if is_windows: files.append((os.path.join("share", "nicotine", "documentation"), [file])) else: files.append((os.path.join(sys.prefix, "share", "nicotine", "documentation"), [file])) if __name__ == '__main__' : LONG_DESCRIPTION = \ """ Nicotine-Plus is a client for SoulSeek filesharing system, forked from Nicotine. """ from pynicotine.utils import version setup(name = "nicotine", version = version, license = "GPLv3", description = "Client for SoulSeek filesharing system.", author = "daelstorm", author_email = "daelstorm@gmail.com", url = "http://www.nicotine-plus.org/", packages = [ 'pynicotine', 'pynicotine.gtkgui' ], scripts = [ 'nicotine','nicotine-import-winconfig'], long_description = LONG_DESCRIPTION, data_files = files, windows = [ { "script": "nicotine", "icon_resources": [(0, "img/ico/nicotine+-.ico")] } ], options = { 'py2exe': { 'packages':'encodings', 'includes': 'cairo, pango, pangocairo, atk, gobject, dbhash', } }, )