From d1b319ae0938e59ac423d8757757ac609f0db2c0 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 15:19:05 +0100
Subject: [PATCH 01/68] Add appveyor config (test under windows)

---
 .appveyor.yml | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 .appveyor.yml

diff --git a/.appveyor.yml b/.appveyor.yml
new file mode 100644
index 00000000..c5aeebe4
--- /dev/null
+++ b/.appveyor.yml
@@ -0,0 +1,41 @@
+environment:
+  # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
+  # /E:ON and /V:ON options are not enabled in the batch script intepreter
+  # See: http://stackoverflow.com/a/13751649/163740
+  CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"
+  TOX_ENV: "pywin"
+
+  matrix:
+    - PYTHON: "C:\\Python27"
+      PYTHON_VERSION: "2.7.8"
+      PYTHON_ARCH: "32"
+
+    - PYTHON: "C:\\Python34"
+      PYTHON_VERSION: "3.4.x" # currently 3.4.3
+      PYTHON_ARCH: "32"
+
+install:
+  # Download setup scripts and unzip
+  - ps: "wget https://github.com/cloudify-cosmo/appveyor-utils/archive/master.zip -OutFile ./master.zip"
+  - "7z e master.zip */appveyor/* -oappveyor"
+
+  # Install Python (from the official .msi of http://python.org) and pip when
+  # not already installed.
+  - "powershell ./appveyor/install.ps1"
+
+  # Prepend newly installed Python to the PATH of this build (this cannot be
+  # done from inside the powershell script as it would require to restart
+  # the parent CMD process).
+  - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
+
+  # Check that we have the expected version and architecture for Python
+  - "python --version"
+  - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
+
+build: false  # Not a C# project, build stuff at the test step instead.
+
+before_test:
+  - "%CMD_IN_ENV% pip install tox"
+
+test_script:
+  - "%CMD_IN_ENV% tox -e %TOX_ENV%"
\ No newline at end of file

From 18a199cdea36f7c03145f90612f0ab64bdd47f75 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 15:26:36 +0100
Subject: [PATCH 02/68] Correct AppVeyor params

---
 .appveyor.yml | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index c5aeebe4..dc312d0a 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -6,10 +6,6 @@ environment:
   TOX_ENV: "pywin"
 
   matrix:
-    - PYTHON: "C:\\Python27"
-      PYTHON_VERSION: "2.7.8"
-      PYTHON_ARCH: "32"
-
     - PYTHON: "C:\\Python34"
       PYTHON_VERSION: "3.4.x" # currently 3.4.3
       PYTHON_ARCH: "32"
@@ -38,4 +34,4 @@ before_test:
   - "%CMD_IN_ENV% pip install tox"
 
 test_script:
-  - "%CMD_IN_ENV% tox -e %TOX_ENV%"
\ No newline at end of file
+  - "%CMD_IN_ENV% tox"
\ No newline at end of file

From 6276cf1ecde4ef188de3c017b532867ffa04a156 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 15:40:18 +0100
Subject: [PATCH 03/68] LaTeX uses '/' for paths, even on windows

---
 patacrep/latex/__init__.py                           | 4 ++++
 patacrep/songs/chordpro/__init__.py                  | 3 ++-
 patacrep/songs/chordpro/data/latex/content_image     | 2 +-
 patacrep/songs/chordpro/data/latex/content_partition | 2 +-
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/patacrep/latex/__init__.py b/patacrep/latex/__init__.py
index d01cfbe5..3ca10d3c 100644
--- a/patacrep/latex/__init__.py
+++ b/patacrep/latex/__init__.py
@@ -29,3 +29,7 @@ def lang2babel(lang):
         available = ", ".join(BABEL_LANGUAGES.keys())
         LOGGER.error('Unknown lang code: ' + lang + '. Supported: ' + available)
         return 'english'
+
+def latexpath(path):
+    """In LaTeX paths use '/' even on windows"""
+    return path.replace('\\', '/')
diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py
index c46a0880..137ca3f4 100644
--- a/patacrep/songs/chordpro/__init__.py
+++ b/patacrep/songs/chordpro/__init__.py
@@ -10,7 +10,7 @@ from patacrep import encoding, files
 from patacrep.songs import Song
 from patacrep.songs.chordpro.syntax import parse_song
 from patacrep.templates import Renderer
-from patacrep.latex import lang2babel
+from patacrep.latex import lang2babel, latexpath
 
 LOGGER = logging.getLogger(__name__)
 
@@ -54,6 +54,7 @@ class ChordproSong(Song):
         jinjaenv.filters['search_image'] = self.search_image
         jinjaenv.filters['search_partition'] = self.search_partition
         jinjaenv.filters['lang2babel'] = lang2babel
