From 42e7134ccd8ad2e68bb690c0e423d62b57abbd83 Mon Sep 17 00:00:00 2001 From: Luthaf Date: Sat, 12 Apr 2014 18:36:49 +0100 Subject: [PATCH] Creation de liens dans le PATH pour le script songbook. --- setup.py | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 81d5eb62..9afb38db 100755 --- a/setup.py +++ b/setup.py @@ -5,23 +5,59 @@ $ python setup.py install """ from distutils.core import setup +from distutils.command.install import install as _install +from songbook_core import __STR_VERSION__ -import songbook_core +import sys +import os +import site -setup(name='songbook-core', - version=songbook_core.__STR_VERSION__, + +def link_songbook(): + if sys.platform.startswith('darwin'): + source = os.path.join(site.PREFIXES[0], + 'bin', + 'songbook') + dest = '/usr/local/bin/songbook' + if os.path.isfile(dest): + print("File {dest} already exist, skipping.".format(dest=dest)) + else: + os.symlink(source, dest) + elif sys.platform.startswith('win32'): + script = os.path.join(site.PREFIXES[0], + 'Scripts', + 'songbook') + dest = script + '.py' + bat_name = script + '.bat' + if os.path.isfile(dest): + os.unlink(dest) + os.rename(script, dest) + content = "python {songbook} %* \n".format(songbook=dest) + with open(bat_name, 'w') as bat_file: + bat_file.write(content) + + +class install(_install): + def run(self): + _install.run(self) + link_songbook() + + +setup(cmdclass={'install': install}, + name='songbook-core', + version=__STR_VERSION__, description='Songbook compilation chain', author='The Songbook team', author_email='crep@team-on-fire.com', url='https://github.com/patacrep/songbook-core', - scripts=['songbook'], + packages=['songbook_core'], license="GPLv2 or any later version", + scripts=['songbook'], requires=[ "argparse", "codecs", "distutils", "fnmatch", "glob", "json", "locale", "logging", "os", "plasTeX", "re", "subprocess", "sys", "textwrap", "unidecode", "jinja2" ], - packages=['songbook_core'], package_data={'songbook_core': ['data/latex/*', 'data/templates/*', 'data/examples/*.sb', @@ -36,8 +72,10 @@ setup(name='songbook-core', "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", "Natural Language :: English", "Operating System :: POSIX :: Linux", + "Operating System :: Microsoft :: Windows", + "Operating System :: MacOS :: MacOS X" "Programming Language :: Python :: 2.7", "Topic :: Utilities", ], - platforms=["GNU/Linux"], + platforms=["GNU/Linux", "Windows", "MacOsX"], )