# HG changeset patch # User greg # Date 1200390575 -3600 # Node ID 4630ccf4932ae0a7e8f5640b00ea0aeed92d23d9 # Parent 838e5397ae678d1aee4ff87fe806f73eac9445c2 add setup.py and objdictedit_postinst.py to build windows installer diff -r 838e5397ae67 -r 4630ccf4932a objdictedit_postinst.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/objdictedit_postinst.py Tue Jan 15 10:49:35 2008 +0100 @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# La première ligne doit commencer par #! et contenir python. +# Elle sera adaptée au système de destination automatiquement + +""" This is a part of Beremiz project. + + Post installation script for win32 system + + This script creat a shortcut for objdictedit.py in the desktop and the + start menu, and remove them at the uninstallation + +""" + +import os +import sys + +# Ce script sera aussi lancé lors de la désinstallation. +# Pour n'exécuter du code que lors de l'installation : +if sys.argv[1] == '-install': + # On récupère le dossier où mes fichiers seront installés (dossier où python est aussi installé sous windows) + python_path = sys.prefix + # On récupère le chemin de pythonw.exe (l'exécutable python qui n'affiche pas de console). + # Si vous voulez une console, remplacez pythonw.exe par python.exe + pyw_path = os.path.abspath(os.path.join(python_path, 'pythonw.exe')) + # On récupère le dossier coincoin + objdictedit_dir = os.path.abspath(os.path.join(python_path, 'LOLITech', 'CanFestival-3','objdictgen')) + ############################################################################ + #objdictedit_dir = os.path.abspath(os.path.join(python_path, 'share', \ + #'objdictedit')) + ############################################################################ + # On récupère les chemins de coincoin.py, et de coincoin.ico + # (Ben oui, l'icone est au format ico, oubliez le svg, ici on en est encore à la préhistoire. + # Heureusement que the GIMP sait faire la conversion !) + ico_path = os.path.join(objdictedit_dir, 'objdictedit.ico') + script_path = os.path.join(objdictedit_dir, 'objdictedit.py') + + # Création des raccourcis + # Pour chaque raccourci, on essaye de le faire pour tous les utilisateurs (Windows NT/2000/XP), + # sinon on le fait pour l'utilisateur courant (Windows 95/98/ME) + + # Raccourcis du bureau + # On essaye de trouver un bureau + try: + desktop_path = get_special_folder_path("CSIDL_COMMON_DESKTOPDIRECTORY") + except OSError: + desktop_path = get_special_folder_path("CSIDL_DESKTOPDIRECTORY") + + # On créé le raccourcis + create_shortcut(pyw_path, # programme à lancer + "Can Node Editor", # Description + os.path.join(desktop_path, 'objdictedit.lnk'), # fichier du raccourcis (gardez le .lnk) + script_path, # Argument (script python) + objdictedit_dir, # Dossier courant + ico_path # Fichier de l'icone + ) + # On va cafter au programme de désinstallation qu'on a fait un fichier, pour qu'il soit supprimé + # lors de la désinstallation + file_created(os.path.join(desktop_path, 'objdictedit.lnk')) + + # Raccourcis dans le menu démarrer (idem qu'avant) + try: + start_path = get_special_folder_path("CSIDL_COMMON_PROGRAMS") + except OSError: + start_path = get_special_folder_path("CSIDL_PROGRAMS") + + + + # Création du dossier dans le menu programme + programs_path = os.path.join(start_path, "LOLITech") + try : + os.mkdir(programs_path) + + except OSError: + + pass + directory_created(programs_path) + + create_shortcut(pyw_path, # Cible + "Can Node Editor", #Description + os.path.join(programs_path, 'objdictedit.lnk'), # Fichier + script_path, # Argument + objdictedit_dir, # Dossier de travail + ico_path # Icone + ) + file_created(os.path.join(programs_path, 'objdictedit.lnk')) + + # End (youpi-message) + # Ce message sera affiché (très) furtivement dans l'installateur. + # Vous pouvez vous en servir comme moyen de communication secret, c'est très in. + sys.stdout.write("Shortcuts created.") + # Fin du bidule + sys.exit() diff -r 838e5397ae67 -r 4630ccf4932a setup.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/setup.py Tue Jan 15 10:49:35 2008 +0100 @@ -0,0 +1,40 @@ +import os,sys +from distutils.core import setup + + +install_dir=os.path.join("LOLITech","CanFestival-3") + +data_files=[] +os.getcwd() +os.chdir(os.getcwd()) + +def generate(base_dir): + listfile=[] + if base_dir == "": + directory = "." + else: + directory = base_dir + data_files.append((os.path.join(install_dir, base_dir), listfile)) + + for element in os.listdir(directory): + element_path=os.path.join(base_dir, element) + if os.path.isdir(element_path): + generate(element_path) + elif os.path.isfile(element_path): + ext_element=os.path.splitext(element) + if ext_element[1] != ".o" and ext_element[1] != ".pyc": + listfile.append(element_path) + +generate("") + + +setup(name='CanFestival-3', # Name of the executable + version='0.1', # Version + description='Open-Source CanOpen Stack', #description + author='Edouard Tisserant, Laurent Bessard', + author_email='edouard.tisserant.lolitech.fr, laurent.bessard@lolitech.fr', + url='http://www.canfestival.org', + license='GPL', + scripts=['objdictedit_postinst.py'], + data_files=data_files, # Add files to install +) \ No newline at end of file