Commit 447fb73f authored by Jakob Luettgau's avatar Jakob Luettgau
Browse files

Add version check (enforce first three version positions to match, thus allow...

Add version check (enforce first three version positions to match, thus allow pydarshan to advance x.x.x.*).
parent 196eae16
.PHONY: clean clean-test clean-pyc clean-build docs help
clean: clean-build clean-pyc clean-test # remove all build, test, coverage and Python artifacts
clean: clean-build clean-docs clean-pyc clean-test # remove all build, test, coverage and Python artifacts
clean-build: # remove build artifacts
rm -rf build/
rm -rf dist/
rm -rf .eggs/
rm -rf docs/_build
find . -name '*.egg-info' -exec rm -rf {} +
find . -name '*.egg' -exec rm -rf {} +
clean-docs:
rm -rf docs/build
rm -f docs/darshan.rst
rm -f docs/darshan.*.rst
rm -f docs/modules.rst
clean-pyc: # remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
......@@ -40,11 +45,7 @@ coverage: # check code coverage quickly with the default Python
xdg-open htmlcov/index.html
docs: # generate Sphinx HTML documentation, including API docs
rm -f docs/darshan.rst
rm -f docs/darshan.backend.rst
rm -f docs/darshan.plots.rst
rm -f docs/modules.rst
docs: clean-docs # generate Sphinx HTML documentation, including API docs
sphinx-apidoc -o docs/ darshan
$(MAKE) -C docs clean
$(MAKE) -C docs html
......
# -*- coding: utf-8 -*-
"""Top-level package for pydarshan."""
__version__ = '0.1.0'
__version__ = '3.2.1'
options = {
......
......@@ -20,10 +20,24 @@ ffi.cdef(API_def_c)
libdutil = None
libdutil = find_utils(ffi, libdutil)
check_version(ffi, libdutil)
def get_lib_version():
"""
Return the version information hardcoded into the shared library.
Args:
None
Return:
version (str): library version number
"""
ver = ffi.new("char **")
ver = libdutil.darshan_log_get_lib_version()
version = ffi.string(ver).decode("utf-8")
return version
def log_open(filename):
......@@ -538,3 +552,6 @@ def log_get_stdio_record(log):
dict: log record
"""
return log_get_generic_record(log, "STDIO", "struct darshan_stdio_file **")
......@@ -8,21 +8,46 @@ import os
def check_version():
def check_version(ffi=None, libdutil=None):
"""
Get version from pkg-config and return info.
:return: Path to a darshan-util installation.
"""
lib_version = None
# query library directly (preferred)
if ffi is not None and libdutil is not None:
ver = ffi.new("char **")
ver = libdutil.darshan_log_get_lib_version()
lib_version = ffi.string(ver).decode("utf-8")
# pkgconfig fallback
if lib_version is None:
print("WARNING: Using pk-config fallback.")
import subprocess
args = ['pkg-config', '--modversion', 'darshan-util']
p = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd='.')
out,err = p.communicate()
retval = p.wait()
lib_version = out.decode('ascii').strip()
import darshan
package_version = darshan.__version__.split(".")
lib_version = lib_version.split(".")
if package_version[0:3] != lib_version[0:3]:
from darshan.error import DarshanVersionError
raise DarshanVersionError(
target_version = ".".join(package_version[0:3]),
provided_version = ".".join(lib_version),
msg="This version of PyDarshan")
import subprocess
args = ['pkg-config', '--modversion', 'darshan-util']
p = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd='.')
out,err = p.communicate()
retval = p.wait()
return lib_version
return out.decode('ascii').strip()
def discover_darshan_pkgconfig():
......
......@@ -13,15 +13,13 @@ class DarshanVersionError(NotImplementedError):
"""
Raised when using a feature which is not provided by libdarshanutil.
"""
min_version = None
def __init__(self, min_version, msg="Feature"):
def __init__(self, target_version, provided_version, msg="Feature"):
self.msg = msg
self.min_version = min_version
self.version = "0.0.0"
self.target_version = target_version
self.provided_version = provided_version
def __repr__(self):
return "DarshanVersionError('%s')" % str(self)
def __str__(self):
return "%s requires libdarshanutil >= %s, have %s" % (self.msg, self.min_version, self.version)
return "%s requires libdarshan-util %s, but found %s" % (self.msg, self.target_version, self.provided_version)
Markdown is supported
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