Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

Commit

Permalink
trappy: set the version using an explicit file
Browse files Browse the repository at this point in the history
There is no pythonic way of specifying the version of a project, [0]
describes 7 (seven!) ways of doing it.  We were currently using method
5, setting the value in setup.py and using pkg_resources to get it from
the installed version.  This works ok if you have installed the package
using "python setup.py" or pip, but fails if you are importing trappy
from a checkout, which is what lisa do.  Even worse, if you import it
from lisa but have an old trappy version installed, trappy.__version__
will tell you the version of the installed trappy, not the one you have
imported and are using.

Switch to use a version.py file that's distributed with the
project (method 3).  trappy.__version__ now reads the imported trappy's
version, which is what you want.  setup.py and the documentation read
the file when they are installing so as to avoid repeating the version
number there.

[0] https://packaging.python.org/en/latest/single_source_version/
  • Loading branch information
Javi Merino committed Jun 16, 2016
1 parent 8899094 commit 712e6f9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
6 changes: 3 additions & 3 deletions doc/api_reference/conf.py
Expand Up @@ -81,10 +81,10 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '5.5'
# The short X.Y version. Drop everything after the last "."
version = trappy.__version__[:trappy.__version__.rindex(".")]
# The full version, including alpha/beta/rc tags.
release = '5.5.0'
release = trappy.__version__

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -16,7 +16,7 @@
from setuptools import setup, find_packages


VERSION = "5.5.0"
execfile("trappy/version.py")

LONG_DESCRIPTION = """TRAPpy is a framework written in python for
analysing and plotting FTrace data by converting it into standardised
Expand Down Expand Up @@ -48,7 +48,7 @@
}

setup(name='TRAPpy',
version=VERSION,
version=__version__,
license="Apache v2",
author="ARM-TRAPPY",
author_email="trappy@arm.com",
Expand Down
7 changes: 1 addition & 6 deletions trappy/__init__.py
Expand Up @@ -14,12 +14,12 @@
#


import pkg_resources
import warnings
from trappy.bare_trace import BareTrace
from trappy.compare_runs import summary_plots, compare_runs
from trappy.ftrace import FTrace
from trappy.systrace import SysTrace
from trappy.version import __version__
try:
from trappy.plotter.LinePlot import LinePlot
except ImportError as exc:
Expand Down Expand Up @@ -71,8 +71,3 @@ def register_class(*args, **kwargs):
__import__("trappy.{}".format(import_name))

del fname, import_name, extension

try:
__version__ = pkg_resources.get_distribution("trappy").version
except pkg_resources.DistributionNotFound:
__version__ = "local"
16 changes: 16 additions & 0 deletions trappy/version.py
@@ -0,0 +1,16 @@
# Copyright 2016-2016 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

__version__ = "5.5.0"

0 comments on commit 712e6f9

Please sign in to comment.