Commit d7821d68 authored by Niclas Esser's avatar Niclas Esser
Browse files

Merge remote-tracking branch 'upstream/dev' into dev

parents a1b93b01 92a10277
Pipeline #132544 failed with stages
in 0 seconds
......@@ -2,48 +2,61 @@
Determine the version of the code. If no version number is given, the version is deduced from git
"""
# if hard coded version froms etup.py use this
# if hard coded version from setup.py use this
# ToDo, not implemented as no setup.py here
import logging
import os
import subprocess
import sys
_log = logging.getLogger("mpikat.core.version")
_log.setLevel("DEBUG")
VERSION = '0.0.1+UNKNOWN'
VERSION_ENV = os.getenv("MPIKAT_VERSION")
if VERSION_ENV is not None:
_log.debug("Using version provided by environment variable")
VERSION=VERSION_ENV
else:
try:
_log.debug("Determine version from git repository")
import git
try:
_log.debug("Determine version from git repository")
import git
path = os.path.dirname(os.path.realpath(__file__))
_log.debug("code file located in {}".format(path))
rroot = os.path.join(path, "../..")
_log.debug("repository root {}".format(rroot))
path = os.path.dirname(os.path.realpath(__file__))
_log.debug("code file located in {}".format(path))
rroot = os.path.join(path, "../..")
_log.debug("repository root {}".format(rroot))
repo = git.Repo(rroot)
repo = git.Repo(rroot)
# Check if current version is a tag, use shaidx otherwise
# Check if current version is a tag, use shaidx otherwise
_log.debug("Get latest tag")
if sys.version_info >= (3, 6):
LATEST_TAG = subprocess.check_output('git describe --abbrev=0 --tags'.split(), cwd=rroot, encoding='utf-8').strip()
else:
LATEST_TAG = subprocess.check_output('git describe --abbrev=0 --tags'.split(), cwd=rroot).strip()
if repo.tags[LATEST_TAG].commit == repo.head.commit:
VERSION = "{}".format(TAG)
else:
# This date format is not well readable, but does not violate
# PEP440 local version definition. Adhering to PEP440 is necessary
# for installation with pip / setuptools in new versions
VERSION = "{}+{}.{}".format(LATEST_TAG, repo.head.object.hexsha, repo.head.object.authored_datetime.strftime("%Y%m%dT%H%M%S"))
_log.debug(" LATEST TAG: %s", LATEST_TAG)
# Add modification note
if repo.tags[LATEST_TAG].commit == repo.head.commit:
VERSION = "{}".format(LATEST_TAG)
if repo.is_dirty():
VERSION += "+withMODIFICATIONS"
else:
# This date format is not well readable, but does not violate
# PEP440 local version definition. Adhering to PEP440 is necessary
# for installation with pip / setuptools in new versions
VERSION = "{}+{}.{}".format(LATEST_TAG, repo.head.object.hexsha, repo.head.object.authored_datetime.strftime("%Y%m%dT%H%M%S"))
if repo.is_dirty():
VERSION += ".withMODIFICATIONS"
except Exception as E:
_log.debug("Error determining version from git:\n{}".format(E))
except Exception as E:
_log.debug("Error determining version from git:\n{}".format(E))
try:
version_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'version.txt')
with open(version_file, "r") as f:
VERSION = f.read().strip()
if not VERSION.endswith(".fromFILE"):
VERSION += ".fromFILE"
except Exception as E:
_log.debug("Cannot read version file: {}".format(E))
_log.error("Cannot determin verion!")
_log.debug("VERSION: {}".format(VERSION))
......
[metadata]
name = mpikat
version = file: mpikat/core/version.txt
author = Ewan Barr, Tobias Winchen, Jason Wu
author_email = ebarr@mpifr-bonn.mpg.de
description= Control software for the EDD
long_description = file: README.md
long_description_content_type = text/markdown
url=https://gitlab.mpcdf.mpg.de/mpifr-bdg/mpikat.git
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT
Operating System :: Linux
[options]
packages = find:
python_requires = >=2.7
include_package_data = True
[options.package_data]
* = core/version.txt,
from setuptools import setup, find_packages
import mpikat.core.version
print("Loaded version: ", mpikat.core.version.VERSION)
if not mpikat.core.version.VERSION.endswith("fromFile"):
with open("mpikat/core/version.txt", "w") as f:
f.write(mpikat.core.version.VERSION)
setup(name='mpikat',
# This will give a warning on installation if not a proper tagged
# version with version string according to PEP 440
version=mpikat.core.version.VERSION,
description='Control software for the EDD',
url='https://gitlab.mpcdf.mpg.de/mpifr-bdg/mpikat.git',
author='Ewan Barr',
author_email='ebarr@mpifr-bonn.mpg.de',
license='MIT',
packages=find_packages(),
include_package_data=True, #Install binary data, needed for fpga firmware
zip_safe=False)
from setuptools import setup; setup()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment