Source code for cgl.plugins.USD.setup.setup
import os
import logging
from cgl.core.utils.general import cgl_execute, cgl_copy
from cgl.core.config.edit import edit_user_config
from cgl.core.config.query import get_user_dir
[docs]
def setup():
"""
runs the pip install requirements.txt using blender 4's build in version of python, this will ensure that blender
is set up to work with Alchemy out the gate.
Returns:
"""
program_files = os.getenv("PROGRAMFILES")
substance_python_path = (
r"{}\Adobe\Adobe Substance 3D Painter\resources\pythonsdk".format(program_files)
)
if os.path.exists(substance_python_path):
code_root = CFG.get_code_root()
requirements_path = os.path.join(
code_root, "cgl", "plugins", "USD", "setup", "requirements.txt"
)
os.chdir(code_root)
command = f'"{substance_python_path}" -m pip install -r {requirements_path}'
cgl_execute(command, verbose=True)
edit_user_config(["software", f"Substance Painter"])
if not os.path.exists(requirements_path):
print('Requirements file not found at "{}"'.format(requirements_path))
else:
print(substance_python_path)
logging.info("Substance Painter not found")
[docs]
def copy_user_setup():
code_root = CFG.get_code_root()
copy_source = os.path.join(code_root, "cgl", "plugins", "substance", "userSetup.py")
user_path = get_user_dir()
substance_startup_path = os.path.join(
user_path,
"Documents",
"Adobe",
"Adobe Substance 3D Painter",
"python",
"startup",
)
# TODO - i need to hard code the ALC_PYTHON_PATH as well as the ALC_CODE_ROOT, or we need them as env vars.
# so far this is one of the only places where we need to hard code the path to the code root.
if os.path.exists(substance_startup_path):
copy_destination = os.path.join(substance_startup_path, "userSetup.py")
print("Copying {} to {}".format(copy_source, copy_destination))
cgl_copy(source=copy_source, destination=copy_destination, verbose=True)
else:
print("Path Does Not Exist: {}".format(substance_startup_path))