Revert "[BE][Easy] replace import pathlib with from pathlib import Path (#129426)"

This reverts commit 6d75604ef135925e8c85363c2f4a5e0b6f7fef28.

Reverted https://github.com/pytorch/pytorch/pull/129426 on behalf of https://github.com/XuehaiPan due to recognize `Path` as new exported API ([comment](https://github.com/pytorch/pytorch/pull/129426#issuecomment-2198371625))
This commit is contained in:
PyTorch MergeBot
2024-06-29 23:24:06 +00:00
parent 67c9ec2b6d
commit 2effbcfcd8
33 changed files with 140 additions and 159 deletions

View File

@ -2,8 +2,8 @@ from __future__ import annotations
import argparse
import os
import pathlib
import sys
from pathlib import Path
from typing import Any, cast
import yaml
@ -19,7 +19,7 @@ TAGS_PATH = "aten/src/ATen/native/tags.yaml"
def generate_code(
gen_dir: Path,
gen_dir: pathlib.Path,
native_functions_path: str | None = None,
tags_path: str | None = None,
install_dir: str | None = None,
@ -41,7 +41,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(
@ -133,8 +133,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(