Skip to content

Feature request: "proxy" packages that support direct editing of files without rebuild #1748

Open
@chadrik

Description

@chadrik

Hi all,
I think this topic has probably come up at every studio that has ever used Rez. I think adoption would be faster, and developer workflows would be simpler and safer if Rez supported this concept natively. Let me know what you think.

Goal

As a Rez developer I want a way for local rez packages to reference live files, so that I can rapidly iterate without needing to rebuild after every change.   Files that I might want to edit in-place include interpreted source code (python, shell scripts), configuration files, and the package.py files themselves. 

Motivation

In a typical Rez studio environment, there are many rez packages which do not require compilation as part of the build process.  The build commands for these packages may simply copy some folders and files to the install location.  Some Rez packages are used to bundle together particular packages and versions, and so the package.py file is the sole file that requires editing and installing.

In these situations, it is a drain on developer time to rebuild packages each time that a file is edited. 

Proposal

  • Add a new --proxy flag to rez build: when a package is built using rez build --proxy --install Rez will install a special proxy package.py that redirects to the source package.py

  • This proxy package will be installed to the local packages path, so that it will be found by the normal Rez discovery mechanism

  • It will have the bare minimum of attributes (such as name and version), along with two new attributes

    • proxied_package: path to the package.py that produced it

    • proxied_root:  (optional) path which should override the root variable within commands.  This can be provided via  rez-build --proxy --proxied-root=..., otherwise it is taken from the source package’s default_proxied_root if present.  

  • When Rez resolves a proxy package.py, it will load the source (aka "proxied") package.py indicated by the proxied_package attribute. If present, it will inject the value of proxied_root as the root variable within the commands context. This allows packages which have a similar source and release folder layouts to "just work". 

  • There will also be a new context variable called is_proxied which will be set to True when a package is loaded via a proxy stub; this can be used to add conditional logic to the commands context.

  • For safety, proxy installs should not be supported by rez release

  • Various commands which list packages in a resolve should indicate when a local package is proxied

Example files

Here's an example package.py that uses this feature:

name = "foo"
version = "1.1.0"

# path is relative to the location of this package.py file
default_proxied_root='.'

def commands():
    # for this env var, the source and release folders layouts are the same, so replacing root "just works"
    env. OCIO.prepend("{root}/ocio")

    # for this env var, there's a difference between the source and release layout, so we have to add some logic
    if is_proxied:
        env.PYTHONPATH.prepend("{root}/python")
    else:
        env.PYTHONPATH.prepend("{root}/site-packages")

Here's the "proxy" package that would be installed into the local packages path:

name = "foo"
version = "1.1.0"

proxied_root='/path/to/foo/'
proxied_package='/path/to/foo/package.py'

Rejected ideas

Add machinery inside package.py files

We could use the very flexible package.py files to emulate this behavior. One idea was to modify our build command to install a .redirect.json file alongside the package.py, then when the commands runs we would check for the existence of this file, and change the behavior.

Cons:

  • Checking for the presence of the .redirect.json file adds overhead even when a package is not in editable mode. 

  • The package.py itself must be re-installed after editing for changes to take place (unless we also use a symlink to the package.py which adds further complexity and room for failure).

  • Since Rez itself is not aware of this concept, when Rez prints a resolve it will not indicate whether the package is a "proxy" pacakge or not.  This can be confusing and dangerous for developers

Use pip install --editable

Cons:

  • The package.py itself must be re-installed after editing for changes to take place (unless we also use a symlink to the package.py which adds further complexity and room for failure).

  • Since Rez itself is not aware of this concept, when Rez prints a resolve it will not indicate whether the package is a "proxy" pacakge or not.  This can be confusing and dangerous for developers

  • Only works for Python projects

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions