mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Revert "[BE][Easy] use pathlib.Path
instead of dirname
/ ".."
/ pardir
(#129374)"
This reverts commit 9e1f3ecaa710785a1ab03c6ad5093a5566d6c5e5. Reverted https://github.com/pytorch/pytorch/pull/129374 on behalf of https://github.com/huydhn due to Sorry for reverting your change but it is still failing with the same error ([comment](https://github.com/pytorch/pytorch/pull/129374#issuecomment-2197801405))
This commit is contained in:
@ -1,25 +1,23 @@
|
||||
import argparse
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, cast, Optional
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
try:
|
||||
# use faster C loader if available
|
||||
from yaml import CSafeLoader as YamlLoader
|
||||
except ImportError:
|
||||
from yaml import SafeLoader as YamlLoader # type: ignore[assignment, misc]
|
||||
|
||||
|
||||
NATIVE_FUNCTIONS_PATH = "aten/src/ATen/native/native_functions.yaml"
|
||||
TAGS_PATH = "aten/src/ATen/native/tags.yaml"
|
||||
|
||||
|
||||
def generate_code(
|
||||
gen_dir: Path,
|
||||
gen_dir: pathlib.Path,
|
||||
native_functions_path: Optional[str] = None,
|
||||
tags_path: Optional[str] = None,
|
||||
install_dir: Optional[str] = None,
|
||||
@ -30,7 +28,6 @@ def generate_code(
|
||||
) -> None:
|
||||
from tools.autograd.gen_annotated_fn_args import gen_annotated
|
||||
from tools.autograd.gen_autograd import gen_autograd, gen_autograd_python
|
||||
|
||||
from torchgen.selective_build.selector import SelectiveBuilder
|
||||
|
||||
# Build ATen based Variable classes
|
||||
@ -42,7 +39,7 @@ def generate_code(
|
||||
autograd_gen_dir = os.path.join(install_dir, "autograd", "generated")
|
||||
for d in (autograd_gen_dir, python_install_dir):
|
||||
os.makedirs(d, exist_ok=True)
|
||||
autograd_dir = os.fspath(Path(__file__).parent.parent / "autograd")
|
||||
autograd_dir = os.fspath(pathlib.Path(__file__).parent.parent / "autograd")
|
||||
|
||||
if subset == "pybindings" or not subset:
|
||||
gen_autograd_python(
|
||||
@ -109,9 +106,8 @@ def get_selector(
|
||||
operators_yaml_path: Optional[str],
|
||||
) -> Any:
|
||||
# cwrap depends on pyyaml, so we can't import it earlier
|
||||
REPO_ROOT = Path(__file__).absolute().parents[2]
|
||||
sys.path.insert(0, str(REPO_ROOT))
|
||||
|
||||
root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
sys.path.insert(0, root)
|
||||
from torchgen.selective_build.selector import SelectiveBuilder
|
||||
|
||||
assert not (
|
||||
@ -135,8 +131,8 @@ def main() -> None:
|
||||
parser.add_argument("--tags-path")
|
||||
parser.add_argument(
|
||||
"--gen-dir",
|
||||
type=Path,
|
||||
default=Path("."),
|
||||
type=pathlib.Path,
|
||||
default=pathlib.Path("."),
|
||||
help="Root directory where to install files. Defaults to the current working directory.",
|
||||
)
|
||||
parser.add_argument(
|
||||
|
Reference in New Issue
Block a user