diff --git a/_updateversion.py b/_updateversion.py index d77a0be47..9ae7ad0cc 100644 --- a/_updateversion.py +++ b/_updateversion.py @@ -1,16 +1,15 @@ #!/usr/bin/env/python # coding=utf-8 -import sys import os import subprocess -_HERE = os.path.join(os.path.abspath(os.path.dirname(__file__)),'tofu') +_HERE = os.path.abspath(os.path.dirname(__file__)) def updateversion(path=_HERE): # Fetch version from git tags, and write to version.py # Also, when git is not available (PyPi package), use stored version.py - version_py = os.path.join(path,"version.py") + version_py = os.path.join(path, 'tofu', 'version.py') try: version_git = subprocess.check_output(["git", "describe"]).rstrip().decode() diff --git a/doc/source/index.rst b/doc/source/index.rst index 80c9671e6..bbcc751dc 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -63,6 +63,7 @@ Contents How to install tofu A guide to contributing to tofu + A list of all different device configurations available (ITER, WEST, JET, ...) Tutorials and examples * How to create / handle a diagnostic geometry diff --git a/examples/tutorials/tuto_plot_gallery_fusion_machines.py b/examples/tutorials/tuto_plot_gallery_fusion_machines.py index ebadfeb12..7c1359678 100644 --- a/examples/tutorials/tuto_plot_gallery_fusion_machines.py +++ b/examples/tutorials/tuto_plot_gallery_fusion_machines.py @@ -2,7 +2,8 @@ A gallery of Fusion Machines ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -This tutorial functions as a gallery of fusion machines that can easily be loaded with `tofu`. +This tutorial functions as a gallery of fusion machines that can easily be +loaded with `tofu`. """ ############################################################################### @@ -11,28 +12,28 @@ import tofu as tf ############################################################################### -# `tofu` provides a geometry helper function that allows creating a configuration with a single call. +# `tofu` provides a geometry helper function that allows creating a +# configuration with a single call. # -# Calling with empty arguments results in a default configuration. At the time of writing, this is ITER. -# By printing the `config` object, a text representation of its components is printed. This allows inspecting +# Calling with empty arguments results in a default configuration. At the time +# of writing, this is ITER. +# By printing the `config` object, a text representation of its components is +# printed. This allows inspecting # component names, number of sections, color or visibility. -config = tf.geom.utils.create_config() +config = tf.geom.utils.create_config() # create default configuration print(config) ############################################################################### -# To get a list of all available built-in configs, one has to know some details about `tofu`. -# Configurations can either be accessed by names (ITER, WEST, JET). +# To get a list of all available built-in configs, one has to know some details +# about `tofu`. Configurations can be accessed by names (ITER, WEST, JET, etc). print(tf.geom.utils._DCONFIG_TABLE.keys()) ############################################################################### -# With that being said, let's create a gallery of the "top 3" fusion machines provided by `tofu` to accelerate -# diagnostic development. +# With that being said, let's create a gallery of the "top 3" fusion machines +# provided by `tofu` to accelerate diagnostic development. -import matplotlib.pyplot as plt - -fig, ax = plt.subplots() for fusion_machine in ['ITER', 'WEST', 'JET']: config = tf.geom.utils.create_config(fusion_machine) - config.plot() \ No newline at end of file + config.plot() diff --git a/setup.py b/setup.py index 23e3c2e42..5f45f94c0 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,10 @@ from Cython.Distutils import build_ext import numpy as np # ... -import _updateversion as up +# Remove _updateversion import due to build-time dependency +# => updateversion defined in here for commodity +# => find a cleaner solution later +# import _updateversion as up # ... for `clean` command from distutils.command.clean import clean as Clean @@ -143,6 +146,26 @@ def check_for_openmp(cc_var): # == Getting tofu version ===================================================== _HERE = os.path.abspath(os.path.dirname(__file__)) + + +def updateversion(path=_HERE): + # Fetch version from git tags, and write to version.py + # Also, when git is not available (PyPi package), use stored version.py + version_py = os.path.join(path, 'tofu', 'version.py') + try: + version_git = subprocess.check_output(["git", + "describe"]).rstrip().decode() + except Exception as err: + with open(version_py, 'r') as fh: + version_git = fh.read().strip().split("=")[-1].replace("'", '') + version_git = version_git.lower().replace('v', '') + + version_msg = "# Do not edit, pipeline versioning governed by git tags!" + with open(version_py, "w") as fh: + msg = "{0}__version__ = '{1}'{0}".format(os.linesep, version_git) + fh.write(version_msg + msg) + return version_git + def get_version_tofu(path=_HERE): # Try from git @@ -163,7 +186,7 @@ def get_version_tofu(path=_HERE): .decode() ) if git_branch in ["master"]: - version_tofu = up.updateversion(os.path.join(path, "tofu")) + version_tofu = updateversion(os.path.join(path, "tofu")) else: isgit = False except Exception: diff --git a/tofu/tests/tests09_tutorials/tests01_runall.py b/tofu/tests/tests09_tutorials/tests01_runall.py index e20341724..5fe4d66a5 100644 --- a/tofu/tests/tests09_tutorials/tests01_runall.py +++ b/tofu/tests/tests09_tutorials/tests01_runall.py @@ -1,25 +1,13 @@ - -# External modules import os import shutil -import types import subprocess -import numpy as np -import warnings as warn import matplotlib.pyplot as plt - -# Nose-specific -from nose import with_setup # optional - -# Importing package tofu.geom -import tofu as tf from tofu import __version__ - +from pathlib import Path _HERE = os.path.abspath(os.path.dirname(__file__)) -_TFROOT = _HERE[:-_HERE[::-1].index('/tofu'[::-1])-len('/tofu')] -# _TFROOT = tf.__path__[0][:-5] -# _PATHTUTO = os.path.join(_TFROOT, 'examples', 'tutorials') +_TFROOT = Path(_HERE).parent.parent.parent + keyVers = 'Vers' diff --git a/tofu/version.py b/tofu/version.py index f16ec2709..e5dd80cc9 100644 --- a/tofu/version.py +++ b/tofu/version.py @@ -1,2 +1,2 @@ # Do not edit, pipeline versioning governed by git tags! -__version__ = '1.4.2-a4' +__version__ = '1.4.2-a4-5-g9b404aa'