From 09c8b5b350afbd06aa625e9c5bc1dac92633d626 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Fri, 1 Mar 2024 16:43:03 -0500 Subject: [PATCH] Add -e/--editable flag to install script to create an editable install Signed-off-by: Jean-Christophe Morin --- install.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/install.py b/install.py index 43b7c81cc..70d630dcf 100644 --- a/install.py +++ b/install.py @@ -147,19 +147,19 @@ def copy_completion_scripts(dest_dir): return None -def install(dest_dir, print_welcome=False): +def install(dest_dir, print_welcome=False, editable=False): """Install rez into the given directory. Args: dest_dir (str): Full path to the install directory. """ - print("installing rez to %s..." % dest_dir) + print("installing rez%s to %s..." % (" (editable mode)" if editable else "", dest_dir)) # create the virtualenv create_virtual_environment(dest_dir) # install rez from source - install_rez_from_source(dest_dir) + install_rez_from_source(dest_dir, editable=editable) # patch the rez binaries patch_rez_binaries(dest_dir) @@ -222,11 +222,15 @@ def install(dest_dir, print_welcome=False): print('') -def install_rez_from_source(dest_dir): +def install_rez_from_source(dest_dir, editable): _, py_executable = get_virtualenv_py_executable(dest_dir) # install via pip - run_command([py_executable, "-m", "pip", "install", "."]) + args = [py_executable, "-m", "pip", "install"] + if editable: + args.append("-e") + args.append(".") + run_command(args) def install_as_rez_package(repo_path): @@ -280,6 +284,11 @@ def install_as_rez_package(repo_path): help="Install rez as a rez package. Note that this installs the API " "only (no cli tools), and DIR is expected to be the path to a rez " "package repository (and will default to ~/packages instead).") + parser.add_argument( + "-e", "--editable", action="store_true", + help="Make the install an editable install (pip install -e). This should " + "only be used for development purposes" + ) parser.add_argument( "DIR", nargs='?', help="Destination directory. If '{version}' is present, it will be " @@ -314,4 +323,4 @@ def install_as_rez_package(repo_path): if opts.as_rez_package: install_as_rez_package(dest_dir) else: - install(dest_dir, print_welcome=True) + install(dest_dir, print_welcome=True, editable=opts.editable)