forked from LuxCoreRender/BlendLuxCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
104 lines (86 loc) · 3.71 KB
/
__init__.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
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
import bpy
import platform
import os
from shutil import which
def get_bin_directory():
current_dir = os.path.dirname(os.path.realpath(__file__))
return os.path.join(current_dir, "bin")
if platform.system() == "Darwin":
if bpy.app.version < (2, 82, 7):
raise Exception("\n\nUnsupported Blender version. 2.82a or higher is required.")
mac_version = tuple(map(int, platform.mac_ver()[0].split(".")))
if mac_version < (10, 9, 0):
raise Exception("\n\nUnsupported Mac OS version. 10.9 or higher is required.")
if platform.system() == "Windows":
# Ensure nvrtc-builtins64_101.dll can be found
bin_directory = get_bin_directory()
try:
from ctypes import windll, c_wchar_p
from ctypes.wintypes import DWORD
AddDllDirectory = windll.kernel32.AddDllDirectory
AddDllDirectory.restype = DWORD
AddDllDirectory.argtypes = [c_wchar_p]
os.environ["PATH"] = bin_directory + os.pathsep + os.environ["PATH"]
AddDllDirectory(bin_directory)
except AttributeError:
# Windows 7 users might be missing this update
raise Exception("\n\nYou need to install this update: "
"https://www.microsoft.com/en-us/download/details.aspx?id=26764") from None
if platform.system() in {"Linux", "Darwin"}:
# Required for downloads from the LuxCore Online Library
import certifi
os.environ["SSL_CERT_FILE"] = certifi.where()
os.environ["REQUESTS_CA_BUNDLE"] = certifi.where()
# Make sure denoiser is executable
denoiser_path = which("oidnDenoise", mode=os.F_OK, path=get_bin_directory() + os.pathsep + os.environ["PATH"])
if not os.access(denoiser_path, os.X_OK):
print("Making LuxCore denoiser executable")
os.chmod(denoiser_path, 0o755)
try:
from .bin import pyluxcore
except ImportError as error:
msg = "\n\nCould not import pyluxcore."
if platform.system() == "Windows":
msg += ("\nYou probably forgot to install one of the "
"redistributable packages.\n"
"They are listed in the release announcement post.")
elif platform.system() == "Linux":
if str(error) == "ImportError: libOpenCL.so.1: cannot open shared object file: No such file or directory":
msg += ("\nYour OpenCL installation is probably missing or broken. "
"Look up how to install OpenCL on your system.")
# Raise from None to suppress the unhelpful
# "during handling of the above exception, ..."
raise Exception(msg + "\n\nImportError: %s" % error) from None
bl_info = {
"name": "LuxCore",
"author": "Simon Wendsche (B.Y.O.B.), Michael Klemm (neo2068), Philstix",
"version": (2, 5),
"blender": (2, 80, 0),
"category": "Render",
"location": "Info header, render engine menu",
"description": "LuxCore integration for Blender",
"warning": "beta1",
"wiki_url": "https://wiki.luxcorerender.org/",
"tracker_url": "https://github.com/LuxCoreRender/BlendLuxCore/issues/new",
}
from . import auto_load, nodes, properties, handlers
auto_load.init()
from .operators import keymaps
def register():
auto_load.register()
nodes.materials.register()
nodes.textures.register()
nodes.volumes.register()
handlers.register()
keymaps.register()
from .utils.log import LuxCoreLog
pyluxcore.Init(LuxCoreLog.add)
version_string = f'{bl_info["version"][0]}.{bl_info["version"][1]}{bl_info["warning"]}'
print(f"BlendLuxCore {version_string} registered (with pyluxcore {pyluxcore.Version()})")
def unregister():
keymaps.unregister()
handlers.unregister()
nodes.materials.unregister()
nodes.textures.unregister()
nodes.volumes.unregister()
auto_load.unregister()