Exemple #1
0
def make_patches():
    """
    Override some original blender files for OCVL
    :return:
    """
    FILES_TO_CLEAN = ["tests/python/CMakeLists.txt"]

    def clean_up_tests():
        for file in FILES_TO_CLEAN:
            with open(file, 'w') as fp:
                pass

    def check_hash(patch):
        with open(patch, 'r') as fp:
            match = re.match(r"diff --git a/(.*) b/", str(fp.readline()))
        path = match.groups()[0]
        out, _ = cmd(f"git ls-files -s {path}", stdout=subprocess.PIPE)
        new_hash = str(out).split(" ")[1]
        match = re.match(r".*build_files/patches/(.*)-.*", str(patch))
        old_hash = match.groups()[0]
        if old_hash != new_hash:
            print(f"WARNING: Update files patches - {patch}")

    os.chdir(os.path.join(WORK_DIR, BLENDER_SOURCE_DIR_NAME))
    patch_names = os.listdir(OCVL_PATCHES_PATH)
    for patch_name in patch_names:
        patch = os.path.join(OCVL_PATCHES_PATH, patch_name)
        try:
            check_hash(patch)
        except Exception as e:
            print(f"WARNING: Can not check hashes - {e}")
        cmd(f"git apply {patch}")

    clean_up_tests()
    os.chdir(WORK_DIR)
Exemple #2
0
 def remove_old_numpy():
     cmd(f"{BLENDER_PIP_BIN} uninstall -y numpy")
     destination_path = os.path.join(WORK_DIR, BUILD_RELEASE_DIRNAME,
                                     BIN_RELEASE, "2.80", "python", "lib",
                                     PYTHON_PACKAGES, "numpy")
     if os.path.exists(destination_path):
         print(f"Remove old version Numpy from: {destination_path}")
         shutil.rmtree(destination_path)
Exemple #3
0
def update_blender_submodule(branch='master'):
    """
    Update Blender submodules
    :param branch:
    :return:
    """
    os.chdir(os.path.join(WORK_DIR, BLENDER_SOURCE_DIR_NAME))
    cmd(f"git submodule foreach git checkout {branch}")
    cmd(f"git submodule foreach git pull --rebase origin {branch}")
    os.chdir(WORK_DIR)
Exemple #4
0
def get_get_pip_script():
    """
    Get get-pip file from remote server
    :return:
    """
    os.chdir(WORK_DIR)
    get_pip_filepath = os.path.join(WORK_DIR, GET_PIP_FILE_NAME)
    if not os.path.isfile(f"{get_pip_filepath}"):
        cmd(f"curl {GET_PIP_URL} -o {GET_PIP_FILE_NAME}")

    cmd(f"{BLENDER_PYTHON_BIN} {get_pip_filepath}")
    os.chdir(WORK_DIR)
Exemple #5
0
def install_ocvl_requirements():
    """
    Install requirements.txt in Blender Python
    :return:
    """
    def remove_old_numpy():
        cmd(f"{BLENDER_PIP_BIN} uninstall -y numpy")
        destination_path = os.path.join(WORK_DIR, BUILD_RELEASE_DIRNAME,
                                        BIN_RELEASE, "2.80", "python", "lib",
                                        PYTHON_PACKAGES, "numpy")
        if os.path.exists(destination_path):
            print(f"Remove old version Numpy from: {destination_path}")
            shutil.rmtree(destination_path)

    if PLATFORM != "Darwin":
        remove_old_numpy()
    cmd(f"{BLENDER_PIP_BIN} install -r {OCVL_REQUIREMENTS_PATH}")
    os.chdir(WORK_DIR)
Exemple #6
0
 def check_hash(patch):
     with open(patch, 'r') as fp:
         match = re.match(r"diff --git a/(.*) b/", str(fp.readline()))
     path = match.groups()[0]
     out, _ = cmd(f"git ls-files -s {path}", stdout=subprocess.PIPE)
     new_hash = str(out).split(" ")[1]
     match = re.match(r".*build_files/patches/(.*)-.*", str(patch))
     old_hash = match.groups()[0]
     if old_hash != new_hash:
         print(f"WARNING: Update files patches - {patch}")
Exemple #7
0
def update_blender(branch='master'):
    """
    Update Blender
    :return:
    """
    os.chdir(os.path.join(WORK_DIR, BLENDER_SOURCE_DIR_NAME))
    cmd(f"git reset --hard")
    cmd(f"git checkout {branch}")
    cmd(f"git pull", accepted_status_code=[0, 1])
    os.chdir(WORK_DIR)
Exemple #8
0
def update_ocvl_addon(branch='master'):
    """
    Update OCVL ADDON
    :return:
    """
    if DEBUG:
        return
    os.chdir(os.path.join(WORK_DIR, OCVL_ADDON_DIR_NAME))
    cmd(f"git resert --hard")
    cmd(f"git checkout {branch}")
    cmd(f"git pull")
    os.chdir(WORK_DIR)
Exemple #9
0
def build_blender(build_version=BUILD_VERSION):
    os.chdir(os.path.join(WORK_DIR, BLENDER_SOURCE_DIR_NAME))
    cmd(f"{MAKE_COMMAND} {build_version}")
    os.chdir(WORK_DIR)