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)
| 1346 | |
| 1347 | |
| 1348 | def versions_from_parentdir(parentdir_prefix, root, verbose): |
| 1349 | """Try to determine the version from the parent directory name. |
| 1350 | |
| 1351 | Source tarballs conventionally unpack into a directory that includes both |
| 1352 | the project name and a version string. We will also support searching up |
| 1353 | two directory levels for an appropriately named parent directory |
| 1354 | """ |
| 1355 | rootdirs = [] |
| 1356 | |
| 1357 | for _ in range(3): |
| 1358 | dirname = os.path.basename(root) |
| 1359 | if dirname.startswith(parentdir_prefix): |
| 1360 | return {"version": dirname[len(parentdir_prefix):], |
| 1361 | "full-revisionid": None, |
| 1362 | "dirty": False, "error": None, "date": None} |
| 1363 | rootdirs.append(root) |
| 1364 | root = os.path.dirname(root) # up a level |
| 1365 | |
| 1366 | if verbose: |
| 1367 | print("Tried directories %s but none started with prefix %s" % |
| 1368 | (str(rootdirs), parentdir_prefix)) |
| 1369 | raise NotThisMethod("rootdir doesn't start with parentdir_prefix") |
| 1370 | |
| 1371 | |
| 1372 | SHORT_VERSION_PY = """ |
no test coverage detected
searching dependent graphs…