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