+        jinjaenv.filters['latexpath'] = latexpath
 
         try:
             return Renderer(
diff --git a/patacrep/songs/chordpro/data/latex/content_image b/patacrep/songs/chordpro/data/latex/content_image
index ac97404b..71d24f4f 100644
--- a/patacrep/songs/chordpro/data/latex/content_image
+++ b/patacrep/songs/chordpro/data/latex/content_image
@@ -1,5 +1,5 @@
 (* block image *)
-(* set image = content.argument|search_image *)
+(* set image = content.argument|search_image|latexpath *)
 (* if image *)
 \image{(( image ))}
 (*- endif *)
diff --git a/patacrep/songs/chordpro/data/latex/content_partition b/patacrep/songs/chordpro/data/latex/content_partition
index a3c35a3e..d6bcf735 100644
--- a/patacrep/songs/chordpro/data/latex/content_partition
+++ b/patacrep/songs/chordpro/data/latex/content_partition
@@ -1,6 +1,6 @@
 (* block partition *)
 (* set partition = content.argument|search_partition *)
 (* if partition *)
-\lilypond{ ((- content.argument|search_partition -)) }
+\lilypond{ ((- content.argument|search_partition|latexpath -)) }
 (*- endif -*)
 (*- endblock -*)

From c9cb81cb3280d05f1de36ac03b25d323dc9c5b65 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 15:46:08 +0100
Subject: [PATCH 04/68] Forgot one latex path

---
 patacrep/songs/chordpro/data/latex/content_partition | 4 ++--
 patacrep/songs/chordpro/data/latex/song              | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/patacrep/songs/chordpro/data/latex/content_partition b/patacrep/songs/chordpro/data/latex/content_partition
index d6bcf735..b2e4a756 100644
--- a/patacrep/songs/chordpro/data/latex/content_partition
+++ b/patacrep/songs/chordpro/data/latex/content_partition
@@ -1,6 +1,6 @@
 (* block partition *)
-(* set partition = content.argument|search_partition *)
+(* set partition = content.argument|search_partition|latexpath *)
 (* if partition *)
-\lilypond{ ((- content.argument|search_partition|latexpath -)) }
+\lilypond{ ((- partition -)) }
 (*- endif -*)
 (*- endblock -*)
diff --git a/patacrep/songs/chordpro/data/latex/song b/patacrep/songs/chordpro/data/latex/song
index 6f026c79..fffc512d 100644
--- a/patacrep/songs/chordpro/data/latex/song
+++ b/patacrep/songs/chordpro/data/latex/song
@@ -29,7 +29,7 @@
   (* endfor *)
   (* if 'cov' in metadata *)
     (* block cov *)
-      (* set cov = metadata["cov"].argument|search_image *)
+      (* set cov = metadata["cov"].argument|search_image|latexpath *)
       (* if cov *)
     cov={(( cov ))},
       (* endif *)

From 5f878aaca1b3f306f54ba7b65ff87f270cfcbd46 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 16:35:32 +0100
Subject: [PATCH 05/68] Print some info about the windows env

---
 test/test_compilation/test_compilation.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 11bb197b..07c96a60 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -97,6 +97,11 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
     def compile_songbook(songbook, steps=None):
         """Compile songbook, and return the command return code."""
         command = ['python', '-m', 'patacrep.songbook', songbook, '-v']
+        #Windows debugging
+        python_path = subprocess.check_output(['where', 'python'])
+        print(python_path)
+        python_version = subprocess.check_output(['python', '-V'])
+        print(python_version)
         if steps:
             command.extend(['--steps', steps])
 

From 3c03215fa053b40ffb2e15955a6533a1b426dd8e Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 16:40:45 +0100
Subject: [PATCH 06/68] Directly call python

---
 .appveyor.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index dc312d0a..8571274d 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -31,7 +31,7 @@ install:
 build: false  # Not a C# project, build stuff at the test step instead.
 
 before_test:
-  - "%CMD_IN_ENV% pip install tox"
+  - "python pip install tox"
 
 test_script:
-  - "%CMD_IN_ENV% tox"
\ No newline at end of file
+  - "python tox"
\ No newline at end of file

From 1a1c6c56121277af1b1515176fe044e299d82113 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 16:44:28 +0100
Subject: [PATCH 07/68] Wrong commands

---
 .appveyor.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 8571274d..503dc112 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -31,7 +31,7 @@ install:
 build: false  # Not a C# project, build stuff at the test step instead.
 
 before_test:
-  - "python pip install tox"
+  - "pip install tox"
 
 test_script:
-  - "python tox"
\ No newline at end of file
+  - "tox"
\ No newline at end of file

From 4f7123c5c717886c2de8cda9f8cacbd899ec354b Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 16:48:30 +0100
Subject: [PATCH 08/68] Simplify yaml config

---
 .appveyor.yml | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 503dc112..21792cdf 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -1,29 +1,10 @@
 environment:
-  # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
-  # /E:ON and /V:ON options are not enabled in the batch script intepreter
-  # See: http://stackoverflow.com/a/13751649/163740
-  CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"
-  TOX_ENV: "pywin"
-
   matrix:
     - PYTHON: "C:\\Python34"
       PYTHON_VERSION: "3.4.x" # currently 3.4.3
       PYTHON_ARCH: "32"
 
 install:
-  # Download setup scripts and unzip
-  - ps: "wget https://github.com/cloudify-cosmo/appveyor-utils/archive/master.zip -OutFile ./master.zip"
-  - "7z e master.zip */appveyor/* -oappveyor"
-
-  # Install Python (from the official .msi of http://python.org) and pip when
-  # not already installed.
-  - "powershell ./appveyor/install.ps1"
-
-  # Prepend newly installed Python to the PATH of this build (this cannot be
-  # done from inside the powershell script as it would require to restart
-  # the parent CMD process).
-  - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
-
   # Check that we have the expected version and architecture for Python
   - "python --version"
   - "python -c \"import struct; print(struct.calcsize('P') * 8)\""

From cbcc7819eba2df3754d4e93e42b19df1cd203b62 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 16:55:03 +0100
Subject: [PATCH 09/68] Actually pip must be installed...

---
 .appveyor.yml | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/.appveyor.yml b/.appveyor.yml
index 21792cdf..07ae03fd 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -5,6 +5,19 @@ environment:
       PYTHON_ARCH: "32"
 
 install:
+  # Download setup scripts and unzip
+  - ps: "wget https://github.com/cloudify-cosmo/appveyor-utils/archive/master.zip -OutFile ./master.zip"
+  - "7z e master.zip */appveyor/* -oappveyor"
+
+  # Install Python (from the official .msi of http://python.org) and pip when
+  # not already installed.
+  - "powershell ./appveyor/install.ps1"
+
+  # Prepend newly installed Python to the PATH of this build (this cannot be
+  # done from inside the powershell script as it would require to restart
+  # the parent CMD process).
+  - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
+
   # Check that we have the expected version and architecture for Python
   - "python --version"
   - "python -c \"import struct; print(struct.calcsize('P') * 8)\""

From b9ac53f16a74e78108d02f59f41755c1db4bfbc9 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 17:02:43 +0100
Subject: [PATCH 10/68] use sys.executable to call python

---
 test/test_compilation/test_compilation.py | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 07c96a60..2bbccc1d 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -4,6 +4,7 @@
 
 import glob
 import os
+import sys
 import subprocess
 import unittest
 import logging
@@ -96,12 +97,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
     @staticmethod
     def compile_songbook(songbook, steps=None):
         """Compile songbook, and return the command return code."""
-        command = ['python', '-m', 'patacrep.songbook', songbook, '-v']
-        #Windows debugging
-        python_path = subprocess.check_output(['where', 'python'])
-        print(python_path)
-        python_version = subprocess.check_output(['python', '-V'])
-        print(python_version)
+        command = [sys.executable, '-m', 'patacrep.songbook', songbook, '-v']
         if steps:
             command.extend(['--steps', steps])
 

From aac910ec7d2046b551ed67bffc41a3117979a070 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 17:17:28 +0100
Subject: [PATCH 11/68] Use sys.executable everywhere

---
 test/test_compilation/test_compilation.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 2bbccc1d..70c76b7c 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -73,7 +73,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
                     expected = expected.replace(
                         "@DATA_FOLDER@",
                         subprocess.check_output(
-                            ["python", "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'], # pylint: disable=line-too-long
+                            [sys.executable, "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'], # pylint: disable=line-too-long
                             universal_newlines=True,
                             cwd=os.path.dirname(songbook),
                             ).strip(),

From d9d58bcc9382db18e9077e9111049546f9386ced Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 17:17:37 +0100
Subject: [PATCH 12/68] [debug] print sys.path

---
 test/test_compilation/test_compilation.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 70c76b7c..a6952bdc 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -101,6 +101,13 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         if steps:
             command.extend(['--steps', steps])
 
+        syspath = subprocess.check_output([sys.executable, "-c", 'import sys;print(sys.path)'])
+        print("###")
+        print(sys.path)
+        print("#####")
+        print(syspath)
+        print("#######")
+
         try:
             subprocess.check_output(
                 command,

From 542aeaccfdba2dab3c0391ec581ca8d43788186b Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 17:49:32 +0100
Subject: [PATCH 13/68] [debug] add dir command

---
 test/test_compilation/test_compilation.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index a6952bdc..5a208a7c 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -102,10 +102,13 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
             command.extend(['--steps', steps])
 
         syspath = subprocess.check_output([sys.executable, "-c", 'import sys;print(sys.path)'])
-        print("###")
+        dirres = subprocess.check_output(["dir", 'C:\projects\patacrep\.tox\py34\lib\site-packages'])
+        print("## sys.path (internal)")
         print(sys.path)
-        print("#####")
+        print("## sys.path (external)")
         print(syspath)
+        print("### dir site-packages")
+        print(dirres)
         print("#######")
 
         try:

From 392b2399f80066077f9be5b68e0e2f852539d39e Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 17:54:40 +0100
Subject: [PATCH 14/68] Try to import songbook

---
 test/test_compilation/test_compilation.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 5a208a7c..f30201fc 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -101,14 +101,21 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         if steps:
             command.extend(['--steps', steps])
 
-        syspath = subprocess.check_output([sys.executable, "-c", 'import sys;print(sys.path)'])
-        dirres = subprocess.check_output(["dir", 'C:\projects\patacrep\.tox\py34\lib\site-packages'])
         print("## sys.path (internal)")
         print(sys.path)
+
         print("## sys.path (external)")
+        syspath = subprocess.check_output([sys.executable, "-c", 'import sys;print(sys.path)'])
         print(syspath)
+
+        print("## import (external)")
+        extimport = subprocess.check_output([sys.executable, "-c", 'import patacrep.songbook as sb;print(sb)'])
+        print(extimport)
+
         print("### dir site-packages")
+        dirres = subprocess.check_output(["dir", 'C:\projects\patacrep\.tox\py34\lib\site-packages'])
         print(dirres)
+
         print("#######")
 
         try:

From 174a0825ec05783ec7d0231c0788806343429fda Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 18:08:43 +0100
Subject: [PATCH 15/68] [debug] another test

---
 test/test_compilation/test_compilation.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index f30201fc..82bc0ed1 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -112,6 +112,10 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         extimport = subprocess.check_output([sys.executable, "-c", 'import patacrep.songbook as sb;print(sb)'])
         print(extimport)
 
+        print("### empty module")
+        emptymod = subprocess.check_output([sys.executable, "-m", 'patacrep.songbook'])
+        print(emptymod)
+
         print("### dir site-packages")
         dirres = subprocess.check_output(["dir", 'C:\projects\patacrep\.tox\py34\lib\site-packages'])
         print(dirres)

From 93b14db1729de3a8d863a50bc83eadac97eb82bd Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 18:10:59 +0100
Subject: [PATCH 16/68] [debug] inspect the command

---
 test/test_compilation/test_compilation.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 82bc0ed1..622186a8 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -120,6 +120,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         dirres = subprocess.check_output(["dir", 'C:\projects\patacrep\.tox\py34\lib\site-packages'])
         print(dirres)
 
+        print("#######")
+        print(command)
         print("#######")
 
         try:

From 6d080c1724e218941a6b105cbe8d08c68f20e3a5 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 18:13:12 +0100
Subject: [PATCH 17/68] Move debug

---
 test/test_compilation/test_compilation.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 622186a8..8d7fa0c3 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -101,6 +101,10 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         if steps:
             command.extend(['--steps', steps])
 
+        print("#######")
+        print(command)
+        print("#######")
+
         print("## sys.path (internal)")
         print(sys.path)
 
@@ -120,9 +124,6 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         dirres = subprocess.check_output(["dir", 'C:\projects\patacrep\.tox\py34\lib\site-packages'])
         print(dirres)
 
-        print("#######")
-        print(command)
-        print("#######")
 
         try:
             subprocess.check_output(

From 6d09ffa817da4d8836d005b5670251d05d103e6b Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 19:09:58 +0100
Subject: [PATCH 18/68] [debug] more tests

---
 test/test_compilation/test_compilation.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 8d7fa0c3..241dc73b 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -117,8 +117,21 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         print(extimport)
 
         print("### empty module")
-        emptymod = subprocess.check_output([sys.executable, "-m", 'patacrep.songbook'])
-        print(emptymod)
+        try:
+            emptymod = subprocess.check_output([sys.executable, "-m", 'patacrep.songbook', 'test.sb'])
+            print(emptymod)
+        except subprocess.CalledProcessError as error:
+            print(error.output)
+
+        print("### cwd module")
+        try:
+            emptymod = subprocess.check_output(
+                [sys.executable, "-m", 'patacrep.songbook', 'test.sb'],
+                cwd=os.path.dirname(songbook)
+                )
+            print(emptymod)
+        except subprocess.CalledProcessError as error:
+            print(error.output)
 
         print("### dir site-packages")
         dirres = subprocess.check_output(["dir", 'C:\projects\patacrep\.tox\py34\lib\site-packages'])

From aed60df121afbccfe8dc70dbb341541211c59474 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 19:14:51 +0100
Subject: [PATCH 19/68] [debug]stderr to stdout

---
 test/test_compilation/test_compilation.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 241dc73b..ceaf4d01 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -118,7 +118,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
 
         print("### empty module")
         try:
-            emptymod = subprocess.check_output([sys.executable, "-m", 'patacrep.songbook', 'test.sb'])
+            emptymod = subprocess.check_output([sys.executable, "-m", 'patacrep.songbook', 'empty.sb'],
+                stderr=subprocess.STDOUT)
             print(emptymod)
         except subprocess.CalledProcessError as error:
             print(error.output)
@@ -126,7 +127,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         print("### cwd module")
         try:
             emptymod = subprocess.check_output(
-                [sys.executable, "-m", 'patacrep.songbook', 'test.sb'],
+                [sys.executable, "-m", 'patacrep.songbook', 'cwd.sb'],
+                stderr=subprocess.STDOUT,
                 cwd=os.path.dirname(songbook)
                 )
             print(emptymod)

From 972f58d903ae86f3558171bf0e947e32de78ee3f Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 19:19:12 +0100
Subject: [PATCH 20/68] [debug] print sys.path with cwd

---
 test/test_compilation/test_compilation.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index ceaf4d01..6fdaf5be 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -109,7 +109,9 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         print(sys.path)
 
         print("## sys.path (external)")
-        syspath = subprocess.check_output([sys.executable, "-c", 'import sys;print(sys.path)'])
+        syspath = subprocess.check_output([sys.executable, "-c", 'import sys;print(sys.path)'],
+                stderr=subprocess.STDOUT,
+                cwd=os.path.dirname(songbook))
         print(syspath)
 
         print("## import (external)")

From 4e05433a274351435befe43beff71296024c474a Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 19:24:39 +0100
Subject: [PATCH 21/68] [debug] import cwd

---
 test/test_compilation/test_compilation.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 6fdaf5be..b315cce7 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -137,6 +137,17 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         except subprocess.CalledProcessError as error:
             print(error.output)
 
+        print("### import cwd")
+        try:
+            importcwd = subprocess.check_output(
+                [sys.executable, "-c", 'import patacrep.songbook as sb;print(sb)'],
+                stderr=subprocess.STDOUT,
+                cwd=os.path.dirname(songbook)
+                )
+            print(importcwd)
+        except subprocess.CalledProcessError as error:
+            print(error.output)
+
         print("### dir site-packages")
         dirres = subprocess.check_output(["dir", 'C:\projects\patacrep\.tox\py34\lib\site-packages'])
         print(dirres)

From 60fac9d3d41051acc9b3d613e37f056a75b78585 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 19:30:46 +0100
Subject: [PATCH 22/68] [debug] pass the env parameter

---
 test/test_compilation/test_compilation.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index b315cce7..6beb8bc6 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -101,6 +101,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         if steps:
             command.extend(['--steps', steps])
 
+        current_env = os.environ.copy()
+        current_env['PYTHONPATH'] = ':'.join(sys.path)
         print("#######")
         print(command)
         print("#######")
@@ -131,7 +133,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
             emptymod = subprocess.check_output(
                 [sys.executable, "-m", 'patacrep.songbook', 'cwd.sb'],
                 stderr=subprocess.STDOUT,
-                cwd=os.path.dirname(songbook)
+                cwd=os.path.dirname(songbook),
+                env=current_env
                 )
             print(emptymod)
         except subprocess.CalledProcessError as error:
@@ -142,7 +145,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
             importcwd = subprocess.check_output(
                 [sys.executable, "-c", 'import patacrep.songbook as sb;print(sb)'],
                 stderr=subprocess.STDOUT,
-                cwd=os.path.dirname(songbook)
+                cwd=os.path.dirname(songbook),
+                env=current_env
                 )
             print(importcwd)
         except subprocess.CalledProcessError as error:

From 23a99afacf40d77d4a173f99ade853d152349470 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 19:37:11 +0100
Subject: [PATCH 23/68] [debug] strict duplication of current_env

---
 test/test_compilation/test_compilation.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 6beb8bc6..0dc4f5f6 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -102,7 +102,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
             command.extend(['--steps', steps])
 
         current_env = os.environ.copy()
-        current_env['PYTHONPATH'] = ':'.join(sys.path)
+        #current_env['PYTHONPATH'] = ':'.join(sys.path)
         print("#######")
         print(command)
         print("#######")
@@ -113,7 +113,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         print("## sys.path (external)")
         syspath = subprocess.check_output([sys.executable, "-c", 'import sys;print(sys.path)'],
                 stderr=subprocess.STDOUT,
-                cwd=os.path.dirname(songbook))
+                cwd=os.path.dirname(songbook),
+                env=current_env)
         print(syspath)
 
         print("## import (external)")

From 602f4dfe1b1a3a99a6df160873165d8a24ddd77e Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 19:40:44 +0100
Subject: [PATCH 24/68] [debug] new try

---
 test/test_compilation/test_compilation.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 0dc4f5f6..d0522f84 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -102,7 +102,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
             command.extend(['--steps', steps])
 
         current_env = os.environ.copy()
-        #current_env['PYTHONPATH'] = ':'.join(sys.path)
+        current_env['PYTHONPATH'] = ':'.join(sys.path[1:])
         print("#######")
         print(command)
         print("#######")

From 033064bb987e416355ae426b4c1b4af24c597566 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 19:46:55 +0100
Subject: [PATCH 25/68] test: semicolon as separator

---
 test/test_compilation/test_compilation.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index d0522f84..458736ed 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -102,7 +102,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
             command.extend(['--steps', steps])
 
         current_env = os.environ.copy()
-        current_env['PYTHONPATH'] = ':'.join(sys.path[1:])
+        current_env['PYTHONPATH'] = ';'.join(sys.path[1:])
         print("#######")
         print(command)
         print("#######")

From f037f406843365460118f69e4e9b0e21a6d7176e Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 19:52:22 +0100
Subject: [PATCH 26/68] Last try?

---
 .appveyor.yml                             |  2 +-
 test/test_compilation/test_compilation.py | 64 +++--------------------
 2 files changed, 9 insertions(+), 57 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 07ae03fd..4c4a6949 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -28,4 +28,4 @@ before_test:
   - "pip install tox"
 
 test_script:
-  - "tox"
\ No newline at end of file
+  - "tox"
diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 458736ed..0761d784 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -101,62 +101,13 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         if steps:
             command.extend(['--steps', steps])
 
-        current_env = os.environ.copy()
-        current_env['PYTHONPATH'] = ';'.join(sys.path[1:])
-        print("#######")
-        print(command)
-        print("#######")
-
-        print("## sys.path (internal)")
-        print(sys.path)
-
-        print("## sys.path (external)")
-        syspath = subprocess.check_output([sys.executable, "-c", 'import sys;print(sys.path)'],
-                stderr=subprocess.STDOUT,
-                cwd=os.path.dirname(songbook),
-                env=current_env)
-        print(syspath)
-
-        print("## import (external)")
-        extimport = subprocess.check_output([sys.executable, "-c", 'import patacrep.songbook as sb;print(sb)'])
-        print(extimport)
-
-        print("### empty module")
-        try:
-            emptymod = subprocess.check_output([sys.executable, "-m", 'patacrep.songbook', 'empty.sb'],
-                stderr=subprocess.STDOUT)
-            print(emptymod)
-        except subprocess.CalledProcessError as error:
-            print(error.output)
-
-        print("### cwd module")
-        try:
-            emptymod = subprocess.check_output(
-                [sys.executable, "-m", 'patacrep.songbook', 'cwd.sb'],
-                stderr=subprocess.STDOUT,
-                cwd=os.path.dirname(songbook),
-                env=current_env
-                )
-            print(emptymod)
-        except subprocess.CalledProcessError as error:
-            print(error.output)
-
-        print("### import cwd")
-        try:
-            importcwd = subprocess.check_output(
-                [sys.executable, "-c", 'import patacrep.songbook as sb;print(sb)'],
-                stderr=subprocess.STDOUT,
-                cwd=os.path.dirname(songbook),
-                env=current_env
-                )
-            print(importcwd)
-        except subprocess.CalledProcessError as error:
-            print(error.output)
-
-        print("### dir site-packages")
-        dirres = subprocess.check_output(["dir", 'C:\projects\patacrep\.tox\py34\lib\site-packages'])
-        print(dirres)
-
+        if os.name == 'nt':
+            # On windows, we need to pass the current env as argument
+            current_env = os.environ.copy()
+            # and duplicate the current PythontPath
+            current_env['PYTHONPATH'] = ';'.join(sys.path[1:])
+        else:
+            current_env = None
 
         try:
             subprocess.check_output(
@@ -164,6 +115,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
                 stderr=subprocess.STDOUT,
                 universal_newlines=True,
                 cwd=os.path.dirname(songbook),
+                env=current_env
                 )
             return 0
         except subprocess.CalledProcessError as error:

From 1442a6a3a71a6e5b2231457d0dea6042a212450e Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 21:31:16 +0100
Subject: [PATCH 27/68] Specific path for AppVeyor

---
 test/test_compilation/test_compilation.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 0761d784..7d9bb005 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -101,11 +101,11 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         if steps:
             command.extend(['--steps', steps])
 
-        if os.name == 'nt':
+        if os.name == 'nt' and 'APPVEYOR' in os.environ:
             # On windows, we need to pass the current env as argument
             current_env = os.environ.copy()
-            # and duplicate the current PythontPath
-            current_env['PYTHONPATH'] = ';'.join(sys.path[1:])
+            # Force the pythonpath for AppVeyor
+            current_env['PYTHONPATH'] = 'C:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\'
         else:
             current_env = None
 

From af0b612110c9d3524dfd5c4e0f09b07247d59df9 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 21:49:09 +0100
Subject: [PATCH 28/68] [debug] more tests

---
 test/test_compilation/test_compilation.py | 26 ++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 7d9bb005..24c2a0cc 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -105,10 +105,34 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
             # On windows, we need to pass the current env as argument
             current_env = os.environ.copy()
             # Force the pythonpath for AppVeyor
-            current_env['PYTHONPATH'] = 'C:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\'
+            current_env['PYTHONPATH'] = ';'.join(sys.path[1:])
         else:
             current_env = None
 
+        print("### cwd module")
+        try:
+            emptymod = subprocess.check_output(
+                [sys.executable, "-m", 'patacrep.songbook', 'cwd.sb'],
+                stderr=subprocess.STDOUT,
+                cwd=os.path.dirname(songbook),
+                env=current_env
+                )
+            print(emptymod)
+        except subprocess.CalledProcessError as error:
+            print(error.output)
+
+        print("### import cwd")
+        try:
+            importcwd = subprocess.check_output(
+                [sys.executable, "-c", 'import sys;print(sys.executable)'],
+                stderr=subprocess.STDOUT,
+                cwd=os.path.dirname(songbook),
+                env=current_env
+                )
+            print(importcwd)
+        except subprocess.CalledProcessError as error:
+            print(error.output)
+
         try:
             subprocess.check_output(
                 command,

From 59a1a7aa3acc780e43c07b604ff1165c220667e3 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 21:53:02 +0100
Subject: [PATCH 29/68] Pass APPVEYOR env var

---
 tox.ini | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tox.ini b/tox.ini
index 1b6a3337..99c71416 100644
--- a/tox.ini
+++ b/tox.ini
@@ -7,7 +7,7 @@ envlist = py34, lint
 
 [testenv]
 commands = {envpython} setup.py test
-passenv = TRAVIS
+passenv = TRAVIS APPVEYOR
 deps =
 
 [testenv:lint]

From a3dc85def67b23b31445425dbad6b31d886164a2 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 21:57:35 +0100
Subject: [PATCH 30/68] test root module

---
 test/test_compilation/test_compilation.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 24c2a0cc..b7ec44c3 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -109,6 +109,17 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         else:
             current_env = None
 
+        print("### root module")
+        try:
+            emptymod = subprocess.check_output(
+                [sys.executable, "-m", 'patacrep', 'test'],
+                stderr=subprocess.STDOUT,
+                cwd=os.path.dirname(songbook)
+                )
+            print(emptymod)
+        except subprocess.CalledProcessError as error:
+            print(error.output)
+
         print("### cwd module")
         try:
             emptymod = subprocess.check_output(

From 58c2f3649ca0c19a40600dd40a4aa1b21bb947cf Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 22:12:44 +0100
Subject: [PATCH 31/68] Add __init__.py file

---
 patacrep/songbook/__init__.py             |  0
 test/test_compilation/test_compilation.py | 10 ++++------
 2 files changed, 4 insertions(+), 6 deletions(-)
 create mode 100644 patacrep/songbook/__init__.py

diff --git a/patacrep/songbook/__init__.py b/patacrep/songbook/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index b7ec44c3..194188e2 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -125,20 +125,18 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
             emptymod = subprocess.check_output(
                 [sys.executable, "-m", 'patacrep.songbook', 'cwd.sb'],
                 stderr=subprocess.STDOUT,
-                cwd=os.path.dirname(songbook),
-                env=current_env
+                cwd=os.path.dirname(songbook)
                 )
             print(emptymod)
         except subprocess.CalledProcessError as error:
             print(error.output)
 
-        print("### import cwd")
+        print("### dir module")
         try:
             importcwd = subprocess.check_output(
-                [sys.executable, "-c", 'import sys;print(sys.executable)'],
+                [sys.executable, "-c", 'import patacrep.songbook;import pkgutil;mo=[name for _, name, _ in pkgutil.iter_modules(patacrep.__path__)];print(mo)'],
                 stderr=subprocess.STDOUT,
-                cwd=os.path.dirname(songbook),
-                env=current_env
+                cwd=os.path.dirname(songbook)
                 )
             print(importcwd)
         except subprocess.CalledProcessError as error:

From f50bb9ab84960862ffd3431b13a619de25af1c0a Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 22:16:12 +0100
Subject: [PATCH 32/68] last try bis

---
 test/test_compilation/test_compilation.py | 42 -----------------------
 1 file changed, 42 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 194188e2..70c76b7c 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -101,54 +101,12 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         if steps:
             command.extend(['--steps', steps])
 
-        if os.name == 'nt' and 'APPVEYOR' in os.environ:
-            # On windows, we need to pass the current env as argument
-            current_env = os.environ.copy()
-            # Force the pythonpath for AppVeyor
-            current_env['PYTHONPATH'] = ';'.join(sys.path[1:])
-        else:
-            current_env = None
-
-        print("### root module")
-        try:
-            emptymod = subprocess.check_output(
-                [sys.executable, "-m", 'patacrep', 'test'],
-                stderr=subprocess.STDOUT,
-                cwd=os.path.dirname(songbook)
-                )
-            print(emptymod)
-        except subprocess.CalledProcessError as error:
-            print(error.output)
-
-        print("### cwd module")
-        try:
-            emptymod = subprocess.check_output(
-                [sys.executable, "-m", 'patacrep.songbook', 'cwd.sb'],
-                stderr=subprocess.STDOUT,
-                cwd=os.path.dirname(songbook)
-                )
-            print(emptymod)
-        except subprocess.CalledProcessError as error:
-            print(error.output)
-
-        print("### dir module")
-        try:
-            importcwd = subprocess.check_output(
-                [sys.executable, "-c", 'import patacrep.songbook;import pkgutil;mo=[name for _, name, _ in pkgutil.iter_modules(patacrep.__path__)];print(mo)'],
-                stderr=subprocess.STDOUT,
-                cwd=os.path.dirname(songbook)
-                )
-            print(importcwd)
-        except subprocess.CalledProcessError as error:
-            print(error.output)
-
         try:
             subprocess.check_output(
                 command,
                 stderr=subprocess.STDOUT,
                 universal_newlines=True,
                 cwd=os.path.dirname(songbook),
-                env=current_env
                 )
             return 0
         except subprocess.CalledProcessError as error:

From 8891985a9338ab29e162ef4dccfc11e8272c76d6 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 22:20:54 +0100
Subject: [PATCH 33/68] Force importing patacrep from the right place

---
 test/test_compilation/test_compilation.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 70c76b7c..7d9bb005 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -101,12 +101,21 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         if steps:
             command.extend(['--steps', steps])
 
+        if os.name == 'nt' and 'APPVEYOR' in os.environ:
+            # On windows, we need to pass the current env as argument
+            current_env = os.environ.copy()
+            # Force the pythonpath for AppVeyor
+            current_env['PYTHONPATH'] = 'C:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\'
+        else:
+            current_env = None
+
         try:
             subprocess.check_output(
                 command,
                 stderr=subprocess.STDOUT,
                 universal_newlines=True,
                 cwd=os.path.dirname(songbook),
+                env=current_env
                 )
             return 0
         except subprocess.CalledProcessError as error:

From 8fec83ea91c5b450127dd24c41cfc23d54a65041 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 22:25:56 +0100
Subject: [PATCH 34/68] latexpath is actually path2posix

---
 patacrep/latex/__init__.py                           | 4 ----
 patacrep/songs/chordpro/__init__.py                  | 5 +++--
 patacrep/songs/chordpro/data/latex/content_image     | 2 +-
 patacrep/songs/chordpro/data/latex/content_partition | 2 +-
 patacrep/songs/chordpro/data/latex/song              | 2 +-
 5 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/patacrep/latex/__init__.py b/patacrep/latex/__init__.py
index 3ca10d3c..d01cfbe5 100644
--- a/patacrep/latex/__init__.py
+++ b/patacrep/latex/__init__.py
@@ -29,7 +29,3 @@ def lang2babel(lang):
         available = ", ".join(BABEL_LANGUAGES.keys())
         LOGGER.error('Unknown lang code: ' + lang + '. Supported: ' + available)
         return 'english'
-
-def latexpath(path):
-    """In LaTeX paths use '/' even on windows"""
-    return path.replace('\\', '/')
diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py
index 137ca3f4..3fbed1a7 100644
--- a/patacrep/songs/chordpro/__init__.py
+++ b/patacrep/songs/chordpro/__init__.py
@@ -10,7 +10,8 @@ from patacrep import encoding, files
 from patacrep.songs import Song
 from patacrep.songs.chordpro.syntax import parse_song
 from patacrep.templates import Renderer
-from patacrep.latex import lang2babel, latexpath
+from patacrep.latex import lang2babel
+from patacrep.files import path2posix
 
 LOGGER = logging.getLogger(__name__)
 
@@ -54,7 +55,7 @@ class ChordproSong(Song):
         jinjaenv.filters['search_image'] = self.search_image
         jinjaenv.filters['search_partition'] = self.search_partition
         jinjaenv.filters['lang2babel'] = lang2babel
-        jinjaenv.filters['latexpath'] = latexpath
+        jinjaenv.filters['path2posix'] = path2posix
 
         try:
             return Renderer(
diff --git a/patacrep/songs/chordpro/data/latex/content_image b/patacrep/songs/chordpro/data/latex/content_image
index 71d24f4f..a567730d 100644
--- a/patacrep/songs/chordpro/data/latex/content_image
+++ b/patacrep/songs/chordpro/data/latex/content_image
@@ -1,5 +1,5 @@
 (* block image *)
-(* set image = content.argument|search_image|latexpath *)
+(* set image = content.argument|search_image|path2posix *)
 (* if image *)
 \image{(( image ))}
 (*- endif *)
diff --git a/patacrep/songs/chordpro/data/latex/content_partition b/patacrep/songs/chordpro/data/latex/content_partition
index b2e4a756..6942492a 100644
--- a/patacrep/songs/chordpro/data/latex/content_partition
+++ b/patacrep/songs/chordpro/data/latex/content_partition
@@ -1,5 +1,5 @@
 (* block partition *)
-(* set partition = content.argument|search_partition|latexpath *)
+(* set partition = content.argument|search_partition|path2posix *)
 (* if partition *)
 \lilypond{ ((- partition -)) }
 (*- endif -*)
diff --git a/patacrep/songs/chordpro/data/latex/song b/patacrep/songs/chordpro/data/latex/song
index fffc512d..472f3d3c 100644
--- a/patacrep/songs/chordpro/data/latex/song
+++ b/patacrep/songs/chordpro/data/latex/song
@@ -29,7 +29,7 @@
   (* endfor *)
   (* if 'cov' in metadata *)
     (* block cov *)
-      (* set cov = metadata["cov"].argument|search_image|latexpath *)
+      (* set cov = metadata["cov"].argument|search_image|path2posix *)
       (* if cov *)
     cov={(( cov ))},
       (* endif *)

From 687e4292eab7e5a7099f8f5e2e6ac3a6821d11ae Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 22:28:36 +0100
Subject: [PATCH 35/68] is default.tex in the templates dir?

---
 test/test_compilation/test_compilation.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 7d9bb005..4378eb3e 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -105,9 +105,22 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
             # On windows, we need to pass the current env as argument
             current_env = os.environ.copy()
             # Force the pythonpath for AppVeyor
-            current_env['PYTHONPATH'] = 'C:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\'
+            current_env['PYTHONPATH'] = 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\'
         else:
             current_env = None
+        
+        print("#####")
+        try:
+            cmd = subprocess.check_output(
+                ['dir', 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\'],
+                stderr=subprocess.STDOUT,
+                universal_newlines=True,
+                cwd=os.path.dirname(songbook),
+                env=current_env
+                )
+            print(cmd)
+        except subprocess.CalledProcessError as error:
+            print(error.output)
 
         try:
             subprocess.check_output(

From 62d6b103f0658f3d8e38bc1446b9e8514282100a Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 22:31:36 +0100
Subject: [PATCH 36/68] is default.tex in the templates subdir?

---
 test/test_compilation/test_compilation.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 4378eb3e..cd06e4ec 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -112,7 +112,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         print("#####")
         try:
             cmd = subprocess.check_output(
-                ['dir', 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\'],
+                ['dir', 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\patacrep\\data\\templates'],
                 stderr=subprocess.STDOUT,
                 universal_newlines=True,
                 cwd=os.path.dirname(songbook),

From f6fc38efcbb1ab985eb22153979a9df76cf06cde Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 22:35:27 +0100
Subject: [PATCH 37/68] dir every subdir

---
 test/test_compilation/test_compilation.py | 28 ++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index cd06e4ec..84a457ac 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -112,7 +112,33 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         print("#####")
         try:
             cmd = subprocess.check_output(
-                ['dir', 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\patacrep\\data\\templates'],
+                ['dir', 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\patacrep\\'],
+                stderr=subprocess.STDOUT,
+                universal_newlines=True,
+                cwd=os.path.dirname(songbook),
+                env=current_env
+                )
+            print(cmd)
+        except subprocess.CalledProcessError as error:
+            print(error.output)
+
+        print("######")
+        try:
+            cmd = subprocess.check_output(
+                ['dir', 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\patacrep\\data\\'],
+                stderr=subprocess.STDOUT,
+                universal_newlines=True,
+                cwd=os.path.dirname(songbook),
+                env=current_env
+                )
+            print(cmd)
+        except subprocess.CalledProcessError as error:
+            print(error.output)
+        
+        print("########")
+        try:
+            cmd = subprocess.check_output(
+                ['dir', 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\patacrep\\data\\templates\\'],
                 stderr=subprocess.STDOUT,
                 universal_newlines=True,
                 cwd=os.path.dirname(songbook),

From 7361f836451f7606d936273a86833c5d977cb62f Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 22:39:23 +0100
Subject: [PATCH 38/68] Use path2posix everywhere

---
 test/test_compilation/test_compilation.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 84a457ac..eeac36b3 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -10,6 +10,7 @@ import unittest
 import logging
 
 from patacrep.encoding import open_read
+from patacrep.files import path2posix
 
 from .. import dynamic # pylint: disable=unused-import
 
@@ -67,16 +68,18 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
                     expected = expectfile.read().strip()
                     expected = expected.replace(
                         "@TEST_FOLDER@",
-                        os.path.dirname(__file__),
+                        path2posix(os.path.dirname(__file__)),
                         )
 
                     expected = expected.replace(
                         "@DATA_FOLDER@",
-                        subprocess.check_output(
-                            [sys.executable, "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'], # pylint: disable=line-too-long
-                            universal_newlines=True,
-                            cwd=os.path.dirname(songbook),
-                            ).strip(),
+                        path2posix(
+                            subprocess.check_output(
+                                [sys.executable, "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'], # pylint: disable=line-too-long
+                                universal_newlines=True,
+                                cwd=os.path.dirname(songbook),
+                                ).strip()
+                        ),
                         )
 
                     self.assertMultiLineEqual(

From 7febe81213bcf4d5858d4d34ea30d3ea8bab001e Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 23:31:54 +0100
Subject: [PATCH 39/68] Move the jinja templates into the data folder

---
 patacrep/__init__.py                                       | 7 ++++++-
 .../ast_templates/chordpro}/chordpro/content_chord         | 0
 .../ast_templates/chordpro}/chordpro/content_chordlist     | 0
 .../ast_templates/chordpro}/chordpro/content_comment       | 0
 .../ast_templates/chordpro}/chordpro/content_define        | 0
 .../ast_templates/chordpro}/chordpro/content_endofline     | 0
 .../ast_templates/chordpro}/chordpro/content_error         | 0
 .../chordpro}/chordpro/content_guitar_comment              | 0
 .../ast_templates/chordpro}/chordpro/content_image         | 0
 .../ast_templates/chordpro}/chordpro/content_line          | 0
 .../ast_templates/chordpro}/chordpro/content_newline       | 0
 .../ast_templates/chordpro}/chordpro/content_partition     | 0
 .../ast_templates/chordpro}/chordpro/content_space         | 0
 .../ast_templates/chordpro}/chordpro/content_tablature     | 0
 .../ast_templates/chordpro}/chordpro/content_verse         | 0
 .../ast_templates/chordpro}/chordpro/content_word          | 0
 .../data => data/ast_templates/chordpro}/chordpro/song     | 0
 .../ast_templates/chordpro}/chordpro/song_body             | 0
 .../ast_templates/chordpro}/chordpro/song_header           | 0
 .../ast_templates/chordpro}/html/content_chord             | 0
 .../ast_templates/chordpro}/html/content_chordlist         | 0
 .../ast_templates/chordpro}/html/content_comment           | 0
 .../ast_templates/chordpro}/html/content_define            | 0
 .../ast_templates/chordpro}/html/content_define_list       | 0
 .../ast_templates/chordpro}/html/content_endofline         | 0
 .../ast_templates/chordpro}/html/content_error             | 0
 .../ast_templates/chordpro}/html/content_guitar_comment    | 0
 .../ast_templates/chordpro}/html/content_image             | 0
 .../data => data/ast_templates/chordpro}/html/content_line | 0
 .../ast_templates/chordpro}/html/content_metadata_cover    | 0
 .../ast_templates/chordpro}/html/content_newline           | 0
 .../ast_templates/chordpro}/html/content_partition         | 0
 .../ast_templates/chordpro}/html/content_space             | 0
 .../ast_templates/chordpro}/html/content_tablature         | 0
 .../ast_templates/chordpro}/html/content_verse             | 0
 .../data => data/ast_templates/chordpro}/html/content_word | 0
 .../data => data/ast_templates/chordpro}/html/song         | 0
 .../data => data/ast_templates/chordpro}/html/song_body    | 0
 .../data => data/ast_templates/chordpro}/html/song_header  | 0
 .../ast_templates/chordpro}/latex/content_chord            | 0
 .../ast_templates/chordpro}/latex/content_chordlist        | 0
 .../ast_templates/chordpro}/latex/content_comment          | 0
 .../ast_templates/chordpro}/latex/content_define           | 0
 .../ast_templates/chordpro}/latex/content_endofline        | 0
 .../ast_templates/chordpro}/latex/content_error            | 0
 .../ast_templates/chordpro}/latex/content_guitar_comment   | 0
 .../ast_templates/chordpro}/latex/content_image            | 0
 .../ast_templates/chordpro}/latex/content_line             | 0
 .../ast_templates/chordpro}/latex/content_newline          | 0
 .../ast_templates/chordpro}/latex/content_partition        | 0
 .../ast_templates/chordpro}/latex/content_space            | 0
 .../ast_templates/chordpro}/latex/content_tablature        | 0
 .../ast_templates/chordpro}/latex/content_verse            | 0
 .../ast_templates/chordpro}/latex/content_word             | 0
 .../data => data/ast_templates/chordpro}/latex/song        | 0
 .../data => data/ast_templates/chordpro}/latex/song_body   | 0
 patacrep/songs/chordpro/__init__.py                        | 5 ++---
 setup.py                                                   | 7 ++++++-
 58 files changed, 14 insertions(+), 5 deletions(-)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_chord (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_chordlist (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_comment (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_define (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_endofline (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_error (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_guitar_comment (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_image (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_line (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_newline (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_partition (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_space (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_tablature (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_verse (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/content_word (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/song (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/song_body (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/chordpro/song_header (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_chord (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_chordlist (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_comment (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_define (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_define_list (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_endofline (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_error (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_guitar_comment (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_image (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_line (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_metadata_cover (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_newline (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_partition (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_space (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_tablature (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_verse (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/content_word (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/song (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/song_body (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/html/song_header (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_chord (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_chordlist (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_comment (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_define (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_endofline (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_error (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_guitar_comment (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_image (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_line (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_newline (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_partition (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_space (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_tablature (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_verse (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/content_word (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/song (100%)
 rename patacrep/{songs/chordpro/data => data/ast_templates/chordpro}/latex/song_body (100%)

diff --git a/patacrep/__init__.py b/patacrep/__init__.py
index e63b5123..0b839a45 100644
--- a/patacrep/__init__.py
+++ b/patacrep/__init__.py
@@ -16,4 +16,9 @@ __version__ = '.'.join([str(number) for number in __TUPLE_VERSION__])
 # Directory containing shared data (default templates, custom LaTeX packages,
 # etc.)
 
-__DATADIR__ = os.path.abspath(resource_filename(__name__, 'data'))
+_ROOT = os.path.abspath(os.path.dirname(__file__))
+def pkg_datapath(path=''):
+    """Return the package data path"""
+    return os.path.join(_ROOT, 'data', path)
+
+__DATADIR__ = os.path.abspath(pkg_datapath())
diff --git a/patacrep/songs/chordpro/data/chordpro/content_chord b/patacrep/data/ast_templates/chordpro/chordpro/content_chord
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_chord
rename to patacrep/data/ast_templates/chordpro/chordpro/content_chord
diff --git a/patacrep/songs/chordpro/data/chordpro/content_chordlist b/patacrep/data/ast_templates/chordpro/chordpro/content_chordlist
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_chordlist
rename to patacrep/data/ast_templates/chordpro/chordpro/content_chordlist
diff --git a/patacrep/songs/chordpro/data/chordpro/content_comment b/patacrep/data/ast_templates/chordpro/chordpro/content_comment
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_comment
rename to patacrep/data/ast_templates/chordpro/chordpro/content_comment
diff --git a/patacrep/songs/chordpro/data/chordpro/content_define b/patacrep/data/ast_templates/chordpro/chordpro/content_define
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_define
rename to patacrep/data/ast_templates/chordpro/chordpro/content_define
diff --git a/patacrep/songs/chordpro/data/chordpro/content_endofline b/patacrep/data/ast_templates/chordpro/chordpro/content_endofline
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_endofline
rename to patacrep/data/ast_templates/chordpro/chordpro/content_endofline
diff --git a/patacrep/songs/chordpro/data/chordpro/content_error b/patacrep/data/ast_templates/chordpro/chordpro/content_error
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_error
rename to patacrep/data/ast_templates/chordpro/chordpro/content_error
diff --git a/patacrep/songs/chordpro/data/chordpro/content_guitar_comment b/patacrep/data/ast_templates/chordpro/chordpro/content_guitar_comment
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_guitar_comment
rename to patacrep/data/ast_templates/chordpro/chordpro/content_guitar_comment
diff --git a/patacrep/songs/chordpro/data/chordpro/content_image b/patacrep/data/ast_templates/chordpro/chordpro/content_image
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_image
rename to patacrep/data/ast_templates/chordpro/chordpro/content_image
diff --git a/patacrep/songs/chordpro/data/chordpro/content_line b/patacrep/data/ast_templates/chordpro/chordpro/content_line
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_line
rename to patacrep/data/ast_templates/chordpro/chordpro/content_line
diff --git a/patacrep/songs/chordpro/data/chordpro/content_newline b/patacrep/data/ast_templates/chordpro/chordpro/content_newline
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_newline
rename to patacrep/data/ast_templates/chordpro/chordpro/content_newline
diff --git a/patacrep/songs/chordpro/data/chordpro/content_partition b/patacrep/data/ast_templates/chordpro/chordpro/content_partition
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_partition
rename to patacrep/data/ast_templates/chordpro/chordpro/content_partition
diff --git a/patacrep/songs/chordpro/data/chordpro/content_space b/patacrep/data/ast_templates/chordpro/chordpro/content_space
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_space
rename to patacrep/data/ast_templates/chordpro/chordpro/content_space
diff --git a/patacrep/songs/chordpro/data/chordpro/content_tablature b/patacrep/data/ast_templates/chordpro/chordpro/content_tablature
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_tablature
rename to patacrep/data/ast_templates/chordpro/chordpro/content_tablature
diff --git a/patacrep/songs/chordpro/data/chordpro/content_verse b/patacrep/data/ast_templates/chordpro/chordpro/content_verse
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_verse
rename to patacrep/data/ast_templates/chordpro/chordpro/content_verse
diff --git a/patacrep/songs/chordpro/data/chordpro/content_word b/patacrep/data/ast_templates/chordpro/chordpro/content_word
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/content_word
rename to patacrep/data/ast_templates/chordpro/chordpro/content_word
diff --git a/patacrep/songs/chordpro/data/chordpro/song b/patacrep/data/ast_templates/chordpro/chordpro/song
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/song
rename to patacrep/data/ast_templates/chordpro/chordpro/song
diff --git a/patacrep/songs/chordpro/data/chordpro/song_body b/patacrep/data/ast_templates/chordpro/chordpro/song_body
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/song_body
rename to patacrep/data/ast_templates/chordpro/chordpro/song_body
diff --git a/patacrep/songs/chordpro/data/chordpro/song_header b/patacrep/data/ast_templates/chordpro/chordpro/song_header
similarity index 100%
rename from patacrep/songs/chordpro/data/chordpro/song_header
rename to patacrep/data/ast_templates/chordpro/chordpro/song_header
diff --git a/patacrep/songs/chordpro/data/html/content_chord b/patacrep/data/ast_templates/chordpro/html/content_chord
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_chord
rename to patacrep/data/ast_templates/chordpro/html/content_chord
diff --git a/patacrep/songs/chordpro/data/html/content_chordlist b/patacrep/data/ast_templates/chordpro/html/content_chordlist
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_chordlist
rename to patacrep/data/ast_templates/chordpro/html/content_chordlist
diff --git a/patacrep/songs/chordpro/data/html/content_comment b/patacrep/data/ast_templates/chordpro/html/content_comment
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_comment
rename to patacrep/data/ast_templates/chordpro/html/content_comment
diff --git a/patacrep/songs/chordpro/data/html/content_define b/patacrep/data/ast_templates/chordpro/html/content_define
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_define
rename to patacrep/data/ast_templates/chordpro/html/content_define
diff --git a/patacrep/songs/chordpro/data/html/content_define_list b/patacrep/data/ast_templates/chordpro/html/content_define_list
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_define_list
rename to patacrep/data/ast_templates/chordpro/html/content_define_list
diff --git a/patacrep/songs/chordpro/data/html/content_endofline b/patacrep/data/ast_templates/chordpro/html/content_endofline
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_endofline
rename to patacrep/data/ast_templates/chordpro/html/content_endofline
diff --git a/patacrep/songs/chordpro/data/html/content_error b/patacrep/data/ast_templates/chordpro/html/content_error
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_error
rename to patacrep/data/ast_templates/chordpro/html/content_error
diff --git a/patacrep/songs/chordpro/data/html/content_guitar_comment b/patacrep/data/ast_templates/chordpro/html/content_guitar_comment
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_guitar_comment
rename to patacrep/data/ast_templates/chordpro/html/content_guitar_comment
diff --git a/patacrep/songs/chordpro/data/html/content_image b/patacrep/data/ast_templates/chordpro/html/content_image
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_image
rename to patacrep/data/ast_templates/chordpro/html/content_image
diff --git a/patacrep/songs/chordpro/data/html/content_line b/patacrep/data/ast_templates/chordpro/html/content_line
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_line
rename to patacrep/data/ast_templates/chordpro/html/content_line
diff --git a/patacrep/songs/chordpro/data/html/content_metadata_cover b/patacrep/data/ast_templates/chordpro/html/content_metadata_cover
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_metadata_cover
rename to patacrep/data/ast_templates/chordpro/html/content_metadata_cover
diff --git a/patacrep/songs/chordpro/data/html/content_newline b/patacrep/data/ast_templates/chordpro/html/content_newline
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_newline
rename to patacrep/data/ast_templates/chordpro/html/content_newline
diff --git a/patacrep/songs/chordpro/data/html/content_partition b/patacrep/data/ast_templates/chordpro/html/content_partition
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_partition
rename to patacrep/data/ast_templates/chordpro/html/content_partition
diff --git a/patacrep/songs/chordpro/data/html/content_space b/patacrep/data/ast_templates/chordpro/html/content_space
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_space
rename to patacrep/data/ast_templates/chordpro/html/content_space
diff --git a/patacrep/songs/chordpro/data/html/content_tablature b/patacrep/data/ast_templates/chordpro/html/content_tablature
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_tablature
rename to patacrep/data/ast_templates/chordpro/html/content_tablature
diff --git a/patacrep/songs/chordpro/data/html/content_verse b/patacrep/data/ast_templates/chordpro/html/content_verse
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_verse
rename to patacrep/data/ast_templates/chordpro/html/content_verse
diff --git a/patacrep/songs/chordpro/data/html/content_word b/patacrep/data/ast_templates/chordpro/html/content_word
similarity index 100%
rename from patacrep/songs/chordpro/data/html/content_word
rename to patacrep/data/ast_templates/chordpro/html/content_word
diff --git a/patacrep/songs/chordpro/data/html/song b/patacrep/data/ast_templates/chordpro/html/song
similarity index 100%
rename from patacrep/songs/chordpro/data/html/song
rename to patacrep/data/ast_templates/chordpro/html/song
diff --git a/patacrep/songs/chordpro/data/html/song_body b/patacrep/data/ast_templates/chordpro/html/song_body
similarity index 100%
rename from patacrep/songs/chordpro/data/html/song_body
rename to patacrep/data/ast_templates/chordpro/html/song_body
diff --git a/patacrep/songs/chordpro/data/html/song_header b/patacrep/data/ast_templates/chordpro/html/song_header
similarity index 100%
rename from patacrep/songs/chordpro/data/html/song_header
rename to patacrep/data/ast_templates/chordpro/html/song_header
diff --git a/patacrep/songs/chordpro/data/latex/content_chord b/patacrep/data/ast_templates/chordpro/latex/content_chord
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_chord
rename to patacrep/data/ast_templates/chordpro/latex/content_chord
diff --git a/patacrep/songs/chordpro/data/latex/content_chordlist b/patacrep/data/ast_templates/chordpro/latex/content_chordlist
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_chordlist
rename to patacrep/data/ast_templates/chordpro/latex/content_chordlist
diff --git a/patacrep/songs/chordpro/data/latex/content_comment b/patacrep/data/ast_templates/chordpro/latex/content_comment
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_comment
rename to patacrep/data/ast_templates/chordpro/latex/content_comment
diff --git a/patacrep/songs/chordpro/data/latex/content_define b/patacrep/data/ast_templates/chordpro/latex/content_define
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_define
rename to patacrep/data/ast_templates/chordpro/latex/content_define
diff --git a/patacrep/songs/chordpro/data/latex/content_endofline b/patacrep/data/ast_templates/chordpro/latex/content_endofline
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_endofline
rename to patacrep/data/ast_templates/chordpro/latex/content_endofline
diff --git a/patacrep/songs/chordpro/data/latex/content_error b/patacrep/data/ast_templates/chordpro/latex/content_error
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_error
rename to patacrep/data/ast_templates/chordpro/latex/content_error
diff --git a/patacrep/songs/chordpro/data/latex/content_guitar_comment b/patacrep/data/ast_templates/chordpro/latex/content_guitar_comment
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_guitar_comment
rename to patacrep/data/ast_templates/chordpro/latex/content_guitar_comment
diff --git a/patacrep/songs/chordpro/data/latex/content_image b/patacrep/data/ast_templates/chordpro/latex/content_image
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_image
rename to patacrep/data/ast_templates/chordpro/latex/content_image
diff --git a/patacrep/songs/chordpro/data/latex/content_line b/patacrep/data/ast_templates/chordpro/latex/content_line
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_line
rename to patacrep/data/ast_templates/chordpro/latex/content_line
diff --git a/patacrep/songs/chordpro/data/latex/content_newline b/patacrep/data/ast_templates/chordpro/latex/content_newline
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_newline
rename to patacrep/data/ast_templates/chordpro/latex/content_newline
diff --git a/patacrep/songs/chordpro/data/latex/content_partition b/patacrep/data/ast_templates/chordpro/latex/content_partition
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_partition
rename to patacrep/data/ast_templates/chordpro/latex/content_partition
diff --git a/patacrep/songs/chordpro/data/latex/content_space b/patacrep/data/ast_templates/chordpro/latex/content_space
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_space
rename to patacrep/data/ast_templates/chordpro/latex/content_space
diff --git a/patacrep/songs/chordpro/data/latex/content_tablature b/patacrep/data/ast_templates/chordpro/latex/content_tablature
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_tablature
rename to patacrep/data/ast_templates/chordpro/latex/content_tablature
diff --git a/patacrep/songs/chordpro/data/latex/content_verse b/patacrep/data/ast_templates/chordpro/latex/content_verse
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_verse
rename to patacrep/data/ast_templates/chordpro/latex/content_verse
diff --git a/patacrep/songs/chordpro/data/latex/content_word b/patacrep/data/ast_templates/chordpro/latex/content_word
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/content_word
rename to patacrep/data/ast_templates/chordpro/latex/content_word
diff --git a/patacrep/songs/chordpro/data/latex/song b/patacrep/data/ast_templates/chordpro/latex/song
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/song
rename to patacrep/data/ast_templates/chordpro/latex/song
diff --git a/patacrep/songs/chordpro/data/latex/song_body b/patacrep/data/ast_templates/chordpro/latex/song_body
similarity index 100%
rename from patacrep/songs/chordpro/data/latex/song_body
rename to patacrep/data/ast_templates/chordpro/latex/song_body
diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py
index 3fbed1a7..abdd8438 100644
--- a/patacrep/songs/chordpro/__init__.py
+++ b/patacrep/songs/chordpro/__init__.py
@@ -4,9 +4,8 @@ from jinja2 import Environment, FileSystemLoader, contextfunction, ChoiceLoader
 import jinja2
 import logging
 import os
-from pkg_resources import resource_filename
 
-from patacrep import encoding, files
+from patacrep import encoding, files, pkg_datapath
 from patacrep.songs import Song
 from patacrep.songs.chordpro.syntax import parse_song
 from patacrep.templates import Renderer
@@ -49,7 +48,7 @@ class ChordproSong(Song):
                 self.get_datadirs(os.path.join("templates", self.output_language))
             ),
             FileSystemLoader(
-                os.path.join(resource_filename(__name__, 'data'), self.output_language)
+                os.path.join(pkg_datapath('ast_templates'), 'chordpro', self.output_language)
             ),
             ]))
         jinjaenv.filters['search_image'] = self.search_image
diff --git a/setup.py b/setup.py
index 4cfaeda0..023201eb 100755
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,12 @@ setup(
         "unidecode", "jinja2", "chardet", "ply",
         ],
     setup_requires=["hgtools"],
-    include_package_data=True,
+    package_data={'patacrep': [
+        'data/ast_templates/*/*/*',
+        'data/img/*',
+        'data/latex/*',
+        'data/templates/*',
+        ]},
     entry_points={
         'console_scripts': [
             "songbook = patacrep.songbook.__main__:main",

From a06f45e3c9a97b50f94f6a7168f61c0969c6c744 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 23:34:41 +0100
Subject: [PATCH 40/68] test with standard env

---
 test/test_compilation/test_compilation.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index eeac36b3..4d308914 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -108,7 +108,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
             # On windows, we need to pass the current env as argument
             current_env = os.environ.copy()
             # Force the pythonpath for AppVeyor
-            current_env['PYTHONPATH'] = 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\'
+            #current_env['PYTHONPATH'] = 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\'
         else:
             current_env = None
         

From 0a3b11481f2e96412a42c1f44e81280d0f7c404f Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 23:37:55 +0100
Subject: [PATCH 41/68] Clean debug

---
 test/test_compilation/test_compilation.py | 47 -----------------------
 1 file changed, 47 deletions(-)

diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index 4d308914..ab032389 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -104,53 +104,6 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
         if steps:
             command.extend(['--steps', steps])
 
-        if os.name == 'nt' and 'APPVEYOR' in os.environ:
-            # On windows, we need to pass the current env as argument
-            current_env = os.environ.copy()
-            # Force the pythonpath for AppVeyor
-            #current_env['PYTHONPATH'] = 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\'
-        else:
-            current_env = None
-        
-        print("#####")
-        try:
-            cmd = subprocess.check_output(
-                ['dir', 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\patacrep\\'],
-                stderr=subprocess.STDOUT,
-                universal_newlines=True,
-                cwd=os.path.dirname(songbook),
-                env=current_env
-                )
-            print(cmd)
-        except subprocess.CalledProcessError as error:
-            print(error.output)
-
-        print("######")
-        try:
-            cmd = subprocess.check_output(
-                ['dir', 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\patacrep\\data\\'],
-                stderr=subprocess.STDOUT,
-                universal_newlines=True,
-                cwd=os.path.dirname(songbook),
-                env=current_env
-                )
-            print(cmd)
-        except subprocess.CalledProcessError as error:
-            print(error.output)
-        
-        print("########")
-        try:
-            cmd = subprocess.check_output(
-                ['dir', 'c:\\projects\\patacrep\\.tox\\py34\\lib\\site-packages\\patacrep\\data\\templates\\'],
-                stderr=subprocess.STDOUT,
-                universal_newlines=True,
-                cwd=os.path.dirname(songbook),
-                env=current_env
-                )
-            print(cmd)
-        except subprocess.CalledProcessError as error:
-            print(error.output)
-
         try:
             subprocess.check_output(
                 command,

From b96fc1675f7ba2f56a98b453ca2a2d6d11b87241 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 23:41:13 +0100
Subject: [PATCH 42/68] Quick fixes

---
 patacrep/content/song.py                  | 2 +-
 test/test_compilation/test_compilation.py | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/patacrep/content/song.py b/patacrep/content/song.py
index 71473aa8..4f9ab809 100755
--- a/patacrep/content/song.py
+++ b/patacrep/content/song.py
@@ -42,7 +42,7 @@ class SongRenderer(Content):
                 {song}
                 """).format(
                     separator="%"*80,
-                    path=self.song.subpath,
+                    path=files.path2posix(self.song.subpath),
                     song=self.song.render(output=context['filename']),
                 )
 
diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index ab032389..bcdb365b 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -109,8 +109,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
                 command,
                 stderr=subprocess.STDOUT,
                 universal_newlines=True,
-                cwd=os.path.dirname(songbook),
-                env=current_env
+                cwd=os.path.dirname(songbook)
                 )
             return 0
         except subprocess.CalledProcessError as error:

From 5e711692331dac02c728d25ea182995a3f82b6ac Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 23:51:00 +0100
Subject: [PATCH 43/68] Force the folder for the compilation

---
 patacrep/build.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/patacrep/build.py b/patacrep/build.py
index 00be667e..2ad9b3f5 100644
--- a/patacrep/build.py
+++ b/patacrep/build.py
@@ -224,6 +224,7 @@ class SongbookBuilder(object):
                 stdout=PIPE,
                 stderr=PIPE,
                 env=os.environ,
+                cwd=os.getcwd(),
                 universal_newlines=True,
                 )
         except Exception as error:

From 5cd1f1bfac66cf333150689ce27661e279586e10 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 23:52:19 +0100
Subject: [PATCH 44/68] Correct pfdlatex error msg

---
 patacrep/errors.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/patacrep/errors.py b/patacrep/errors.py
index 5ec9fd9b..d48f8e1f 100644
--- a/patacrep/errors.py
+++ b/patacrep/errors.py
@@ -47,7 +47,7 @@ class LatexCompilationError(StepError):
     def __init__(self, basename):
         super(LatexCompilationError, self).__init__(
             (
-                """Error while pdfLaTeX compilation of "{basename}.tex" """
+                """Error while LaTeX compilation of "{basename}.tex" """
                 """(see {basename}.log for more information)."""
                 ).format(basename=basename)
             )

From f858fdadfdf464482b00721d7791490aec65ba88 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Thu, 29 Oct 2015 23:56:46 +0100
Subject: [PATCH 45/68] More verbose error

---
 patacrep/build.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/patacrep/build.py b/patacrep/build.py
index 2ad9b3f5..4c52c589 100644
--- a/patacrep/build.py
+++ b/patacrep/build.py
@@ -229,6 +229,13 @@ class SongbookBuilder(object):
                 )
         except Exception as error:
             LOGGER.debug(error)
+            LOGGER.debug(os.getcwd())
+            import subprocess
+            LOGGER.debug(subprocess.check_output(
+                ['dir', os.getcwd()],
+                stderr=subprocess.STDOUT,
+                universal_newlines=True
+                ))
             raise errors.LatexCompilationError(self.basename)
 
         if not self.interactive:

From 2a421802499e7a1aa7389b48cc4c3cd7ae851528 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 00:03:49 +0100
Subject: [PATCH 46/68] Try to make lualatex more verbose

---
 patacrep/build.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/patacrep/build.py b/patacrep/build.py
index 4c52c589..2fb134fb 100644
--- a/patacrep/build.py
+++ b/patacrep/build.py
@@ -164,6 +164,7 @@ class SongbookBuilder(object):
 
     def _set_latex(self):
         """Set LaTeX options."""
+        self._lualatex_options.append("--file-line-error")
         if self.unsafe:
             self._lualatex_options.append("--shell-escape")
         if not self.interactive:

From 356aa455b5fdcc2c047da15d4be62ac84a07d54d Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 07:48:37 +0100
Subject: [PATCH 47/68] Correct pkg_datapath

---
 patacrep/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/patacrep/__init__.py b/patacrep/__init__.py
index 0b839a45..13e74a66 100644
--- a/patacrep/__init__.py
+++ b/patacrep/__init__.py
@@ -16,9 +16,9 @@ __version__ = '.'.join([str(number) for number in __TUPLE_VERSION__])
 # Directory containing shared data (default templates, custom LaTeX packages,
 # etc.)
 
-_ROOT = os.path.abspath(os.path.dirname(__file__))
+_ROOT = os.path.abspath(resource_filename(__name__, 'data'))
 def pkg_datapath(path=''):
     """Return the package data path"""
-    return os.path.join(_ROOT, 'data', path)
+    return os.path.join(_ROOT, path)
 
 __DATADIR__ = os.path.abspath(pkg_datapath())

From d263f0475849883041b0ccbd356a4527d9d28d1e Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 07:55:27 +0100
Subject: [PATCH 48/68] Try to install miktex with chocolatey

---
 .appveyor.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.appveyor.yml b/.appveyor.yml
index 4c4a6949..0b72b29b 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -22,6 +22,10 @@ install:
   - "python --version"
   - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
 
+  # Install miktex
+  - cmd: choco install miktex
+  - "lualatex --version"
+
 build: false  # Not a C# project, build stuff at the test step instead.
 
 before_test:

From fabe56ef9dd475f13eeea2fffefd976d43f1821d Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 08:05:42 +0100
Subject: [PATCH 49/68] Try to localize MikTex

---
 .appveyor.yml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/.appveyor.yml b/.appveyor.yml
index 0b72b29b..dc7e7b81 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -24,6 +24,11 @@ install:
 
   # Install miktex
   - cmd: choco install miktex
+  - cmd: dir C:\ProgramData\chocolatey\bin
+  - cmd: dir C:\ProgramData\chocolatey\lib
+  - cmd: dir %APPDATA%
+  - cmd: dir %APPDATA%\MiKTeX
+  - cmd: dir %APPDATA%\MiKTeX\2.9
   - "lualatex --version"
 
 build: false  # Not a C# project, build stuff at the test step instead.

From 60d5a3821ff671fea88ef8bbd0c2529cc4f5d14d Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 09:44:25 +0100
Subject: [PATCH 50/68] Separatate chocolatey installation

---
 .appveyor.choco.cmd | 1 +
 .appveyor.yml       | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 .appveyor.choco.cmd

diff --git a/.appveyor.choco.cmd b/.appveyor.choco.cmd
new file mode 100644
index 00000000..0238c676
--- /dev/null
+++ b/.appveyor.choco.cmd
@@ -0,0 +1 @@
+choco install miktex
\ No newline at end of file
diff --git a/.appveyor.yml b/.appveyor.yml
index dc7e7b81..27ad535d 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -22,8 +22,8 @@ install:
   - "python --version"
   - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
 
-  # Install miktex
-  - cmd: choco install miktex
+  # Install Chocolatey packages (miktex)
+  - cmd: C:\projects\patacrep\.appveyor.choco.cmd
   - cmd: dir C:\ProgramData\chocolatey\bin
   - cmd: dir C:\ProgramData\chocolatey\lib
   - cmd: dir %APPDATA%
@@ -38,3 +38,8 @@ before_test:
 
 test_script:
   - "tox"
+
+# Cache Chocolatey packages
+cache:
+- C:\ProgramData\chocolatey\bin -> .appveyor.choch.cmd
+- C:\ProgramData\chocolatey\lib -> .appveyor.choch.cmd

From 5b49aa7b55855db3c1a958a4f8929ef6bc4e61f9 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 10:11:32 +0100
Subject: [PATCH 51/68] Further exploration

---
 .appveyor.yml | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 27ad535d..b6e34a1d 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -24,11 +24,10 @@ install:
 
   # Install Chocolatey packages (miktex)
   - cmd: C:\projects\patacrep\.appveyor.choco.cmd
-  - cmd: dir C:\ProgramData\chocolatey\bin
   - cmd: dir C:\ProgramData\chocolatey\lib
-  - cmd: dir %APPDATA%
-  - cmd: dir %APPDATA%\MiKTeX
-  - cmd: dir %APPDATA%\MiKTeX\2.9
+  - cmd: dir C:\ProgramData\chocolatey\lib\miktex
+  - cmd: dir C:\ProgramData\chocolatey\lib\miktex\bin
+  - cmd: doskey lualatex=C:\ProgramData\chocolatey\lib\miktex\bin\lualatex.exe $*
   - "lualatex --version"
 
 build: false  # Not a C# project, build stuff at the test step instead.

From 094352d861462ab1695f66b672148313ddf0d952 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 10:54:46 +0100
Subject: [PATCH 52/68] miktex is maybe somewhere else

---
 .appveyor.yml | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index b6e34a1d..d680f2ac 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -24,10 +24,16 @@ install:
 
   # Install Chocolatey packages (miktex)
   - cmd: C:\projects\patacrep\.appveyor.choco.cmd
+  - cmd: dir %APPDATA%\MiKTeX\2.9
+  - cmd: dir %LOCALAPPDATA%
+  - cmd: dir %LOCALAPPDATA%\MiKTeX
+  - cmd: dir %LOCALAPPDATA%\MiKTeX\2.9
+  - cmd: dir %LOCALAPPDATA%\MiKTeX\2.9\miktex
+  - cmd: dir %LOCALAPPDATA%\MiKTeX\2.9\miktex\bin
   - cmd: dir C:\ProgramData\chocolatey\lib
   - cmd: dir C:\ProgramData\chocolatey\lib\miktex
-  - cmd: dir C:\ProgramData\chocolatey\lib\miktex\bin
-  - cmd: doskey lualatex=C:\ProgramData\chocolatey\lib\miktex\bin\lualatex.exe $*
+  #- cmd: dir C:\ProgramData\chocolatey\lib\miktex\bin
+  - cmd: doskey lualatex=%LOCALAPPDATA%\MiKTeX\2.9\miktex\bin\lualatex.exe $*
   - "lualatex --version"
 
 build: false  # Not a C# project, build stuff at the test step instead.

From ab5951cb4023415f189369eae52bac5af5937577 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 11:10:55 +0100
Subject: [PATCH 53/68] Manual install of miktex

---
 .appveyor.choco.cmd |  1 -
 .appveyor.miktex.ps |  2 ++
 .appveyor.yml       | 16 +++++++---------
 3 files changed, 9 insertions(+), 10 deletions(-)
 delete mode 100644 .appveyor.choco.cmd
 create mode 100644 .appveyor.miktex.ps

diff --git a/.appveyor.choco.cmd b/.appveyor.choco.cmd
deleted file mode 100644
index 0238c676..00000000
--- a/.appveyor.choco.cmd
+++ /dev/null
@@ -1 +0,0 @@
-choco install miktex
\ No newline at end of file
diff --git a/.appveyor.miktex.ps b/.appveyor.miktex.ps
new file mode 100644
index 00000000..2bcafe36
--- /dev/null
+++ b/.appveyor.miktex.ps
@@ -0,0 +1,2 @@
+wget http://ctan.math.washington.edu/tex-archive/systems/win32/miktex/setup/basic-miktex-2.9.5721-x64.exe -OutFile ./basic-miktex.exe
+basic-miktex.exe --unattended --portable --user-config=%LOCALAPPDATA%\MiKTeX\2.9 --user-data=%LOCALAPPDATA%\MiKTeX\2.9 --user-install=%LOCALAPPDATA%\MiKTeX\2.9
\ No newline at end of file
diff --git a/.appveyor.yml b/.appveyor.yml
index d680f2ac..f11c0cb0 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -22,18 +22,17 @@ install:
   - "python --version"
   - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
 
-  # Install Chocolatey packages (miktex)
-  - cmd: C:\projects\patacrep\.appveyor.choco.cmd
-  - cmd: dir %APPDATA%\MiKTeX\2.9
+  # Install miktex
+  - ps: C:\projects\patacrep\.appveyor.miktex.ps
+
   - cmd: dir %LOCALAPPDATA%
   - cmd: dir %LOCALAPPDATA%\MiKTeX
   - cmd: dir %LOCALAPPDATA%\MiKTeX\2.9
   - cmd: dir %LOCALAPPDATA%\MiKTeX\2.9\miktex
   - cmd: dir %LOCALAPPDATA%\MiKTeX\2.9\miktex\bin
-  - cmd: dir C:\ProgramData\chocolatey\lib
-  - cmd: dir C:\ProgramData\chocolatey\lib\miktex
-  #- cmd: dir C:\ProgramData\chocolatey\lib\miktex\bin
+
   - cmd: doskey lualatex=%LOCALAPPDATA%\MiKTeX\2.9\miktex\bin\lualatex.exe $*
+
   - "lualatex --version"
 
 build: false  # Not a C# project, build stuff at the test step instead.
@@ -44,7 +43,6 @@ before_test:
 test_script:
   - "tox"
 
-# Cache Chocolatey packages
+# Cache Miktex install
 cache:
-- C:\ProgramData\chocolatey\bin -> .appveyor.choch.cmd
-- C:\ProgramData\chocolatey\lib -> .appveyor.choch.cmd
+- %LOCALAPPDATA%\MiKTeX\2.9 -> .appveyor.miktex.ps

From 0b87d16101e428694a8e390af18a17390e2281c7 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 11:12:08 +0100
Subject: [PATCH 54/68] fix indentation

---
 .appveyor.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index f11c0cb0..e1ad6a73 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -45,4 +45,4 @@ test_script:
 
 # Cache Miktex install
 cache:
-- %LOCALAPPDATA%\MiKTeX\2.9 -> .appveyor.miktex.ps
+  - %LOCALAPPDATA%\MiKTeX\2.9 -> .appveyor.miktex.ps

From df55da433fce34d7b7da6557fefa5e437a36b256 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 11:13:49 +0100
Subject: [PATCH 55/68] fix caching config

---
 .appveyor.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index e1ad6a73..07846167 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -45,4 +45,4 @@ test_script:
 
 # Cache Miktex install
 cache:
-  - %LOCALAPPDATA%\MiKTeX\2.9 -> .appveyor.miktex.ps
+- C:\Users\appveyor\AppData\Local\MiKTeX\2.9 -> .appveyor.miktex.ps

From 242059fbb642cc80bbb095b16843961e205cb598 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 11:16:41 +0100
Subject: [PATCH 56/68] Change powershell calling

---
 .appveyor.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 07846167..3dda5948 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -23,7 +23,7 @@ install:
   - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
 
   # Install miktex
-  - ps: C:\projects\patacrep\.appveyor.miktex.ps
+  - "powershell C:\projects\patacrep\.appveyor.miktex.ps"
 
   - cmd: dir %LOCALAPPDATA%
   - cmd: dir %LOCALAPPDATA%\MiKTeX

From 441d10119cd70b18035469ab38cb1ef2cefd48ad Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 11:17:26 +0100
Subject: [PATCH 57/68] change slah

---
 .appveyor.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 3dda5948..a50339ba 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -23,7 +23,7 @@ install:
   - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
 
   # Install miktex
-  - "powershell C:\projects\patacrep\.appveyor.miktex.ps"
+  - "powershell C:/projects/patacrep/.appveyor.miktex.ps"
 
   - cmd: dir %LOCALAPPDATA%
   - cmd: dir %LOCALAPPDATA%\MiKTeX

From 5d22b275a1e33f46fefcc3fd8f5d7b400d81f69e Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 11:22:35 +0100
Subject: [PATCH 58/68] donwload and install in yml

---
 .appveyor.miktex.ps | 2 --
 .appveyor.yml       | 5 +++--
 2 files changed, 3 insertions(+), 4 deletions(-)
 delete mode 100644 .appveyor.miktex.ps

diff --git a/.appveyor.miktex.ps b/.appveyor.miktex.ps
deleted file mode 100644
index 2bcafe36..00000000
--- a/.appveyor.miktex.ps
+++ /dev/null
@@ -1,2 +0,0 @@
-wget http://ctan.math.washington.edu/tex-archive/systems/win32/miktex/setup/basic-miktex-2.9.5721-x64.exe -OutFile ./basic-miktex.exe
-basic-miktex.exe --unattended --portable --user-config=%LOCALAPPDATA%\MiKTeX\2.9 --user-data=%LOCALAPPDATA%\MiKTeX\2.9 --user-install=%LOCALAPPDATA%\MiKTeX\2.9
\ No newline at end of file
diff --git a/.appveyor.yml b/.appveyor.yml
index a50339ba..e2ff6abb 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -23,7 +23,8 @@ install:
   - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
 
   # Install miktex
-  - "powershell C:/projects/patacrep/.appveyor.miktex.ps"
+  - ps: "wget http://ctan.math.washington.edu/tex-archive/systems/win32/miktex/setup/basic-miktex-2.9.5721-x64.exe -OutFile ./basic-miktex.exe"
+  - cmd: basic-miktex.exe --unattended --portable --user-config=%LOCALAPPDATA%\MiKTeX\2.9 --user-data=%LOCALAPPDATA%\MiKTeX\2.9 --user-install=%LOCALAPPDATA%\MiKTeX\2.9
 
   - cmd: dir %LOCALAPPDATA%
   - cmd: dir %LOCALAPPDATA%\MiKTeX
@@ -45,4 +46,4 @@ test_script:
 
 # Cache Miktex install
 cache:
-- C:\Users\appveyor\AppData\Local\MiKTeX\2.9 -> .appveyor.miktex.ps
+- C:\Users\appveyor\AppData\Local\MiKTeX\2.9 -> .appveyor.yml

From 8bd9056d1ed62d4810188df5e64fc3c53d80b419 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 11:35:57 +0100
Subject: [PATCH 59/68] Use portable installer

---
 .appveyor.yml | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index e2ff6abb..24542feb 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -23,14 +23,13 @@ install:
   - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
 
   # Install miktex
-  - ps: "wget http://ctan.math.washington.edu/tex-archive/systems/win32/miktex/setup/basic-miktex-2.9.5721-x64.exe -OutFile ./basic-miktex.exe"
-  - cmd: basic-miktex.exe --unattended --portable --user-config=%LOCALAPPDATA%\MiKTeX\2.9 --user-data=%LOCALAPPDATA%\MiKTeX\2.9 --user-install=%LOCALAPPDATA%\MiKTeX\2.9
+  - ps: "wget http://mirrors.ctan.org/systems/win32/miktex/setup/miktex-portable-2.9.5719.exe -OutFile ./basic-miktex.exe"
+  - "7z e basic-miktex.exe * -omiktex"
+  #- cmd: basic-miktex.exe --unattended --portable --user-config=%LOCALAPPDATA%\MiKTeX\2.9 --user-data=%LOCALAPPDATA%\MiKTeX\2.9 --user-install=%LOCALAPPDATA%\MiKTeX\2.9
 
-  - cmd: dir %LOCALAPPDATA%
-  - cmd: dir %LOCALAPPDATA%\MiKTeX
-  - cmd: dir %LOCALAPPDATA%\MiKTeX\2.9
-  - cmd: dir %LOCALAPPDATA%\MiKTeX\2.9\miktex
-  - cmd: dir %LOCALAPPDATA%\MiKTeX\2.9\miktex\bin
+  - cmd: dir .
+  - cmd: dir .\miktex
+  - cmd: dir .\miktex\bin
 
   - cmd: doskey lualatex=%LOCALAPPDATA%\MiKTeX\2.9\miktex\bin\lualatex.exe $*
 
@@ -46,4 +45,4 @@ test_script:
 
 # Cache Miktex install
 cache:
-- C:\Users\appveyor\AppData\Local\MiKTeX\2.9 -> .appveyor.yml
+- C:\Users\appveyor\miktex -> .appveyor.yml

From b64011f562ec13e6cfc0c152e3374898c8f093cc Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 11:40:48 +0100
Subject: [PATCH 60/68] Correct portable extraction

---
 .appveyor.yml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 24542feb..0b07cac4 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -23,13 +23,13 @@ install:
   - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
 
   # Install miktex
-  - ps: "wget http://mirrors.ctan.org/systems/win32/miktex/setup/miktex-portable-2.9.5719.exe -OutFile ./basic-miktex.exe"
-  - "7z e basic-miktex.exe * -omiktex"
+  - ps: "wget http://mirrors.ctan.org/systems/win32/miktex/setup/miktex-portable-2.9.5719.exe -OutFile ./miktex-portable.exe"
+  - "7z x miktex-portable.exe * -aot"
   #- cmd: basic-miktex.exe --unattended --portable --user-config=%LOCALAPPDATA%\MiKTeX\2.9 --user-data=%LOCALAPPDATA%\MiKTeX\2.9 --user-install=%LOCALAPPDATA%\MiKTeX\2.9
 
   - cmd: dir .
-  - cmd: dir .\miktex
-  - cmd: dir .\miktex\bin
+  - cmd: dir .\miktex-portable
+  - cmd: dir .\miktex-portable\bin
 
   - cmd: doskey lualatex=%LOCALAPPDATA%\MiKTeX\2.9\miktex\bin\lualatex.exe $*
 

From 514cca15000b7bdbe992c35395eb6af6a1f60f58 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 11:45:04 +0100
Subject: [PATCH 61/68] Extract in a subfolder

---
 .appveyor.yml | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 0b07cac4..e9feaa1f 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -24,12 +24,13 @@ install:
 
   # Install miktex
   - ps: "wget http://mirrors.ctan.org/systems/win32/miktex/setup/miktex-portable-2.9.5719.exe -OutFile ./miktex-portable.exe"
-  - "7z x miktex-portable.exe * -aot"
+  - "7z x miktex-portable.exe * -aot -omiktex"
   #- cmd: basic-miktex.exe --unattended --portable --user-config=%LOCALAPPDATA%\MiKTeX\2.9 --user-data=%LOCALAPPDATA%\MiKTeX\2.9 --user-install=%LOCALAPPDATA%\MiKTeX\2.9
 
   - cmd: dir .
-  - cmd: dir .\miktex-portable
-  - cmd: dir .\miktex-portable\bin
+  - cmd: dir .\miktex
+  - cmd: dir .\miktex\miktex
+  - cmd: dir .\miktex\miktex\bin
 
   - cmd: doskey lualatex=%LOCALAPPDATA%\MiKTeX\2.9\miktex\bin\lualatex.exe $*
 

From b32cf3193406e1b67cf361527ad98149cbd6b9e7 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 11:59:18 +0100
Subject: [PATCH 62/68] fix the alias

---
 .appveyor.yml | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index e9feaa1f..b8ab6148 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -22,19 +22,16 @@ install:
   - "python --version"
   - "python -c \"import struct; print(struct.calcsize('P') * 8)\""
 
-  # Install miktex
+  # Install miktex portable
   - ps: "wget http://mirrors.ctan.org/systems/win32/miktex/setup/miktex-portable-2.9.5719.exe -OutFile ./miktex-portable.exe"
-  - "7z x miktex-portable.exe * -aot -omiktex"
-  #- cmd: basic-miktex.exe --unattended --portable --user-config=%LOCALAPPDATA%\MiKTeX\2.9 --user-data=%LOCALAPPDATA%\MiKTeX\2.9 --user-install=%LOCALAPPDATA%\MiKTeX\2.9
+  - "%COMSPEC% /c 7z x miktex-portable.exe * -aot -omiktex"
 
-  - cmd: dir .
-  - cmd: dir .\miktex
-  - cmd: dir .\miktex\miktex
   - cmd: dir .\miktex\miktex\bin
 
-  - cmd: doskey lualatex=%LOCALAPPDATA%\MiKTeX\2.9\miktex\bin\lualatex.exe $*
+  - cmd: doskey lualatex=.\miktex\miktex\bin\lualatex.exe $*
+  - cmd: set PATH=%PATH%;C:\Users\appveyor\miktex\miktex\bin\lualatex
 
-  - "lualatex --version"
+  - "lualatex.exe --version"
 
 build: false  # Not a C# project, build stuff at the test step instead.
 

From ea7ae929a040f600664185ca4fa419352ed8fbf1 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 12:03:32 +0100
Subject: [PATCH 63/68] new lualatex call

---
 .appveyor.yml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index b8ab6148..9e69cedd 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -28,10 +28,12 @@ install:
 
   - cmd: dir .\miktex\miktex\bin
 
-  - cmd: doskey lualatex=.\miktex\miktex\bin\lualatex.exe $*
+  #- cmd: doskey lualatex=.\miktex\miktex\bin\lualatex.exe $*
   - cmd: set PATH=%PATH%;C:\Users\appveyor\miktex\miktex\bin\lualatex
+  - cmd: C:\Users\appveyor\miktex\miktex\bin\lualatex.exe --version
+  - cmd: echo %PATH%
 
-  - "lualatex.exe --version"
+  - cmd: lualatex.exe --version
 
 build: false  # Not a C# project, build stuff at the test step instead.
 

From ed944f86e5283f41f3f252bb449afc377afcef35 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 12:05:03 +0100
Subject: [PATCH 64/68] try to silent 7zip

---
 .appveyor.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 9e69cedd..9b2ffade 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -24,7 +24,7 @@ install:
 
   # Install miktex portable
   - ps: "wget http://mirrors.ctan.org/systems/win32/miktex/setup/miktex-portable-2.9.5719.exe -OutFile ./miktex-portable.exe"
-  - "%COMSPEC% /c 7z x miktex-portable.exe * -aot -omiktex"
+  - "7z x miktex-portable.exe * -aot -omiktex > nul"
 
   - cmd: dir .\miktex\miktex\bin
 

From 0028c5cbb45936d32c8e3fd15d5b3a6c16e22b9d Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 12:24:29 +0100
Subject: [PATCH 65/68] New try

---
 .appveyor.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 9b2ffade..f75f13b7 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -29,11 +29,11 @@ install:
   - cmd: dir .\miktex\miktex\bin
 
   #- cmd: doskey lualatex=.\miktex\miktex\bin\lualatex.exe $*
-  - cmd: set PATH=%PATH%;C:\Users\appveyor\miktex\miktex\bin\lualatex
-  - cmd: C:\Users\appveyor\miktex\miktex\bin\lualatex.exe --version
+  - cmd: set PATH=%PATH%;C:\Users\appveyor\miktex\miktex\bin
   - cmd: echo %PATH%
 
   - cmd: lualatex.exe --version
+  - cmd: C:\Users\appveyor\miktex\miktex\bin\lualatex.exe --version
 
 build: false  # Not a C# project, build stuff at the test step instead.
 

From 5e60aa17be2013b979d68ca7aded3c6a5f36c5ec Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 12:32:52 +0100
Subject: [PATCH 66/68] Correct paths

---
 .appveyor.yml | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index f75f13b7..2e8a9de0 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -28,12 +28,11 @@ install:
 
   - cmd: dir .\miktex\miktex\bin
 
-  #- cmd: doskey lualatex=.\miktex\miktex\bin\lualatex.exe $*
-  - cmd: set PATH=%PATH%;C:\Users\appveyor\miktex\miktex\bin
+  - cmd: set PATH=%PATH%;C:\projects\patacrep\miktex\miktex\bin
   - cmd: echo %PATH%
 
+  - cmd: C:\projects\patacrep\miktex\miktex\bin\lualatex.exe --version
   - cmd: lualatex.exe --version
-  - cmd: C:\Users\appveyor\miktex\miktex\bin\lualatex.exe --version
 
 build: false  # Not a C# project, build stuff at the test step instead.
 
@@ -43,6 +42,6 @@ before_test:
 test_script:
   - "tox"
 
-# Cache Miktex install
+# Cache Miktex zip install
 cache:
-- C:\Users\appveyor\miktex -> .appveyor.yml
+- C:\projects\patacrep\miktex-portable.exe -> .appveyor.yml

From 6f79a773b718a1ec7338cd198fb6c18aeb5ef69d Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 12:47:50 +0100
Subject: [PATCH 67/68] Comment debug commands

---
 .appveyor.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 2e8a9de0..5f929665 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -26,12 +26,12 @@ install:
   - ps: "wget http://mirrors.ctan.org/systems/win32/miktex/setup/miktex-portable-2.9.5719.exe -OutFile ./miktex-portable.exe"
   - "7z x miktex-portable.exe * -aot -omiktex > nul"
 
-  - cmd: dir .\miktex\miktex\bin
+  #- cmd: dir .\miktex\miktex\bin
 
   - cmd: set PATH=%PATH%;C:\projects\patacrep\miktex\miktex\bin
-  - cmd: echo %PATH%
+  #- cmd: echo %PATH%
 
-  - cmd: C:\projects\patacrep\miktex\miktex\bin\lualatex.exe --version
+  #- cmd: C:\projects\patacrep\miktex\miktex\bin\lualatex.exe --version
   - cmd: lualatex.exe --version
 
 build: false  # Not a C# project, build stuff at the test step instead.

From 8d34114bd260b8bb7eef724b1291652eecfded14 Mon Sep 17 00:00:00 2001
From: Oliverpool <oliverpool@hotmail.fr>
Date: Fri, 30 Oct 2015 13:01:07 +0100
Subject: [PATCH 68/68] Cleanly check if the LaTeX compiler is present

---
 patacrep/build.py                         | 26 ++++++++++++++---------
 patacrep/errors.py                        | 10 +++++++++
 test/test_compilation/test_compilation.py |  2 +-
 3 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/patacrep/build.py b/patacrep/build.py
index 2fb134fb..d260d45b 100644
--- a/patacrep/build.py
+++ b/patacrep/build.py
@@ -164,7 +164,6 @@ class SongbookBuilder(object):
 
     def _set_latex(self):
         """Set LaTeX options."""
-        self._lualatex_options.append("--file-line-error")
         if self.unsafe:
             self._lualatex_options.append("--shell-escape")
         if not self.interactive:
@@ -218,25 +217,32 @@ class SongbookBuilder(object):
         LOGGER.info("Building '{}.pdf'…".format(self.basename))
         self._run_once(self._set_latex)
 
+        compiler = "lualatex"
+
+        # test if the LaTeX compiler is accessible
+        try:
+            process = Popen(
+                [compiler, "--version"],
+                stdin=PIPE,
+                stdout=PIPE,
+                stderr=PIPE,
+                env=os.environ,
+                universal_newlines=True,
+                )
+        except Exception as error:
+            raise errors.ExecutableNotFound(compiler)
+
         try:
             process = Popen(
-                ["lualatex"] + self._lualatex_options + [self.basename],
+                [compiler] + self._lualatex_options + [self.basename],
                 stdin=PIPE,
                 stdout=PIPE,
                 stderr=PIPE,
                 env=os.environ,
-                cwd=os.getcwd(),
                 universal_newlines=True,
                 )
         except Exception as error:
             LOGGER.debug(error)
-            LOGGER.debug(os.getcwd())
-            import subprocess
-            LOGGER.debug(subprocess.check_output(
-                ['dir', os.getcwd()],
-                stderr=subprocess.STDOUT,
-                universal_newlines=True
-                ))
             raise errors.LatexCompilationError(self.basename)
 
         if not self.interactive:
diff --git a/patacrep/errors.py b/patacrep/errors.py
index d48f8e1f..d1d3a74f 100644
--- a/patacrep/errors.py
+++ b/patacrep/errors.py
@@ -31,6 +31,16 @@ class TemplateError(SongbookError):
         else:
             return self.message
 
+class ExecutableNotFound(SongbookError):
+    """Couldn't find a LaTeX executable."""
+
+    def __init__(self, executable):
+        super(ExecutableNotFound, self).__init__(
+            (
+                """Could not find the following executable: {executable}"""
+                ).format(executable=executable)
+            )
+
 class StepError(SongbookError):
     """Error during execution of one compilation step."""
 
diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py
index d98b5211..efb6ebe4 100644
--- a/test/test_compilation/test_compilation.py
+++ b/test/test_compilation/test_compilation.py
@@ -121,7 +121,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
                 command,
                 stderr=subprocess.STDOUT,
                 universal_newlines=True,
-                cwd=os.path.dirname(songbook)
+                cwd=os.path.dirname(songbook),
                 )
             return 0
         except subprocess.CalledProcessError as error: