馃悕馃悕馃悕
1from setuptools import setup
2import os
3import sys
4from torch.utils.cpp_extension import BuildExtension, CUDAExtension
5import torch
6
7cwd = os.path.dirname(os.path.abspath(__file__))
8include_path = None
9lib_path = None
10
11if sys.platform.startswith("linux"):
12 glfw_libraries = ["glfw", "GL"]
13elif sys.platform.startswith("win"):
14 glfw_libraries = ["glfw3dll", "opengl32"]
15else:
16 raise Exception("Unsupported platform.") # TODO pick a more specific exception type
17
18if "INCLUDE_PATH" in os.environ:
19 include_path = os.environ["INCLUDE_PATH"]
20
21if "LIB_PATH" in os.environ:
22 lib_path = os.environ["LIB_PATH"]
23
24if include_path is None or lib_path is None:
25 raise Exception("INCLUDE_PATH and LIB_PATH must be set.")
26
27ext_modules = [
28 CUDAExtension(
29 "cudacanvas.cudacanvas_cpp",
30 ["cudacanvas/cudacanvas.cpp"],
31 include_dirs=[include_path],
32 library_dirs=[lib_path],
33 libraries=glfw_libraries,
34 language="c++"
35 )
36]
37
38setup(
39 name="cudacanvas",
40 packages=["cudacanvas"],
41 ext_modules=ext_modules,
42 cmdclass={
43 "build_ext": BuildExtension
44 },
45 install_requires=["glfw"]
46)
47