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

Function versions_from_parentdir

shapely/_version.py:120–147  ·  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

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

Callers 1

get_versionsFunction · 0.70

Calls 1

NotThisMethodClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…