updated wheels installation

This commit is contained in:
Ubuntu
2025-06-13 08:03:21 +00:00
parent 9cb998eadd
commit 464f475855
5 changed files with 255 additions and 37 deletions
+88 -8
View File
@@ -4,6 +4,7 @@ from os.path import dirname
import subprocess
import re
import time
import platform
BUILD_SCRIPT_ROOT_ABS_PATH = dirname(__file__)
sys.path.append(BUILD_SCRIPT_ROOT_ABS_PATH)
@@ -51,6 +52,11 @@ def setup_build_env():
install_remote_packages(build_config.build_base_packages)
install_platform_packages()
# Install spconv with correct CUDA version
from build_utils import install_spconv
if not install_spconv():
raise RuntimeError("Failed to install spconv")
def clone_or_update_read_dependency(dependency_url, dependency_dir):
if os.path.exists(dependency_dir):
@@ -61,19 +67,71 @@ def clone_or_update_read_dependency(dependency_url, dependency_dir):
subprocess.run(["git", "clone", "--recursive", dependency_url, dependency_dir])
def build_python_wheel(dependency_dir, output_dir):
# Build wheel and move the wheel file we just built to the output directory
print(f"Building {dependency_dir}")
"""Build wheel using available build method"""
print(f"Checking {dependency_dir}")
setup_py_path = os.path.join(dependency_dir, "setup.py")
pyproject_toml_path = os.path.join(dependency_dir, "pyproject.toml")
has_setup_py = os.path.exists(setup_py_path)
has_pyproject = os.path.exists(pyproject_toml_path)
if not has_setup_py and not has_pyproject:
print(f"No setup.py or pyproject.toml found in {dependency_dir}, skipping")
return None # Skipped
# Try different build methods
if has_setup_py:
print(f"Building wheel for {dependency_dir} using setup.py")
result = subprocess.run(
[PYTHON_PATH, "setup.py", "bdist_wheel", "--dist-dir", output_dir],
cwd=dependency_dir, text=True, capture_output=True
)
else:
print(f"Building wheel for {dependency_dir} using pip wheel")
result = subprocess.run(
[PYTHON_PATH, "-m", "pip", "wheel", ".", "--no-deps", "--wheel-dir", output_dir],
cwd=dependency_dir, text=True, capture_output=True
)
result = subprocess.run([PYTHON_PATH, "setup.py", "bdist_wheel", "--dist-dir", output_dir], cwd=dependency_dir, text=True, capture_output=True)
#print(f"returncode: {result.returncode} \n\n Output: {result.stdout} \n\n Error: {result.stderr}")
build_failed = result.returncode != 0
if build_failed:
print(f"[Wheel BUILD LOG]\n{result.stdout}")
print(f"[Wheel BUILD ERROR LOG]\n{result.stderr}")
# If first method failed and we have both files, try the other method
if has_setup_py and has_pyproject:
print(f"Retrying with pip wheel method...")
result = subprocess.run(
[PYTHON_PATH, "-m", "pip", "wheel", ".", "--no-deps", "--wheel-dir", output_dir],
cwd=dependency_dir, text=True, capture_output=True
)
build_failed = result.returncode != 0
if build_failed:
print(f"[Retry BUILD LOG]\n{result.stdout}")
print(f"[Retry BUILD ERROR LOG]\n{result.stderr}")
print(f" Build {dependency_dir} {'Failed' if build_failed else 'Succeed'}")
return build_failed
# If wheel building failed, try direct installation as fallback
if build_failed:
print(f"Wheel building failed, trying direct installation...")
result = subprocess.run(
[PYTHON_PATH, "-m", "pip", "install", "."],
cwd=dependency_dir, text=True, capture_output=True
)
if result.returncode == 0:
print(f"Direct install {dependency_dir} Succeed (no wheel created)")
return "installed" # Installed directly, no wheel
else:
print(f"[Direct INSTALL LOG]\n{result.stdout}")
print(f"[Direct INSTALL ERROR LOG]\n{result.stderr}")
print(f"Build and install {dependency_dir} Failed")
return False # Failed
else:
print(f"Build {dependency_dir} Succeed")
return True # Success
def main(args):
start_time = time.time()
@@ -95,17 +153,39 @@ def main(args):
# Build all dependencies and move them to output_root_path
failed_build = []
skipped_build = []
successful_build = []
direct_installed = []
for dependency in dependencies:
dependency_dir, is_url = get_dependency_dir(dependency)
if is_url:
clone_or_update_read_dependency(dependency, dependency_dir)
# Check if directory exists
if not os.path.exists(dependency_dir):
print(f"Directory {dependency_dir} does not exist, skipping")
skipped_build.append(dependency)
continue
build_failed = build_python_wheel(dependency_dir, output_root_path)
if build_failed:
result = build_python_wheel(dependency_dir, output_root_path)
if result is None:
skipped_build.append(dependency)
elif result == "installed":
direct_installed.append(dependency)
elif result is False:
failed_build.append(dependency)
else:
successful_build.append(dependency)
hours, minutes, seconds = calculate_runtime(start_time)
print(f"Build all dependencies finished in {int(hours):0>2}:{int(minutes):0>2}:{seconds:05.2f}")
print(f"Results: {len(successful_build)} wheels built, {len(direct_installed)} direct installs, {len(skipped_build)} skipped, {len(failed_build)} failed")
if len(skipped_build) > 0:
print(f"Skipped dependencies (no setup.py/pyproject.toml): {skipped_build}")
if len(direct_installed) > 0:
print(f"Direct installed dependencies (no wheel): {direct_installed}")
if len(failed_build) == 0:
print(f"[Comfy3D BUILD SUCCEED]")
+12 -5
View File
@@ -1,4 +1,4 @@
repo_id: "MrForExample/Comfy3D_Pre_Builds"
repo_id: "DenisKochetov/Comfy3D_Pre_Builds"
supported_cuda_versions: ["12.8", "12.6", "12.4", "12.1", "11.8"]
cuda_version: "12.8"
@@ -22,6 +22,14 @@ platform_packages:
linux:
- "triton"
# Simple spconv installation with CUDA mapping
spconv_cuda_mapping:
"12.8": "cu126" # Default for 12.8 and maximum available
"12.6": "cu126"
"12.4": "cu124"
"12.1": "cu121"
"11.8": "cu118"
# All packages will be automatically installed at beginning of install.py follwing orders from top to bottom
remote_packages:
torch:
@@ -36,7 +44,6 @@ remote_packages:
version: "0.0.30"
url: "https://download.pytorch.org/whl/${cuda_version}"
# At the time of writing, torch-scatter is not available for PyTorch 2.5.0
#torch-scatter:
# url_option: "--find-links"
# url: "https://data.pyg.org/whl/torch-${remote_packages.torch.version}+${cuda_version}.html"
torch-scatter:
url_option: "--find-links"
url: "https://data.pyg.org/whl/torch-${remote_packages.torch.version}+${cuda_version}.html"
+44
View File
@@ -250,6 +250,50 @@ def install_platform_packages():
print(f"Installing platform package {package}...")
subprocess.run([PYTHON_PATH, "-s", "-m", "pip", "install", package])
def install_spconv():
"""Simple spconv installation with correct CUDA version"""
# Check if spconv is already installed
try:
import spconv.core_cc
print("spconv is already installed and working")
return True
except ImportError:
pass
# Get CUDA version mapping
if not hasattr(build_config, 'spconv_cuda_mapping'):
print("No spconv_cuda_mapping in config, skipping spconv installation")
return True
# Convert CUDA_VERSION (e.g. cu128 -> 12.8) for lookup
cuda_version_for_lookup = CUDA_VERSION[2:3] + '.' + CUDA_VERSION[3:]
cuda_suffix = build_config.spconv_cuda_mapping.get(cuda_version_for_lookup)
if not cuda_suffix:
print(f"No spconv mapping for CUDA {cuda_version_for_lookup}, skipping")
return True
spconv_package = f"spconv-{cuda_suffix}"
print(f"Installing {spconv_package}...")
result = subprocess.run(
[PYTHON_PATH, "-m", "pip", "install", spconv_package],
text=True, capture_output=True
)
if result.returncode != 0:
print(f"Failed to install {spconv_package}: {result.stderr}")
return False
# Verify installation
try:
import spconv.core_cc
print(f"Successfully installed and verified {spconv_package}")
return True
except ImportError as e:
print(f"spconv installed but verification failed: {e}")
return False
def wheels_dir_exists_and_not_empty(builds_dir):
if not os.path.exists(builds_dir):
return False