Version getting now doesn't require importing spintrum
This commit is contained in:
parent
67d0c5a2aa
commit
e81b27ef4e
@ -48,13 +48,21 @@ endif()
|
|||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
#add_definitions(-DPOLYMATH_DEBUG)
|
#add_definitions(-DPOLYMATH_DEBUG)
|
||||||
|
|
||||||
|
set(VERSION_GETTER python3 ${CMAKE_SOURCE_DIR}/get_version.py)
|
||||||
set(VERSION 0.1.6)
|
execute_process(COMMAND ${VERSION_GETTER}
|
||||||
execute_process(COMMAND "python3 -c 'from spintrum import meta; print(meta.__version__)'" OUTPUT_VARIABLE VERSION)
|
OUTPUT_VARIABLE VERSION_GET_OUTPUT
|
||||||
|
ERROR_VARIABLE VERSION_GET_ERROR
|
||||||
|
RESULT_VARIABLE VERSION_GET_RESULT
|
||||||
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||||
|
file (STRINGS "${CMAKE_BINARY_DIR}/TEMP_VERSION.txt" VERSION)
|
||||||
|
if(NOT "${VERSION_GET_RESULT}" STREQUAL "0")
|
||||||
|
message(FATAL_ERROR "${BoldRed}Error: Unable to get version number by executing ${VERSION_GETTER}${ColourReset}")
|
||||||
|
endif()
|
||||||
add_definitions(-DSPINTRUM_VERSION="${VERSION}")
|
add_definitions(-DSPINTRUM_VERSION="${VERSION}")
|
||||||
|
message("${BoldBlue}Building Spintrum, version: ${VERSION}${ColourReset}")
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${PolymathPath}/include)
|
INCLUDE_DIRECTORIES(${PolymathPath}/include)
|
||||||
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
|
#INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
|
||||||
INCLUDE_DIRECTORIES(${SpintrumPath})
|
INCLUDE_DIRECTORIES(${SpintrumPath})
|
||||||
INCLUDE_DIRECTORIES(${OpenBLASPath})
|
INCLUDE_DIRECTORIES(${OpenBLASPath})
|
||||||
|
|
||||||
|
15
get_version.py
Normal file
15
get_version.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
VERSIONFILE = os.path.join(os.path.dirname(os.path.abspath(__file__)),"spintrum/meta.py")
|
||||||
|
verstrline = open(VERSIONFILE, "rt").read()
|
||||||
|
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
|
||||||
|
mo = re.search(VSRE, verstrline, re.M)
|
||||||
|
if mo:
|
||||||
|
return str(mo.group(1))
|
||||||
|
else:
|
||||||
|
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
|
||||||
|
|
||||||
|
with open("TEMP_VERSION.txt","w") as f:
|
||||||
|
f.write(get_version())
|
14
setup.py
14
setup.py
@ -1,6 +1,4 @@
|
|||||||
from setuptools import setup, find_packages
|
|
||||||
from distutils.command.build import build as _build
|
from distutils.command.build import build as _build
|
||||||
from spintrum import meta
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
@ -8,6 +6,7 @@ import errno
|
|||||||
import tempfile
|
import tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
import glob
|
import glob
|
||||||
|
import re
|
||||||
import fnmatch
|
import fnmatch
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -27,6 +26,15 @@ def _print_error(msg):
|
|||||||
sys.stderr.write("\n\n" + error_color_start + "ERROR: " + msg + color_end + " \n\n\n ")
|
sys.stderr.write("\n\n" + error_color_start + "ERROR: " + msg + color_end + " \n\n\n ")
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
VERSIONFILE = os.path.join(os.path.dirname(os.path.abspath(__file__)),"spintrum/meta.py")
|
||||||
|
verstrline = open(VERSIONFILE, "rt").read()
|
||||||
|
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
|
||||||
|
mo = re.search(VSRE, verstrline, re.M)
|
||||||
|
if mo:
|
||||||
|
return str(mo.group(1))
|
||||||
|
else:
|
||||||
|
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
|
||||||
|
|
||||||
def which(program):
|
def which(program):
|
||||||
"""
|
"""
|
||||||
@ -245,7 +253,7 @@ class DependenciesBuilder(_build):
|
|||||||
|
|
||||||
|
|
||||||
setup(name='spintrum',
|
setup(name='spintrum',
|
||||||
version=meta.__version__,
|
version=get_version(),
|
||||||
description='Software for spin systems simulation',
|
description='Software for spin systems simulation',
|
||||||
url='http://www.afach.de/',
|
url='http://www.afach.de/',
|
||||||
author='Samer Afach',
|
author='Samer Afach',
|
||||||
|
Loading…
Reference in New Issue
Block a user