From 5d3bbd92f34b1d594787be9792f05363beab7b1d Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 1 Mar 2014 14:09:48 +0100 Subject: [PATCH 1/5] =?UTF-8?q?Mise=20en=20place=20d'un=20installateur,=20?= =?UTF-8?q?et=20d=C3=A9placement=20des=20donn=C3=A9es=20dans=20un=20endroi?= =?UTF-8?q?t=20portable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #8 --- .gitignore | 2 + readme.md | 13 ++++++- setup.py | 36 ++++++++++++++++++ songbook | 4 +- songbook_core/__init__.py | 11 ++++-- songbook_core/build.py | 6 +-- {share => songbook_core/data}/examples/README | 0 .../data}/examples/example.sb | 0 .../data}/examples/img/README | 0 .../data}/examples/img/treble_a.png | Bin .../data}/examples/latex/README | 0 .../data}/examples/songs/README | 0 .../data}/examples/songs/_lilypond/header | 0 .../songs/chevaliers_de_la_table_ronde.sg | 0 .../data}/examples/songs/example-en.sg | 0 .../data}/examples/songs/example-fr.sg | 0 .../data}/examples/songs/greensleeves.ly | 0 .../data}/examples/songs/greensleeves.sg | 0 .../data}/examples/songs/traditionnel.jpg | Bin .../data}/examples/songs/vent_frais.sg | 0 .../data}/examples/templates/README | 0 .../data}/latex/chords.sty | 0 .../data}/latex/crepbook.cls | 0 {share => songbook_core/data}/latex/songs.sty | 0 .../data}/latex/venturisold.sty | 0 .../data}/latex/xstring.sty | 0 .../data}/templates/default.tmpl | 0 27 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 setup.py rename {share => songbook_core/data}/examples/README (100%) rename {share => songbook_core/data}/examples/example.sb (100%) rename {share => songbook_core/data}/examples/img/README (100%) rename {share => songbook_core/data}/examples/img/treble_a.png (100%) rename {share => songbook_core/data}/examples/latex/README (100%) rename {share => songbook_core/data}/examples/songs/README (100%) rename {share => songbook_core/data}/examples/songs/_lilypond/header (100%) rename {share => songbook_core/data}/examples/songs/chevaliers_de_la_table_ronde.sg (100%) rename {share => songbook_core/data}/examples/songs/example-en.sg (100%) rename {share => songbook_core/data}/examples/songs/example-fr.sg (100%) rename {share => songbook_core/data}/examples/songs/greensleeves.ly (100%) rename {share => songbook_core/data}/examples/songs/greensleeves.sg (100%) rename {share => songbook_core/data}/examples/songs/traditionnel.jpg (100%) rename {share => songbook_core/data}/examples/songs/vent_frais.sg (100%) rename {share => songbook_core/data}/examples/templates/README (100%) rename {share => songbook_core/data}/latex/chords.sty (100%) rename {share => songbook_core/data}/latex/crepbook.cls (100%) rename {share => songbook_core/data}/latex/songs.sty (100%) rename {share => songbook_core/data}/latex/venturisold.sty (100%) rename {share => songbook_core/data}/latex/xstring.sty (100%) rename {share => songbook_core/data}/templates/default.tmpl (100%) diff --git a/.gitignore b/.gitignore index 3bcf8958..18533c63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +deb_dist +build .gitignore *~ *.aux diff --git a/readme.md b/readme.md index 55a97355..502056fa 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,7 @@ Songbook Compilation Chain # Description + This package provides a compilation toolchain that produce LaTeX songbook using the LaTeX songs package. A new LaTeX document class is provided to allow specific customisation and new command like embedded @@ -13,7 +14,9 @@ to the CC-BY-SA licence. Other document are subject to the GNU GPLv2 except if another licence is precised in the header. -# Clone Patacrep repos +# Download + +Clone Patacrep repos: > git clone git://github.com/crep4ever/songbook-core.git > git clone git://github.com/crep4ever/songbook-data.git @@ -28,10 +31,18 @@ Look for existing songbook files in /books. For example: > /songbook /books/songbook_en.sb > songbook_en.pdf +# Quick and dirty deb packages + +Install `python-stdeb`, then: + +> python setup.py --command-packages=stdeb.command bdist_deb +> sudo dpkg -i deb_dist/python-songbook-core_-1_all.deb # Documentation + http://www.patacrep.com/data/documents/doc_en.pdf # Contact & Forums + * http://www.patacrep.com * crep@team-on-fire.com diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..1568b25b --- /dev/null +++ b/setup.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +"""Installation script for songbook. + +$ python setup.py install +""" + +from distutils.core import setup + +import songbook_core + +setup(name='songbook-core', + version=songbook_core.__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'], + license="GPLv2 or any later version", + requires=[ + "argparse", "codecs", "distutils", "fnmatch", "glob", "json", + "locale", "logging", "os", "plasTeX", "re", "subprocess", "sys", + "textwrap", "unidecode" + ], + packages=['songbook_core'], + package_data={'songbook_core': ['*', '*/*', '*/*/*']}, + classifiers=[ + "Environment :: Console", + "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", + "Natural Language :: English", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 2.7", + "Topic :: Utilities", + ], + platforms=["GNU/Linux"], +) diff --git a/songbook b/songbook index 43b0d7ce..9e5e3083 100755 --- a/songbook +++ b/songbook @@ -13,7 +13,7 @@ import textwrap import sys from songbook_core.build import buildsongbook -from songbook_core import __VERSION__ +from songbook_core import __STR_VERSION__ from songbook_core import errors @@ -22,7 +22,7 @@ def argument_parser(args): parser = argparse.ArgumentParser(description="A song book compiler") parser.add_argument('--version', help='Show version', action='version', - version='%(prog)s ' + __VERSION__) + version='%(prog)s ' + __STR_VERSION__) parser.add_argument('book', nargs=1, help=textwrap.dedent("""\ Book to compile. diff --git a/songbook_core/__init__.py b/songbook_core/__init__.py index b580af8b..96f0724e 100644 --- a/songbook_core/__init__.py +++ b/songbook_core/__init__.py @@ -1,11 +1,14 @@ """Global variables.""" +from pkg_resources import resource_filename import os -__VERSION__ = "3.7.2" +# Version + +__VERSION__ = (3, 7, 2) +__STR_VERSION__ = '.'.join([str(number) for number in __VERSION__]) # Directory containing shared data (default templates, custom LaTeX packages, # etc.) -__SHAREDIR__ = os.path.abspath( - os.path.join(os.path.dirname(__file__), "..", "share") - ) + +__DATADIR__ = os.path.abspath(resource_filename(__name__, 'data')) diff --git a/songbook_core/build.py b/songbook_core/build.py index c27dc9e1..e7673f70 100755 --- a/songbook_core/build.py +++ b/songbook_core/build.py @@ -11,7 +11,7 @@ import os.path import re import subprocess -from songbook_core import __SHAREDIR__ +from songbook_core import __DATADIR__ from songbook_core import errors from songbook_core.files import recursive_find from songbook_core.index import process_sxd @@ -127,7 +127,7 @@ def make_tex_file(songbook, output): template = songbook["template"] del songbook["template"] else: - template = os.path.join(__SHAREDIR__, "templates", "default.tmpl") + template = os.path.join(__DATADIR__, "templates", "default.tmpl") if "songs" in songbook: songs = songbook["songs"] del songbook["songs"] @@ -256,7 +256,7 @@ def buildsongbook( if not 'TEXINPUTS' in os.environ.keys(): os.environ['TEXINPUTS'] = '' os.environ['TEXINPUTS'] += os.pathsep + os.path.join( - __SHAREDIR__, + __DATADIR__, 'latex', ) os.environ['TEXINPUTS'] += os.pathsep + os.path.join( diff --git a/share/examples/README b/songbook_core/data/examples/README similarity index 100% rename from share/examples/README rename to songbook_core/data/examples/README diff --git a/share/examples/example.sb b/songbook_core/data/examples/example.sb similarity index 100% rename from share/examples/example.sb rename to songbook_core/data/examples/example.sb diff --git a/share/examples/img/README b/songbook_core/data/examples/img/README similarity index 100% rename from share/examples/img/README rename to songbook_core/data/examples/img/README diff --git a/share/examples/img/treble_a.png b/songbook_core/data/examples/img/treble_a.png similarity index 100% rename from share/examples/img/treble_a.png rename to songbook_core/data/examples/img/treble_a.png diff --git a/share/examples/latex/README b/songbook_core/data/examples/latex/README similarity index 100% rename from share/examples/latex/README rename to songbook_core/data/examples/latex/README diff --git a/share/examples/songs/README b/songbook_core/data/examples/songs/README similarity index 100% rename from share/examples/songs/README rename to songbook_core/data/examples/songs/README diff --git a/share/examples/songs/_lilypond/header b/songbook_core/data/examples/songs/_lilypond/header similarity index 100% rename from share/examples/songs/_lilypond/header rename to songbook_core/data/examples/songs/_lilypond/header diff --git a/share/examples/songs/chevaliers_de_la_table_ronde.sg b/songbook_core/data/examples/songs/chevaliers_de_la_table_ronde.sg similarity index 100% rename from share/examples/songs/chevaliers_de_la_table_ronde.sg rename to songbook_core/data/examples/songs/chevaliers_de_la_table_ronde.sg diff --git a/share/examples/songs/example-en.sg b/songbook_core/data/examples/songs/example-en.sg similarity index 100% rename from share/examples/songs/example-en.sg rename to songbook_core/data/examples/songs/example-en.sg diff --git a/share/examples/songs/example-fr.sg b/songbook_core/data/examples/songs/example-fr.sg similarity index 100% rename from share/examples/songs/example-fr.sg rename to songbook_core/data/examples/songs/example-fr.sg diff --git a/share/examples/songs/greensleeves.ly b/songbook_core/data/examples/songs/greensleeves.ly similarity index 100% rename from share/examples/songs/greensleeves.ly rename to songbook_core/data/examples/songs/greensleeves.ly diff --git a/share/examples/songs/greensleeves.sg b/songbook_core/data/examples/songs/greensleeves.sg similarity index 100% rename from share/examples/songs/greensleeves.sg rename to songbook_core/data/examples/songs/greensleeves.sg diff --git a/share/examples/songs/traditionnel.jpg b/songbook_core/data/examples/songs/traditionnel.jpg similarity index 100% rename from share/examples/songs/traditionnel.jpg rename to songbook_core/data/examples/songs/traditionnel.jpg diff --git a/share/examples/songs/vent_frais.sg b/songbook_core/data/examples/songs/vent_frais.sg similarity index 100% rename from share/examples/songs/vent_frais.sg rename to songbook_core/data/examples/songs/vent_frais.sg diff --git a/share/examples/templates/README b/songbook_core/data/examples/templates/README similarity index 100% rename from share/examples/templates/README rename to songbook_core/data/examples/templates/README diff --git a/share/latex/chords.sty b/songbook_core/data/latex/chords.sty similarity index 100% rename from share/latex/chords.sty rename to songbook_core/data/latex/chords.sty diff --git a/share/latex/crepbook.cls b/songbook_core/data/latex/crepbook.cls similarity index 100% rename from share/latex/crepbook.cls rename to songbook_core/data/latex/crepbook.cls diff --git a/share/latex/songs.sty b/songbook_core/data/latex/songs.sty similarity index 100% rename from share/latex/songs.sty rename to songbook_core/data/latex/songs.sty diff --git a/share/latex/venturisold.sty b/songbook_core/data/latex/venturisold.sty similarity index 100% rename from share/latex/venturisold.sty rename to songbook_core/data/latex/venturisold.sty diff --git a/share/latex/xstring.sty b/songbook_core/data/latex/xstring.sty similarity index 100% rename from share/latex/xstring.sty rename to songbook_core/data/latex/xstring.sty diff --git a/share/templates/default.tmpl b/songbook_core/data/templates/default.tmpl similarity index 100% rename from share/templates/default.tmpl rename to songbook_core/data/templates/default.tmpl From 6a9fe11330922f2beeaba51364ea589457ad0083 Mon Sep 17 00:00:00 2001 From: Luthaf Date: Sun, 2 Mar 2014 20:08:32 +0000 Subject: [PATCH 2/5] =?UTF-8?q?Mise=20=C3=A0=20jour=20du=20script=20d'inst?= =?UTF-8?q?allation.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) mode change 100644 => 100755 setup.py diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 1568b25b..cbcb359a --- a/setup.py +++ b/setup.py @@ -4,7 +4,6 @@ $ python setup.py install """ - from distutils.core import setup import songbook_core @@ -23,7 +22,15 @@ setup(name='songbook-core', "textwrap", "unidecode" ], packages=['songbook_core'], - package_data={'songbook_core': ['*', '*/*', '*/*/*']}, + package_data={'songbook_core': ['data/latex/*', + 'data/templates/*', + 'data/examples/*.sb', + 'data/examples/*/*.sg', + 'data/examples/*/*.ly', + 'data/examples/*/*.jpg', + 'data/examples/*/*.png', + 'data/examples/*/*.png', + 'data/examples/*/*/header']}, classifiers=[ "Environment :: Console", "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", From 9750b49c7451eac7645406f9d741cb727780b42f Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 4 Mar 2014 13:53:07 +0100 Subject: [PATCH 3/5] Pas de support de Python<2.6. #13 --- songbook_core/index.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/songbook_core/index.py b/songbook_core/index.py index 082eec08..bc25bf1c 100644 --- a/songbook_core/index.py +++ b/songbook_core/index.py @@ -163,23 +163,14 @@ class Index(object): @staticmethod def ref_to_str(ref): """Return the LaTeX code corresponding to the reference.""" - if sys.version_info >= (2, 6): - return r'\hyperlink{{{0[link]}}}{{{0[num]}}}'.format(ref) - else: - return r'\hyperlink{%(link)s}{%(num)s}' % ref + return r'\hyperlink{{{0[link]}}}{{{0[num]}}}'.format(ref) def entry_to_str(self, key, entry): """Return the LaTeX code corresponding to the entry.""" - if sys.version_info >= (2, 6): return unicode(r'\idxentry{{{0}}}{{{1}}}' + EOL).format( key, r'\\'.join([self.ref_to_str(ref) for ref in entry]), ) - else: - return unicode(r'\idxentry{%s}{%s}' + EOL) % ( - key, - r'\\'.join([self.ref_to_str(ref) for ref in entry]), - ) def idxblock_to_str(self, letter, entries): """Return the LaTeX code corresponding to an index block. From d6617aaf016ff992b7df9eac344d5bc985e95f5b Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 4 Mar 2014 13:55:06 +0100 Subject: [PATCH 4/5] typo #12 --- songbook_core/index.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/songbook_core/index.py b/songbook_core/index.py index bc25bf1c..c4b0d634 100644 --- a/songbook_core/index.py +++ b/songbook_core/index.py @@ -167,10 +167,10 @@ class Index(object): def entry_to_str(self, key, entry): """Return the LaTeX code corresponding to the entry.""" - return unicode(r'\idxentry{{{0}}}{{{1}}}' + EOL).format( - key, - r'\\'.join([self.ref_to_str(ref) for ref in entry]), - ) + return unicode(r'\idxentry{{{0}}}{{{1}}}' + EOL).format( + key, + r'\\'.join([self.ref_to_str(ref) for ref in entry]), + ) def idxblock_to_str(self, letter, entries): """Return the LaTeX code corresponding to an index block. From eec3039e25be5d9e1953730005058114f93b3a19 Mon Sep 17 00:00:00 2001 From: Luthaf Date: Tue, 4 Mar 2014 14:17:32 +0000 Subject: [PATCH 5/5] Suppression de \songbookstaff --- songbook_core/data/latex/crepbook.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/songbook_core/data/latex/crepbook.cls b/songbook_core/data/latex/crepbook.cls index c9ed4cf8..249fb419 100644 --- a/songbook_core/data/latex/crepbook.cls +++ b/songbook_core/data/latex/crepbook.cls @@ -310,7 +310,7 @@ \fi% % On-the-fly compilation of lilypond files -\epstopdfDeclareGraphicsRule{.ly}{pdf}{.pdf}{lilypond --format=pdf -e '(define-public songbookstaff "")' --output=\Gin@base\ETE@suffix\space #1} +\epstopdfDeclareGraphicsRule{.ly}{pdf}{.pdf}{lilypond --format=pdf --output=\Gin@base\ETE@suffix\space #1} \AppendGraphicsExtensions{.ly} \newcommand{\lilypond}[1]{%