From 2f41a0d597d0f437760a757685bbbf5f707909b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernardo=20Mart=C3=ADnez=20Garrido?= Date: Tue, 9 Jun 2015 22:11:29 +0200 Subject: [PATCH] Corrected version acquisition. --- cookiecutter.json | 2 +- setup.py | 18 ++++++++++++++++ .../docs/source/_templates/layout.html | 19 ----------------- .../docs/source/conf.py | 21 +++++++++++++++++-- 4 files changed, 38 insertions(+), 22 deletions(-) delete mode 100644 {{cookiecutter.repo_name}}/docs/source/_templates/layout.html diff --git a/cookiecutter.json b/cookiecutter.json index 27549a7..75d8ef6 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -12,6 +12,6 @@ "year": "2015", "version": "0.1.0", "_copy_without_render": [ - "_templates/layout.html" + "layout.html" ] } diff --git a/setup.py b/setup.py index e5636e1..db49244 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,11 @@ # -*- coding: utf-8 -*- +import ast +import re import sys import io from os.path import dirname from os.path import join +from os import path from setuptools import find_packages, setup from setuptools.command.test import test as test_command @@ -15,10 +18,25 @@ __license__ = 'MIT' +# Regular expression for the version +_version_re = re.compile(r'__version__\s+=\s+(.*)') # Test requirements _tests_require = ['tox'] +# Path to the project's root +here = path.abspath(path.dirname(__file__)) + +# Gets the long description from the readme +with open(path.join(here, 'README.rst'), encoding='utf-8') as f: + long_description = f.read() + +# Gets the version for the source folder __init__.py file +with open('cwr/__init__.py', 'rb', encoding='utf-8') as f: + version = f.read() + version = _version_re.search(version).group(1) + version = str(ast.literal_eval(version.rstrip())) + # Gets the long description from the readme def read(*names, **kwargs): diff --git a/{{cookiecutter.repo_name}}/docs/source/_templates/layout.html b/{{cookiecutter.repo_name}}/docs/source/_templates/layout.html deleted file mode 100644 index 982facd..0000000 --- a/{{cookiecutter.repo_name}}/docs/source/_templates/layout.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends "!layout.html" %} -{% set bootswatch_css_custom = ['_static/doc.css']%} - -{% block header %} -{{ super() }} - - -{% endblock %} \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/docs/source/conf.py b/{{cookiecutter.repo_name}}/docs/source/conf.py index 533ebda..3950801 100644 --- a/{{cookiecutter.repo_name}}/docs/source/conf.py +++ b/{{cookiecutter.repo_name}}/docs/source/conf.py @@ -7,9 +7,26 @@ import re import sys import os -import datetime from codecs import open +from os import path +# -- Version -------------------------------------------------------------- + +# Regular expression for the version +_version_re = re.compile(r'__version__\s+=\s+(.*)') + +# Path to the project's root +here = path.abspath(path.dirname(__file__)) + +# Gets the long description from the readme +with open(path.join(here, 'README.rst'), encoding='utf-8') as f: + long_description = f.read() + +# Gets the version for the source folder __init__.py file +with open('cwr/__init__.py', 'rb', encoding='utf-8') as f: + version_lib = f.read() + version_lib = _version_re.search(version_lib).group(1) + version_lib = str(ast.literal_eval(version_lib.rstrip())) # -- Code location -------------------------------------------------------- @@ -50,7 +67,7 @@ # The version info for the project. # # Semantic version value. -version = {{ cookiecutter.package_name }}.__version__ +version = version_lib # The full version, including alpha/beta/rc tags. release = version