From 1a2737bbcd43dfa5ed9dcc0fac6d35dd31b456ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Tue, 10 Jan 2017 15:28:38 +0100 Subject: [PATCH] quick fix for semver dependency during install --- .../{{cookiecutter.repo_name}}/__init__.py | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/__init__.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/__init__.py index dee2ef8..c0819b5 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/__init__.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/__init__.py @@ -16,19 +16,23 @@ """ {{cookiecutter.project_short_description}} """ +from __future__ import print_function -import semver from .version import __version__ -__version_info__ = semver.parse_version_info(__version__) +try: + import semver + __version_info__ = semver.parse_version_info(__version__) -if __version_info__.prerelease: - import logging - logger = logging.getLogger(__name__) - msg = 'WARNING: You are using a pre-release version of {} ({})'.format( - __name__, __version__) - if len(logging.root.handlers) > 0: - logger.info(msg) - else: - import sys - print(msg, file=sys.stderr) + if __version_info__.prerelease: + import logging + logger = logging.getLogger(__name__) + msg = 'WARNING: You are using a pre-release version of {} ({})'.format( + __name__, __version__) + if len(logging.root.handlers) > 0: + logger.info(msg) + else: + import sys + print(msg, file=sys.stderr) +except ImportError: + print('semver not installed. Not doing version checking')