Skip to content

Instantly share code, notes, and snippets.

@Jawabiscuit
Last active April 12, 2022 13:26
Show Gist options
  • Select an option

  • Save Jawabiscuit/113fdefb4a972eee51507cfd4af16336 to your computer and use it in GitHub Desktop.

Select an option

Save Jawabiscuit/113fdefb4a972eee51507cfd4af16336 to your computer and use it in GitHub Desktop.
Recipe snippets of rez package.py files

Rez Package Snippets

Tools

@late()
def tools():
    import os

    executables = []

    sitepath = os.path.join(this.root, "Lib", "site-packages", this.name)
    if os.path.exists(sitepath):
        executables.extend(os.listdir(sitepath))
    
    binpath = os.path.join(this.root, "Scripts")
    if os.path.exists(binpath):
        executables.extend(os.listdir(binpath))

    return executables

Variants

@early()
def variants():
    from rez.package_py_utils import expand_requires

    requires = ["platform-**", "arch-**", "os-**", "python-2.7"]
    return [expand_requires(*requires)]

Private Build Requires

@early()
def private_build_requires():
    import os

    requires = ["pip-19+"]
    if os.name == "nt":
        return ["msvc-14.16+<14.20"] + requires
    return ["cmake-3"] + requires

Build Commands

pwsh build_commands

@early()
def build_command():
    import os
    import sys

    if os.name == "nt":
        command = 'pwsh -File "{0}"'
        prefix = "%REZ_BUILD_SOURCE_PATH%"
        script = "rezbuild.ps1"

        return command.format(os.path.join(prefix, script))

Commands

command alias

def commands():
    import os

    env.PATH.prepend(os.path.join(this.root, this.name, "bin"))

    if os.name == "nt":
        alias("pycharm", "pycharm64")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment