Bläddra i källkod

Use module variables for version and release numbers.

Stefano Cossu 6 år sedan
förälder
incheckning
fcfbe2146e
6 ändrade filer med 14 tillägg och 19 borttagningar
  1. 0 1
      VERSION
  2. 3 4
      docs/conf.py
  3. 4 0
      lakesuperior/__init__.py
  4. 2 6
      lakesuperior/endpoints/main.py
  5. 1 1
      lakesuperior/endpoints/templates/index.html
  6. 4 7
      setup.py

+ 0 - 1
VERSION

@@ -1 +0,0 @@
-1.0.0a16

+ 3 - 4
docs/conf.py

@@ -32,11 +32,10 @@ class MockModule(MagicMock):
 MOCK_MODULES = ['lmdb']
 sys.modules.update((mod_name, MockModule()) for mod_name in MOCK_MODULES)
 
+import lakesuperior
 import lakesuperior.env_setup
 
 
-here = path.abspath(path.dirname(__file__))
-
 # -- General configuration ------------------------------------------------
 
 # If your documentation needs a minimal Sphinx version, state it here.
@@ -75,8 +74,8 @@ author = 'Stefano Cossu'
 # built documents.
 #
 # Version and release are the same.
-with open(path.realpath(path.join(here, '..', 'VERSION'))) as fh:
-    version = release = fh.readlines()[0]
+version = lakesuperior.version
+release = lakesuperior.release
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.

+ 4 - 0
lakesuperior/__init__.py

@@ -2,6 +2,10 @@ import threading
 
 from os import path
 
+
+version = '1.0 alpha'
+release = '1.0.0a17'
+
 basedir = path.dirname(path.realpath(__file__))
 """
 Base directory for the module.

+ 2 - 6
lakesuperior/endpoints/main.py

@@ -4,7 +4,7 @@ from os import path
 
 from flask import Blueprint, render_template
 
-from lakesuperior import basedir
+from lakesuperior import release
 
 logger = logging.getLogger(__name__)
 
@@ -18,11 +18,7 @@ main = Blueprint('main', __name__, template_folder='templates',
 @main.route('/', methods=['GET'])
 def index():
     """Homepage."""
-    version_fname = path.abspath(
-            path.join(path.dirname(basedir), 'VERSION'))
-    with open(version_fname) as fh:
-        version = fh.readlines()[0]
-    return render_template('index.html', version=version)
+    return render_template('index.html', release=release)
 
 
 @main.route('/debug', methods=['GET'])

+ 1 - 1
lakesuperior/endpoints/templates/index.html

@@ -1,7 +1,7 @@
 {% extends 'base.html' %}
 {% block title %}LAKEsuperior{% endblock %}
 {% block content %}
-    <p>Version {{ version }}</p>
+    <p>Release {{ release }}</p>
     <blockquote>
         Superior, they said, never gives up her dead<br />
         When the gales of November come early

+ 4 - 7
setup.py

@@ -13,7 +13,7 @@ from codecs import open
 from glob import glob
 from os import path
 
-here = path.abspath(path.dirname(__file__))
+import lakesuperior
 
 # ``pytest_runner`` is referenced in ``setup_requires``.
 # See https://github.com/pytest-dev/pytest-runner#conditional-requirement
@@ -22,17 +22,14 @@ pytest_runner = ['pytest-runner'] if needs_pytest else []
 
 
 # Get the long description from the README file
-with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
+readme_fpath = path.join(path.dirname(lakesuperior.basedir), 'README.rst')
+with open(readme_fpath, encoding='utf-8') as f:
     long_description = f.read()
 
-# Read release number.
-with open(path.realpath(path.join(here, 'VERSION'))) as fh:
-    version = fh.readlines()[0]
-
 
 setup(
     name='lakesuperior',
-    version=version,
+    version=lakesuperior.release,
 
     description='A Linked Data Platform repository sever.',
     long_description=long_description,