def exec_python(attr, src, executable="<STR_LIT>"):
import subprocess<EOL>if isinstance(src, basestring):<EOL><INDENT>src = [src]<EOL><DEDENT>p = popen([executable, "<STR_LIT:-c>", "<STR_LIT>".join(src)],<EOL>stdout=subprocess.PIPE, stderr=subprocess.PIPE)<EOL>out, err = p.communicate()<EOL>if p.returncode:<EOL><INDENT>from rez.exceptions import InvalidPackageError<EOL>raise InvalidPackageError(<EOL>"<STR_LIT>" % (attr, err))<EOL><DEDENT>return out.strip()<EOL>
Runs a python subproc to calculate a package attribute.

    Args:
        attr (str): Name of package attribute being created.
        src (list of str): Python code to execute, will be converted into
            semicolon-delimited single line of code.

    Returns:
        str: Output of python process.