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)
| 36 | return f.readlines() |
| 37 | |
| 38 | def 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 | |
| 58 | setup( |
| 59 | author='Apache Mesos', |