def patch_rez_binaries(dest_dir): bin_names = os.listdir(bin_path) _, _, _, venv_bin_path = path_locations(dest_dir) venv_py_executable = which("python", env={ "PATH": venv_bin_path, "PATHEXT": os.environ.get("PATHEXT", "") }) # delete rez bin files written by setuptools for name in bin_names: filepath = os.path.join(venv_bin_path, name) if os.path.isfile(filepath): os.remove(filepath) # write patched bins instead. These go into 'bin/rez' subdirectory, which # gives us a bin dir containing only rez binaries. This is what we want - # we don't want resolved envs accidentally getting the venv's 'python'. dest_bin_path = os.path.join(venv_bin_path, "rez") if os.path.exists(dest_bin_path): shutil.rmtree(dest_bin_path) os.makedirs(dest_bin_path) maker = _ScriptMaker(bin_path, dest_bin_path) maker.executable = venv_py_executable options = dict(interpreter_args=["-E"]) for name in bin_names: entry = fake_entry(name) maker._make_script(entry, [], options=options)
def get_py_venv_executable(dest_dir): # get virtualenv's python executable _, _, _, venv_bin_dir = path_locations(dest_dir) env = {"PATH": venv_bin_dir, "PATHEXT": os.environ.get("PATHEXT", "")} return venv_bin_dir, which("python", env=env)
def patch_rez_binaries(dest_dir): bin_names = os.listdir(bin_path) _, _, _, venv_bin_path = path_locations(dest_dir) venv_py_executable = which("python", env={"PATH":venv_bin_path, "PATHEXT":os.environ.get("PATHEXT", "")}) # delete rez bin files written by setuptools for name in bin_names: filepath = os.path.join(venv_bin_path, name) if os.path.isfile(filepath): os.remove(filepath) # write patched bins instead. These go into 'bin/rez' subdirectory, which # gives us a bin dir containing only rez binaries. This is what we want - # we don't want resolved envs accidentally getting the venv's 'python'. dest_bin_path = os.path.join(venv_bin_path, "rez") if os.path.exists(dest_bin_path): shutil.rmtree(dest_bin_path) os.makedirs(dest_bin_path) maker = _ScriptMaker(bin_path, dest_bin_path) maker.executable = venv_py_executable options = dict(interpreter_args=["-E"]) for name in bin_names: entry = fake_entry(name) maker._make_script(entry, [], options=options)
def get_virtualenv_bin_dir(dest_dir): if use_venv: builder = venv.EnvBuilder() context = builder.ensure_directories(dest_dir) return context.bin_path else: _, _, _, bin_dir = path_locations(dest_dir) return bin_dir
def install(dest_dir, print_welcome=False): """Install rez into the given directory. Args: dest_dir (str): Full path to the install directory. """ print("installing rez to %s..." % dest_dir) # create the virtualenv create_environment(dest_dir) # install rez from source install_rez_from_source(dest_dir) # patch the rez binaries patch_rez_binaries(dest_dir) # copy completion scripts into venv completion_path = copy_completion_scripts(dest_dir) # mark venv as production rez install. Do not remove - rez uses this! _, _, _, venv_bin_dir = path_locations(dest_dir) dest_bin_dir = os.path.join(venv_bin_dir, "rez") validation_file = os.path.join(dest_bin_dir, ".rez_production_install") with open(validation_file, 'w') as f: f.write(_rez_version) # done if print_welcome: print() print("SUCCESS! To activate Rez, add the following path to $PATH:") print(dest_bin_dir) if completion_path: print('') shell = os.getenv('SHELL') if shell: shell = os.path.basename(shell) ext = "csh" if "csh" in shell else "sh" # Basic selection logic print( "You may also want to source the completion script (for %s):" % shell) print("source {0}/complete.{1}".format(completion_path, ext)) else: print( "You may also want to source the relevant completion script from:" ) print(completion_path) print('')
dest_dir = args[0].format(version=_rez_version) dest_dir = os.path.expanduser(dest_dir) dest_dir = os.path.realpath(dest_dir) print "installing rez to %s..." % dest_dir # make virtualenv verbose log_level = Logger.level_for_integer(2 - opts.verbose) logger = Logger([(log_level, sys.stdout)]) # create the virtualenv create_environment(dest_dir) # install rez from source _, _, _, venv_bin_dir = path_locations(dest_dir) py_executable = which("python", env={ "PATH": venv_bin_dir, "PATHEXT": os.environ.get("PATHEXT", "") }) args = [ py_executable, "setup.py", "install", "--quiet", "--single-version-externally-managed", "--record", os.path.join(dest_dir, 'install_log.txt') ] if opts.verbose: print "running in %s: %s" % (source_path, " ".join(args)) p = subprocess.Popen(args, cwd=source_path) p.wait()
def install(dest_dir, print_welcome=False): """Install rez into the given directory. Args: dest_dir (str): Full path to the install directory. """ print("installing rez to %s..." % dest_dir) # create the virtualenv create_environment(dest_dir) # install rez from source install_rez_from_source(dest_dir) # patch the rez binaries patch_rez_binaries(dest_dir) # copy completion scripts into venv completion_path = copy_completion_scripts(dest_dir) # mark venv as production rez install. Do not remove - rez uses this! _, _, _, venv_bin_dir = path_locations(dest_dir) dest_bin_dir = os.path.join(venv_bin_dir, "rez") validation_file = os.path.join(dest_bin_dir, ".rez_production_install") with open(validation_file, 'w') as f: f.write(_rez_version) # done if print_welcome: print() print("SUCCESS!") rez_exe = os.path.realpath(os.path.join(dest_bin_dir, "rez")) print("Rez executable installed to: %s" % rez_exe) try: out = subprocess.check_output([ rez_exe, "python", "-c", "import rez; print(rez.__path__[0])" ]) pkg_path = os.path.realpath(out.strip()) print("Rez python package installed to: %s" % pkg_path) except: pass # just in case there's an issue with rez-python tool print() print("To activate Rez, add the following path to $PATH:") print(dest_bin_dir) if completion_path: print('') shell = os.getenv('SHELL') if shell: shell = os.path.basename(shell) ext = "csh" if "csh" in shell else "sh" # Basic selection logic print("You may also want to source the completion script (for %s):" % shell) print("source {0}/complete.{1}".format(completion_path, ext)) else: print("You may also want to source the relevant completion script from:") print(completion_path) print('')
dest_dir = args[0].format(version=_rez_version) dest_dir = os.path.expanduser(dest_dir) dest_dir = os.path.realpath(dest_dir) print "installing rez to %s..." % dest_dir # make virtualenv verbose log_level = Logger.level_for_integer(2 - opts.verbose) logger = Logger([(log_level, sys.stdout)]) # create the virtualenv create_environment(dest_dir) # install rez from source _, _, _, venv_bin_dir = path_locations(dest_dir) py_executable = which("python", env={"PATH":venv_bin_dir, "PATHEXT":os.environ.get("PATHEXT", "")}) args = [ py_executable, "setup.py", "install", "--quiet", "--single-version-externally-managed", "--record", os.path.join(dest_dir, 'install_log.txt')] if opts.verbose: print "running in %s: %s" % (source_path, " ".join(args)) p = subprocess.Popen(args, cwd=source_path) p.wait() # patch the rez binaries patch_rez_binaries(dest_dir) # copy completion scripts into venv