MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / versions_from_parentdir

Function versions_from_parentdir

monai/_version.py:115–136  ·  view source on GitHub ↗

Try to determine the version from the parent directory name. Source tarballs conventionally unpack into a directory that includes both the project name and a version string. We will also support searching up two directory levels for an appropriately named parent directory

(parentdir_prefix, root, verbose)

Source from the content-addressed store, hash-verified

113
114
115def versions_from_parentdir(parentdir_prefix, root, verbose):
116 """Try to determine the version from the parent directory name.
117
118 Source tarballs conventionally unpack into a directory that includes both
119 the project name and a version string. We will also support searching up
120 two directory levels for an appropriately named parent directory
121 """
122 rootdirs = []
123
124 for _ in range(3):
125 dirname = os.path.basename(root)
126 if dirname.startswith(parentdir_prefix):
127 return {"version": dirname[len(parentdir_prefix):],
128 "full-revisionid": None,
129 "dirty": False, "error": None, "date": None}
130 rootdirs.append(root)
131 root = os.path.dirname(root) # up a level
132
133 if verbose:
134 print("Tried directories %s but none started with prefix %s" %
135 (str(rootdirs), parentdir_prefix))
136 raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
137
138
139@register_vcs_handler("git", "get_keywords")

Callers 1

get_versionsFunction · 0.70

Calls 2

NotThisMethodClass · 0.70
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…