Git-specific installation logic for Versioneer. For Git, this means creating/changing .gitattributes to mark _version.py for export-subst keyword substitution.
(versionfile_source, ipy)
| 1319 | |
| 1320 | |
| 1321 | def do_vcs_install(versionfile_source, ipy): |
| 1322 | """Git-specific installation logic for Versioneer. |
| 1323 | |
| 1324 | For Git, this means creating/changing .gitattributes to mark _version.py |
| 1325 | for export-subst keyword substitution. |
| 1326 | """ |
| 1327 | GITS = ["git"] |
| 1328 | if sys.platform == "win32": |
| 1329 | GITS = ["git.cmd", "git.exe"] |
| 1330 | files = [versionfile_source] |
| 1331 | if ipy: |
| 1332 | files.append(ipy) |
| 1333 | try: |
| 1334 | my_path = __file__ |
| 1335 | if my_path.endswith(".pyc") or my_path.endswith(".pyo"): |
| 1336 | my_path = os.path.splitext(my_path)[0] + ".py" |
| 1337 | versioneer_file = os.path.relpath(my_path) |
| 1338 | except NameError: |
| 1339 | versioneer_file = "versioneer.py" |
| 1340 | files.append(versioneer_file) |
| 1341 | present = False |
| 1342 | try: |
| 1343 | with open(".gitattributes", "r") as fobj: |
| 1344 | for line in fobj: |
| 1345 | if line.strip().startswith(versionfile_source): |
| 1346 | if "export-subst" in line.strip().split()[1:]: |
| 1347 | present = True |
| 1348 | break |
| 1349 | except OSError: |
| 1350 | pass |
| 1351 | if not present: |
| 1352 | with open(".gitattributes", "a+") as fobj: |
| 1353 | fobj.write(f"{versionfile_source} export-subst\n") |
| 1354 | files.append(".gitattributes") |
| 1355 | run_command(GITS, ["add", "--"] + files) |
| 1356 | |
| 1357 | |
| 1358 | def versions_from_parentdir(parentdir_prefix, root, verbose): |
no test coverage detected
searching dependent graphs…