diff --git a/src/test/MANIFEST.in b/src/test/MANIFEST.in index ed111d81e6155a5b655eccd7382faf3d4f6b1707..e7b77446f3e60c33aa86e5381f66c0c564ade835 100644 --- a/src/test/MANIFEST.in +++ b/src/test/MANIFEST.in @@ -1,2 +1,2 @@ -include MANIFEST.in -recursive-include clmctest _version.py *.yml *.yaml *.sh *.json *.conf \ No newline at end of file +include VERSION +recursive-include clmctest *.yml *.yaml *.sh *.json *.conf \ No newline at end of file diff --git a/src/test/VERSION b/src/test/VERSION new file mode 100644 index 0000000000000000000000000000000000000000..4a2bfa871aa7cbcb89e5d84bf7020312f591bb5d --- /dev/null +++ b/src/test/VERSION @@ -0,0 +1 @@ +__version__ = "1.2.0" \ No newline at end of file diff --git a/src/test/setup.py b/src/test/setup.py index 8a52b180bedef919d1ca496cf26eb3ea26ee8843..7f03b5ef45e8e099d41094b1597b253473ae8ec7 100644 --- a/src/test/setup.py +++ b/src/test/setup.py @@ -27,32 +27,41 @@ import os.path from setuptools import setup, find_packages -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() +def get_version(*relative_path): + """ + Reads and parses a version file. + :param relative_path: iterable representing the relative path to the version file + :return: + """ + + fname = os.path.join(os.path.dirname(__file__), *relative_path) -def get_version(fname): if os.path.isfile(fname): - git_revision = read(fname) + with open(fname) as f: # Use context managers when opening files, otherwise file handlers might not be properly closed + version = {} + # execute the version file and put its content in the version dictionary + exec(f.read(), version) + # extract the __version__ variable from the dictionary, if not found use default value "SNAPSHOT" + git_revision = version.get("__version__", "SNAPSHOT") else: - git_revision = "SNAPSHOT" + git_revision = "SNAPSHOT" return git_revision setup( - name = "clmctest", - version = get_version("_version.py"), - author = "Michael Boniface", - author_email = "mjb@it-innovation.soton.ac.uk", - description = "FLAME CLMC Test Module", - license = "https://gitlab.it-innovation.soton.ac.uk/FLAME/flame-clmc/blob/integration/LICENSE", - keywords = "FLAME CLMC", + name="clmctest", + version=get_version("VERSION"), + author="Michael Boniface", + author_email="mjb@it-innovation.soton.ac.uk", + description="FLAME CLMC Test Module", + license="https://gitlab.it-innovation.soton.ac.uk/FLAME/flame-clmc/blob/integration/LICENSE", + keywords="FLAME CLMC", url='https://gitlab.it-innovation.soton.ac.uk/FLAME/flame-clmc', - packages=find_packages(exclude=["services"]), + packages=find_packages(), include_package_data=True, - package_data={'': ['_version.py', '*.yml', '*.yaml', '*.sh', '*.json', '*.conf']}, - long_description="FLAME CLMC", + long_description="FLAME CLMC Test", classifiers=[ "Development Status :: Alpha", "Topic :: FLAME Tests",