From de520814818fb6b2472de9376be63869198fe099 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Thu, 7 Nov 2019 16:48:47 -0800 Subject: [PATCH 1/3] Explicitly write Version to file --- .gitignore | 1 + .travis.yml | 1 + jrnl/__init__.py | 11 +++++++---- pyproject.toml | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 2382cabeb..b14464d0e 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ exp/ _extras/ *.sublime-* site/ +jrnl/VERSION.txt diff --git a/.travis.yml b/.travis.yml index fea48f502..3eda0c9a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ script: before_deploy: - pip install poetry - poetry config http-basic.pypi $PYPI_USER $PYPI_PASS + - echo $TRAVIS_TAG > jrnl/VERSION.txt - poetry version $TRAVIS_TAG - poetry build deploy: diff --git a/jrnl/__init__.py b/jrnl/__init__.py index 57664dbb5..f1cdc3c47 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -1,9 +1,12 @@ #!/usr/bin/env python # encoding: utf-8 -import pkg_resources +import os -dist = pkg_resources.get_distribution('jrnl') -__title__ = dist.project_name -__version__ = dist.version +__title__ = "jrnl" +__version__ = "source" +version_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "VERSION.txt") +if os.path.exists(version_path): + with open(version_path) as version_file: + __version__ = version_file.read() diff --git a/pyproject.toml b/pyproject.toml index 1b84acde0..df18f9daf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,7 @@ license = "MIT" readme = "README.md" homepage = "https://jrnl.sh" repository = "https://github.com/jrnl-org/jrnl" +include = ["VERSION.txt"] [tool.poetry.dependencies] python = "^3.7" From 80b376b4fb03b023d28e41aa43be8d8c83077d99 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Thu, 7 Nov 2019 16:49:01 -0800 Subject: [PATCH 2/3] Delay import of asteval --- jrnl/plugins/template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jrnl/plugins/template.py b/jrnl/plugins/template.py index 21fb28963..bdb1ebe49 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) From 45384f3c8f9e5522622383d305c347c8681d6e90 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Sun, 1 Dec 2019 19:41:16 -0800 Subject: [PATCH 3/3] Use __version__.py instead of VERSION.txt --- .gitignore | 2 +- .travis.yml | 2 +- jrnl/__init__.py | 11 ++++------- pyproject.toml | 1 - 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index b14464d0e..a06808dfb 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,4 @@ exp/ _extras/ *.sublime-* site/ -jrnl/VERSION.txt +jrnl/__version__.py diff --git a/.travis.yml b/.travis.yml index 3eda0c9a5..215ef3392 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ script: before_deploy: - pip install poetry - poetry config http-basic.pypi $PYPI_USER $PYPI_PASS - - echo $TRAVIS_TAG > jrnl/VERSION.txt + - echo __version__ = \"$TRAVIS_TAG\" > jrnl/__version__.py - poetry version $TRAVIS_TAG - poetry build deploy: diff --git a/jrnl/__init__.py b/jrnl/__init__.py index f1cdc3c47..f0f0af6d1 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -2,11 +2,8 @@ # encoding: utf-8 import os - +try: + from .__version__ import __version__ +except ImportError: + __version__ = "source" __title__ = "jrnl" -__version__ = "source" - -version_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "VERSION.txt") -if os.path.exists(version_path): - with open(version_path) as version_file: - __version__ = version_file.read() diff --git a/pyproject.toml b/pyproject.toml index df18f9daf..1b84acde0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,6 @@ license = "MIT" readme = "README.md" homepage = "https://jrnl.sh" repository = "https://github.com/jrnl-org/jrnl" -include = ["VERSION.txt"] [tool.poetry.dependencies] python = "^3.7"