-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
105 lines (86 loc) · 2.96 KB
/
setup.py
File metadata and controls
105 lines (86 loc) · 2.96 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import os
import subprocess
import sys
from pathlib import Path
from setuptools import setup
from setuptools.command.install import install
from setuptools.command.build_py import build_py
from setuptools.command.develop import develop
def download_sample_data():
"""Download sample 3DGS data"""
import requests
data_dir = Path("vulkan_3dgs/data")
data_dir.mkdir(exist_ok=True)
sample_file = data_dir / "bonsai.ply"
if not sample_file.exists():
print("Downloading sample 3DGS data...")
url = "https://huggingface.co/datasets/dylanebert/3dgs/resolve/main/bonsai/point_cloud/iteration_30000/point_cloud.ply?download=true"
try:
response = requests.get(url, stream=True)
response.raise_for_status()
with open(sample_file, 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
print(f"Downloaded sample data to {sample_file}")
except Exception as e:
print(f"Failed to download sample data: {e}")
else:
print(f"Sample data already exists at {sample_file}")
def build_cmake():
"""Build CMake project with Python bindings"""
cmake_source_dir = Path("vulkan_3dgs/csrc/3dgs-vulkan-cpp")
build_dir = cmake_source_dir / "build"
import shutil
if build_dir.exists():
shutil.rmtree(build_dir)
build_dir.mkdir(exist_ok=True)
print("Running CMake build...")
subprocess.check_call([
"cmake",
"-DBUILD_PYTHON_BINDING=ON",
".."
], cwd=build_dir)
subprocess.check_call([
"cmake",
"--build",
".",
"--config",
"Release",
], cwd=build_dir)
import glob
import platform
if platform.system() in ["Darwin", "Linux"]: # macOS and Linux
built_modules = glob.glob(str(build_dir / "vulkan-3dgs" / "vulkan_3dgs_py.*"))
else: # Windows
built_modules = glob.glob(str(build_dir / "vulkan-3dgs" / "*" / "vulkan_3dgs_py.*"))
if built_modules:
import shutil
dest = Path("vulkan_3dgs") / Path(built_modules[0]).name
python_modules = [f for f in built_modules if f.endswith(('.pyd', '.so'))]
if python_modules:
shutil.copy2(python_modules[0], dest)
shutil.copytree("vulkan_3dgs/csrc/3dgs-vulkan-cpp/vulkan-3dgs/src/Shaders",
"vulkan_3dgs/Shaders", dirs_exist_ok=True)
class CustomInstall(install):
def run(self):
download_sample_data()
build_cmake()
super().run()
class CustomDevelop(develop):
def run(self):
download_sample_data()
build_cmake()
super().run()
class CustomBuild(build_py):
def run(self):
download_sample_data()
build_cmake()
super().run()
setup(
name="vulkan-3dgs",
cmdclass={
"build_py": CustomBuild,
"install": CustomInstall,
"develop": CustomDevelop
}
)