diff --git a/patacrep/__init__.py b/patacrep/__init__.py index 13e74a66..5effb2c4 100644 --- a/patacrep/__init__.py +++ b/patacrep/__init__.py @@ -17,8 +17,8 @@ __version__ = '.'.join([str(number) for number in __TUPLE_VERSION__]) # etc.) _ROOT = os.path.abspath(resource_filename(__name__, 'data')) -def pkg_datapath(path=''): +def pkg_datapath(*path): """Return the package data path""" - return os.path.join(_ROOT, path) + return os.path.join(_ROOT, *path) __DATADIR__ = os.path.abspath(pkg_datapath()) diff --git a/patacrep/build.py b/patacrep/build.py index d260d45b..766a82d9 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -6,7 +6,7 @@ import glob import logging import threading import os.path -from subprocess import Popen, PIPE, call +from subprocess import Popen, PIPE, call, check_call from patacrep import __DATADIR__, authors, content, errors, files from patacrep.index import process_sxd @@ -219,26 +219,25 @@ class SongbookBuilder(object): compiler = "lualatex" - # test if the LaTeX compiler is accessible + # Test if the LaTeX compiler is accessible try: - process = Popen( + check_call( [compiler, "--version"], stdin=PIPE, stdout=PIPE, stderr=PIPE, - env=os.environ, universal_newlines=True, ) except Exception as error: raise errors.ExecutableNotFound(compiler) + # Perform compilation try: process = Popen( [compiler] + self._lualatex_options + [self.basename], stdin=PIPE, stdout=PIPE, stderr=PIPE, - env=os.environ, universal_newlines=True, ) except Exception as error: diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index abdd8438..ad20b860 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -48,7 +48,7 @@ class ChordproSong(Song): self.get_datadirs(os.path.join("templates", self.output_language)) ), FileSystemLoader( - os.path.join(pkg_datapath('ast_templates'), 'chordpro', self.output_language) + pkg_datapath('ast_templates', 'chordpro', self.output_language) ), ])) jinjaenv.filters['search_image'] = self.search_image diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 3b14088b..6b74969b 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -76,7 +76,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): "@DATA_FOLDER@", path2posix( subprocess.check_output( - [sys.executable, "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'], # pylint: disable=line-too-long + [sys.executable, "-c", 'import patacrep; print(patacrep.__DATADIR__)'], # pylint: disable=line-too-long universal_newlines=True, cwd=os.path.dirname(songbook), ).strip() @@ -117,7 +117,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): command.extend(['--steps', steps]) try: - subprocess.check_output( + subprocess.check_call( command, stderr=subprocess.STDOUT, universal_newlines=True,