MCPcopy Create free account
hub / github.com/dask/dask / versions_from_parentdir

Function versions_from_parentdir

dask/dataframe/dask_expr/_version.py:135–166  ·  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: str,
    root: str,
    verbose: bool,
)

Source from the content-addressed store, hash-verified

133
134
135def versions_from_parentdir(
136 parentdir_prefix: str,
137 root: str,
138 verbose: bool,
139) -> dict[str, Any]:
140 """Try to determine the version from the parent directory name.
141
142 Source tarballs conventionally unpack into a directory that includes both
143 the project name and a version string. We will also support searching up
144 two directory levels for an appropriately named parent directory
145 """
146 rootdirs = []
147
148 for _ in range(3):
149 dirname = os.path.basename(root)
150 if dirname.startswith(parentdir_prefix):
151 return {
152 "version": dirname[len(parentdir_prefix) :],
153 "full-revisionid": None,
154 "dirty": False,
155 "error": None,
156 "date": None,
157 }
158 rootdirs.append(root)
159 root = os.path.dirname(root) # up a level
160
161 if verbose:
162 print(
163 "Tried directories %s but none started with prefix %s"
164 % (str(rootdirs), parentdir_prefix)
165 )
166 raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
167
168
169@register_vcs_handler("git", "get_keywords")

Callers 1

get_versionsFunction · 0.70

Calls 1

NotThisMethodClass · 0.70

Tested by

no test coverage detected