mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Support for sapling scm (#122072)
We can use Sapling (hg) with the pytorch repo but there are a couple minor issues to teach our scripting to be happier with having either a git or hg repo. This change fixes some issues in: - setup.py - lintrunner Pull Request resolved: https://github.com/pytorch/pytorch/pull/122072 Approved by: https://github.com/ezyang
This commit is contained in:
committed by
PyTorch MergeBot
parent
482f6c4693
commit
f7b8d8e249
@ -13,13 +13,22 @@ from pathlib import Path
|
||||
from sysconfig import get_paths as gp
|
||||
from typing import Any, List, NamedTuple, Optional, Pattern
|
||||
|
||||
|
||||
# PyTorch directory root
|
||||
result = subprocess.run(
|
||||
["git", "rev-parse", "--show-toplevel"],
|
||||
stdout=subprocess.PIPE,
|
||||
check=True,
|
||||
)
|
||||
PYTORCH_ROOT = result.stdout.decode("utf-8").strip()
|
||||
def scm_root() -> str:
|
||||
path = os.path.abspath(os.getcwd())
|
||||
while True:
|
||||
if os.path.isdir(os.path.join(path, ".git")):
|
||||
return path
|
||||
if os.path.isdir(os.path.join(path, ".hg")):
|
||||
return path
|
||||
n = len(path)
|
||||
path = os.path.dirname(path)
|
||||
if len(path) == n:
|
||||
raise RuntimeError("Unable to find SCM root")
|
||||
|
||||
|
||||
PYTORCH_ROOT = scm_root()
|
||||
IS_WINDOWS: bool = os.name == "nt"
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user