diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-06-24 18:58:30 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-06-24 21:14:11 +0200 |
commit | 7844307638c4666c0fc4a330b7d536722fc13460 (patch) | |
tree | c0e231cb82f89867e7e34db749a7e4c57f05f2e5 | |
parent | d9be7da0cf3d38e2476862fc6bb75a8d27de3276 (diff) | |
download | ghdl-7844307638c4666c0fc4a330b7d536722fc13460.tar.gz ghdl-7844307638c4666c0fc4a330b7d536722fc13460.tar.bz2 ghdl-7844307638c4666c0fc4a330b7d536722fc13460.zip |
python: add version.py, check it in configure.
-rwxr-xr-x | configure | 18 | ||||
-rw-r--r-- | python/libghdl/__init__.py | 2 | ||||
-rw-r--r-- | python/libghdl/version.py | 1 | ||||
-rw-r--r-- | python/setup.py | 22 |
4 files changed, 16 insertions, 27 deletions
@@ -178,6 +178,18 @@ if ! $CC -v 2> /dev/null; then exit 1 fi +# Check the version of libghdl is correct. +if [ "$enable_libghdl" = true ]; then + libghdl_version="$srcdir/python/libghdl/version.py" + if ! echo "__version__ = '${ghdl_version}'" | cmp "$libghdl_version" ; then + echo "Sorry, the version of $libghdl_version is not correct" + echo "update the version to: $ghdl_version" + echo "or use --disable-libghdl" + exit 1 + fi +fi + + # Default for enable_openieee if [ "$enable_openieee" = "unknown" ]; then if test -d $srcdir/libraries/ieee ; then @@ -294,12 +306,6 @@ if [ ! -d pic ]; then fi fi -if [ "$enable_libghdl" = true ]; then - cat > config.py <<-EOF -__version__ = '${ghdl_version}' -EOF -fi - # Generate config.status rm -f config.status { diff --git a/python/libghdl/__init__.py b/python/libghdl/__init__.py index a733cd1a8..3050a82da 100644 --- a/python/libghdl/__init__.py +++ b/python/libghdl/__init__.py @@ -2,7 +2,7 @@ import ctypes import os from os.path import dirname, join, exists from shutil import which -from libghdl.config import __version__ +from libghdl.version import __version__ def _get_libghdl_name(): diff --git a/python/libghdl/version.py b/python/libghdl/version.py new file mode 100644 index 000000000..0a51c80f3 --- /dev/null +++ b/python/libghdl/version.py @@ -0,0 +1 @@ +__version__ = '0.37-dev' diff --git a/python/setup.py b/python/setup.py index 4d9dc5c41..479b9f5af 100644 --- a/python/setup.py +++ b/python/setup.py @@ -5,35 +5,20 @@ from distutils.core import setup import re def get_version(): - # Try from config.py. Reads it to avoid to load the shared library. + # Try from version.py. Reads it to avoid to load the shared library. r = re.compile("^__version__ = '(.*)'\n") try: - l = open('libghdl/config.py').read() + l = open('libghdl/version.py').read() m = r.match(l) if m: return m.group(1) except: pass - # Try to extract from configure - r = re.compile('^ghdl_version="(.*)"') - try: - for l in open('../configure').readlines(): - m = r.match(l) - if m: - return m.group(1) - except: - pass raise Exception("Cannot find version") # Extract the version now, as setup() may change the current directory. version=get_version() -class MyBuildPy(distutils.command.build_py.build_py): - def run(self): - with open('libghdl/config.py', 'w') as f: - f.write("__version__ = '{}'\n".format(version)) - super(MyBuildPy, self).run() - setup( name='libghdl', version=version, @@ -46,9 +31,6 @@ write tools like linters. author_email='tgingold@free.fr', url='http://github.com/ghdl/ghdl', license='GPL-2.0-or-later', - cmdclass={ - 'build_py': MyBuildPy - }, package_dir={ 'libghdl': './libghdl' }, |