From d1b319ae0938e59ac423d8757757ac609f0db2c0 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 29 Oct 2015 15:19:05 +0100 Subject: [PATCH 01/48] 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 Date: Thu, 29 Oct 2015 15:26:36 +0100 Subject: [PATCH 02/48] 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 Date: Thu, 29 Oct 2015 15:40:18 +0100 Subject: [PATCH 03/48] 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 Date: Thu, 29 Oct 2015 15:46:08 +0100 Subject: [PATCH 04/48] 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 Date: Thu, 29 Oct 2015 16:35:32 +0100 Subject: [PATCH 05/48] 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 Date: Thu, 29 Oct 2015 16:40:45 +0100 Subject: [PATCH 06/48] 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 Date: Thu, 29 Oct 2015 16:44:28 +0100 Subject: [PATCH 07/48] 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 Date: Thu, 29 Oct 2015 16:48:30 +0100 Subject: [PATCH 08/48] 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 Date: Thu, 29 Oct 2015 16:55:03 +0100 Subject: [PATCH 09/48] 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 Date: Thu, 29 Oct 2015 17:02:43 +0100 Subject: [PATCH 10/48] 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 Date: Thu, 29 Oct 2015 17:17:28 +0100 Subject: [PATCH 11/48] 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 Date: Thu, 29 Oct 2015 17:17:37 +0100 Subject: [PATCH 12/48] [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 Date: Thu, 29 Oct 2015 17:49:32 +0100 Subject: [PATCH 13/48] [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 Date: Thu, 29 Oct 2015 17:54:40 +0100 Subject: [PATCH 14/48] 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 Date: Thu, 29 Oct 2015 18:08:43 +0100 Subject: [PATCH 15/48] [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 Date: Thu, 29 Oct 2015 18:10:59 +0100 Subject: [PATCH 16/48] [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 Date: Thu, 29 Oct 2015 18:13:12 +0100 Subject: [PATCH 17/48] 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 Date: Thu, 29 Oct 2015 19:09:58 +0100 Subject: [PATCH 18/48] [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 Date: Thu, 29 Oct 2015 19:14:51 +0100 Subject: [PATCH 19/48] [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 Date: Thu, 29 Oct 2015 19:19:12 +0100 Subject: [PATCH 20/48] [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 Date: Thu, 29 Oct 2015 19:24:39 +0100 Subject: [PATCH 21/48] [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 Date: Thu, 29 Oct 2015 19:30:46 +0100 Subject: [PATCH 22/48] [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 Date: Thu, 29 Oct 2015 19:37:11 +0100 Subject: [PATCH 23/48] [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 Date: Thu, 29 Oct 2015 19:40:44 +0100 Subject: [PATCH 24/48] [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 Date: Thu, 29 Oct 2015 19:46:55 +0100 Subject: [PATCH 25/48] 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 Date: Thu, 29 Oct 2015 19:52:22 +0100 Subject: [PATCH 26/48] 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 Date: Thu, 29 Oct 2015 21:31:16 +0100 Subject: [PATCH 27/48] 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 Date: Thu, 29 Oct 2015 21:49:09 +0100 Subject: [PATCH 28/48] [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 Date: Thu, 29 Oct 2015 21:53:02 +0100 Subject: [PATCH 29/48] 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 Date: Thu, 29 Oct 2015 21:57:35 +0100 Subject: [PATCH 30/48] 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 Date: Thu, 29 Oct 2015 22:12:44 +0100 Subject: [PATCH 31/48] 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 Date: Thu, 29 Oct 2015 22:16:12 +0100 Subject: [PATCH 32/48] 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 Date: Thu, 29 Oct 2015 22:20:54 +0100 Subject: [PATCH 33/48] 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 Date: Thu, 29 Oct 2015 22:25:56 +0100 Subject: [PATCH 34/48] 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 Date: Thu, 29 Oct 2015 22:28:36 +0100 Subject: [PATCH 35/48] 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 Date: Thu, 29 Oct 2015 22:31:36 +0100 Subject: [PATCH 36/48] 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 Date: Thu, 29 Oct 2015 22:35:27 +0100 Subject: [PATCH 37/48] 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 Date: Thu, 29 Oct 2015 22:39:23 +0100 Subject: [PATCH 38/48] 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 Date: Thu, 29 Oct 2015 23:31:54 +0100 Subject: [PATCH 39/48] 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 Date: Thu, 29 Oct 2015 23:34:41 +0100 Subject: [PATCH 40/48] 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 Date: Thu, 29 Oct 2015 23:37:55 +0100 Subject: [PATCH 41/48] 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 Date: Thu, 29 Oct 2015 23:41:13 +0100 Subject: [PATCH 42/48] 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 Date: Thu, 29 Oct 2015 23:51:00 +0100 Subject: [PATCH 43/48] 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 Date: Thu, 29 Oct 2015 23:52:19 +0100 Subject: [PATCH 44/48] 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 Date: Thu, 29 Oct 2015 23:56:46 +0100 Subject: [PATCH 45/48] 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 Date: Fri, 30 Oct 2015 00:03:49 +0100 Subject: [PATCH 46/48] 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 e6e493496aa19d39413c100ee95f6d9fdd4547f2 Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 30 Oct 2015 01:07:17 +0100 Subject: [PATCH 47/48] Test appveyor --- .appveyor.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index 4c4a6949..e410d7e9 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -21,6 +21,12 @@ install: # Check that we have the expected version and architecture for Python - "python --version" - "python -c \"import struct; print(struct.calcsize('P') * 8)\"" + - "pip --version" + + # Download and install MikTeX + - ps: "wget http://mirrors.ctan.org/systems/win32/miktex/setup/basic-miktex-2.9.5721.exe -OutFile ./basic-miktex.exe" + - "./basic-miktex.exe" + build: false # Not a C# project, build stuff at the test step instead. From a09ece79ad6bd7c7f24cf942082e7dd225d1db1f Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 30 Oct 2015 01:12:20 +0100 Subject: [PATCH 48/48] Change path --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index e410d7e9..8f0c8ac0 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -25,7 +25,7 @@ install: # Download and install MikTeX - ps: "wget http://mirrors.ctan.org/systems/win32/miktex/setup/basic-miktex-2.9.5721.exe -OutFile ./basic-miktex.exe" - - "./basic-miktex.exe" + - "basic-miktex.exe" build: false # Not a C# project, build stuff at the test step instead.