mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[OpenReg] add pyproject.toml for openreg (#158440)
As the title stated. Pull Request resolved: https://github.com/pytorch/pytorch/pull/158440 Approved by: https://github.com/albanD ghstack dependencies: #158415
This commit is contained in:
@ -47,6 +47,7 @@ torch_openreg/
|
||||
│ ├── OpenRegHostAllocator.cpp
|
||||
│ ├── OpenRegHostAllocator.h
|
||||
│ └── ...
|
||||
├── pyproject.toml
|
||||
├── README.md
|
||||
├── setup.py
|
||||
├── third_party
|
||||
@ -144,9 +145,8 @@ There are 4 DSOs in torch_openreg, and the dependencies between them are as foll
|
||||
### Installation
|
||||
|
||||
```python
|
||||
pip3 install -r requirements.txt
|
||||
|
||||
python setup.py develop/install
|
||||
pip3 install --no-build-isolation -e . # for develop
|
||||
pip3 install --no-build-isolation . # for install
|
||||
```
|
||||
|
||||
### Usage Example
|
||||
|
@ -0,0 +1,35 @@
|
||||
[build-system]
|
||||
requires = [
|
||||
"setuptools",
|
||||
"wheel",
|
||||
"torch", # Needed by setup.py for getting include of PyTorch
|
||||
]
|
||||
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "torch_openreg"
|
||||
version = "0.0.1"
|
||||
description = "A minimal reference implementation of an out-of-tree backend"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.9"
|
||||
license = { text = "BSD-3-Clause" }
|
||||
authors = [{ name = "PyTorch Team", email = "packages@pytorch.org" }]
|
||||
dependencies = [
|
||||
"torch",
|
||||
]
|
||||
# Add classifiers info for making lint happy
|
||||
classifiers = [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Topic :: Software Development",
|
||||
"Topic :: Software Development :: Libraries",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
"Programming Language :: C++",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://pytorch.org"
|
||||
Repository = "https://github.com/pytorch/pytorch"
|
||||
Documentation = "https://pytorch.org/docs"
|
||||
Forum = "https://discuss.pytorch.org"
|
@ -1 +0,0 @@
|
||||
torch
|
@ -9,8 +9,8 @@ from distutils.command.clean import clean
|
||||
from setuptools import Extension, find_packages, setup
|
||||
|
||||
|
||||
PACKAGE_NAME = "torch_openreg"
|
||||
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
RUN_BUILD_DEPS = any(arg in {"clean", "dist_info"} for arg in sys.argv)
|
||||
|
||||
|
||||
def get_pytorch_dir():
|
||||
@ -49,7 +49,7 @@ def build_deps():
|
||||
|
||||
class BuildClean(clean):
|
||||
def run(self):
|
||||
for i in ["build", "install", "torch_openreg.egg-info", "torch_openreg/lib"]:
|
||||
for i in ["build", "install", "torch_openreg/lib"]:
|
||||
dirs = os.path.join(BASE_DIR, i)
|
||||
if os.path.exists(dirs) and os.path.isdir(dirs):
|
||||
shutil.rmtree(dirs)
|
||||
@ -60,9 +60,6 @@ class BuildClean(clean):
|
||||
os.remove(os.path.join(dirpath, filename))
|
||||
|
||||
|
||||
RUN_BUILD_DEPS = any(arg == "clean" for arg in sys.argv)
|
||||
|
||||
|
||||
def main():
|
||||
if not RUN_BUILD_DEPS:
|
||||
build_deps()
|
||||
@ -71,6 +68,7 @@ def main():
|
||||
Extension(
|
||||
name="torch_openreg._C",
|
||||
sources=["torch_openreg/csrc/stub.c"],
|
||||
language="c",
|
||||
extra_compile_args=["-g", "-Wall", "-Werror"],
|
||||
libraries=["torch_bindings"],
|
||||
library_dirs=[os.path.join(BASE_DIR, "torch_openreg/lib")],
|
||||
@ -78,20 +76,12 @@ def main():
|
||||
)
|
||||
]
|
||||
|
||||
package_data = {PACKAGE_NAME: ["lib/*.so*"]}
|
||||
package_data = {"torch_openreg": ["lib/*.so*"]}
|
||||
|
||||
setup(
|
||||
name=PACKAGE_NAME,
|
||||
version="0.0.1",
|
||||
author="PyTorch Core Team",
|
||||
description="Example for PyTorch out of tree registration",
|
||||
packages=find_packages(exclude=("test",)),
|
||||
packages=find_packages(),
|
||||
package_data=package_data,
|
||||
install_requires=[
|
||||
"torch",
|
||||
],
|
||||
ext_modules=ext_modules,
|
||||
python_requires=">=3.8",
|
||||
cmdclass={
|
||||
"clean": BuildClean, # type: ignore[misc]
|
||||
},
|
||||
|
@ -1,4 +1,5 @@
|
||||
import torch
|
||||
|
||||
import torch_openreg._C # type: ignore[misc]
|
||||
import torch_openreg.openreg
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import torch
|
||||
|
||||
import torch_openreg._C # type: ignore[misc]
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import torch
|
||||
|
||||
import torch_openreg._C # type: ignore[misc]
|
||||
|
||||
from . import _lazy_init, current_device, device_count
|
||||
|
Reference in New Issue
Block a user