MCPcopy Create free account
hub / github.com/apache/mesos / find_version

Function find_version

src/python/lib/setup.py:38–56  ·  view source on GitHub ↗

Find the version string in a file relative to the current directory. :param relative_path_parts: list of path parts relative to the current directory where the file containing the __version__ st

(*relative_path_parts)

Source from the content-addressed store, hash-verified

36 return f.readlines()
37
38def find_version(*relative_path_parts):
39 """
40 Find the version string in a file relative to the current directory.
41
42 :param relative_path_parts: list of path parts relative
43 to the current directory where
44 the file containing the __version__
45 string lives
46 :type relative_path_parts: list[str]
47 :rtype: str
48 """
49 currdir = os.path.abspath(os.path.dirname(__file__))
50 version_file = os.path.join(currdir, *relative_path_parts)
51
52 with open(version_file, 'r') as f:
53 match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", f.read(), re.M)
54 if not match:
55 raise RuntimeError("Unable to find version string.")
56 return match.group(1)
57
58setup(
59 author='Apache Mesos',

Callers 1

setup.pyFile · 0.85

Calls 4

dirnameMethod · 0.80
joinMethod · 0.65
openFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected