diff --git a/.gitignore b/.gitignore index 2382cabeb..a06808dfb 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ exp/ _extras/ *.sublime-* site/ +jrnl/__version__.py diff --git a/.travis.yml b/.travis.yml index 17251ba94..afe427117 100644 --- a/.travis.yml +++ b/.travis.yml @@ -113,6 +113,7 @@ jobs: before_deploy: - poetry config http-basic.pypi "$PYPI_USER" "$PYPI_PASS" - poetry version "$TRAVIS_TAG" + - echo __version__ = \"$TRAVIS_TAG\" > jrnl/__version__.py - poetry build deploy: - provider: script @@ -124,4 +125,3 @@ jobs: - git add pyproject.toml - git commit -m "Incrementing version to ${TRAVIS_TAG}" - git push https://${GITHUB_TOKEN}@github.com/jrnl-org/jrnl.git master - diff --git a/jrnl/__init__.py b/jrnl/__init__.py index 1905b1959..9c4b051e8 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -1,8 +1,8 @@ #!/usr/bin/env python -import pkg_resources - -dist = pkg_resources.get_distribution('jrnl') -__title__ = dist.project_name -__version__ = dist.version - +import os +try: + from .__version__ import __version__ +except ImportError: + __version__ = "source" +__title__ = "jrnl" diff --git a/jrnl/plugins/template.py b/jrnl/plugins/template.py index 7f72e2f80..a74784e2f 100644 --- a/jrnl/plugins/template.py +++ b/jrnl/plugins/template.py @@ -1,5 +1,4 @@ import re -import asteval import yaml VAR_RE = r"[_a-zA-Z][a-zA-Z0-9_]*" @@ -39,6 +38,7 @@ def render_block(self, block, **vars): return self._expand(self.blocks[block], **vars) def _eval_context(self, vars): + import asteval e = asteval.Interpreter(use_numpy=False, writer=None) e.symtable.update(vars) e.symtable['__last_iteration'] = vars.get("__last_iteration", False)