-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
55 lines (48 loc) · 1.59 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
import sys
import shutil
import platform
from skbuild import setup
from setuptools import find_packages
from setuptools.command.install import install
class CleanInstall(install):
def run(self):
install.run(self)
install_path = self.install_lib
extensions = [".cpp", ".h", ".cu", ".hip"]
for root, dirs, files in os.walk(install_path):
for file in files:
if any(file.endswith(ext) for ext in extensions):
os.remove(os.path.join(root, file))
nvcc_path = shutil.which("nvcc")
hipcc_path = shutil.which("hipcc")
if nvcc_path:
compiler_choice = "-DUSE_CUDA=ON"
elif hipcc_path:
compiler_choice = "-DUSE_HIP=ON"
else:
raise RuntimeError("Neither CUDA nor HIP were found on this system.")
if platform.system() != "Linux":
raise RuntimeError("This package is only supported on Linux.")
setup(
name="TorchImager",
version="0.2.0",
description="A Python library for displaying 2D tensors using OpenGL and HIP/CUDA interop",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="Picus303",
author_email="[email protected]",
url="https://github.com/Picus303/TorchImager",
license="MIT",
packages=find_packages(),
cmake_install_dir="TorchImager",
cmake_minimum_required_version="3.18",
cmake_args=[
f"-DPYTHON_EXECUTABLE={sys.executable}",
compiler_choice,
],
include_package_data=True,
python_requires=">=3.10",
install_requires=["torch"],
cmdclass={"install": CleanInstall}
)