def compile_multiple_pyc(python_exe_full_path, py_full_paths, pyc_full_paths, prefix, py_ver): py_full_paths = tuple(py_full_paths) pyc_full_paths = tuple(pyc_full_paths) if len(py_full_paths) == 0: return [] for pyc_full_path in pyc_full_paths: if lexists(pyc_full_path): maybe_raise(BasicClobberError(None, pyc_full_path, context), context) fd, filename = tempfile.mkstemp() try: for f in py_full_paths: f = os.path.relpath(f, prefix) if hasattr(f, 'encode'): f = f.encode(sys.getfilesystemencoding(), errors='replace') os.write(fd, f + b"\n") os.close(fd) command = ["-Wi", "-m", "compileall", "-q", "-l", "-i", filename] # if the python version in the prefix is 3.5+, we have some extra args. # -j 0 will do the compilation in parallel, with os.cpu_count() cores if int(py_ver[0]) >= 3 and int(py_ver.split('.')[1]) > 5: command.extend(["-j", "0"]) command[0:0] = [python_exe_full_path] # command[0:0] = ['--cwd', prefix, '--dev', '-p', prefix, python_exe_full_path] log.trace(command) from conda.gateways.subprocess import any_subprocess # from conda.common.io import env_vars # This stack does not maintain its _argparse_args correctly? # from conda.base.context import stack_context_default # with env_vars({}, stack_context_default): # stdout, stderr, rc = run_command(Commands.RUN, *command) stdout, stderr, rc = any_subprocess(command, prefix) finally: os.remove(filename) created_pyc_paths = [] for py_full_path, pyc_full_path in zip(py_full_paths, pyc_full_paths): if not isfile(pyc_full_path): message = dals(""" pyc file failed to compile successfully (run_command failed) python_exe_full_path: %s py_full_path: %s pyc_full_path: %s compile rc: %s compile stdout: %s compile stderr: %s """) log.info(message, python_exe_full_path, py_full_path, pyc_full_path, rc, stdout, stderr) else: created_pyc_paths.append(pyc_full_path) return created_pyc_paths
def compile_multiple_pyc(python_exe_full_path, py_full_paths, pyc_full_paths, prefix, py_ver): py_full_paths = tuple(py_full_paths) pyc_full_paths = tuple(pyc_full_paths) if len(py_full_paths) == 0: return [] for pyc_full_path in pyc_full_paths: if lexists(pyc_full_path): maybe_raise(BasicClobberError(None, pyc_full_path, context), context) fd, filename = tempfile.mkstemp() try: for f in py_full_paths: f = os.path.relpath(f, prefix) if hasattr(f, 'encode'): f = f.encode(sys.getfilesystemencoding(), errors='replace') os.write(fd, f + b"\n") os.close(fd) command = ["-Wi", "-m", "compileall", "-q", "-l", "-i", filename] # if the python version in the prefix is 3.5+, we have some extra args. # -j 0 will do the compilation in parallel, with os.cpu_count() cores if int(py_ver[0]) >= 3 and int(py_ver.split('.')[1]) > 5: command.extend(["-j", "0"]) command[0:0] = [python_exe_full_path] # command[0:0] = ['--cwd', prefix, '--dev', '-p', prefix, python_exe_full_path] log.trace(command) from conda.gateways.subprocess import any_subprocess # from conda.common.io import env_vars # This stack does not maintain its _argparse_args correctly? # from conda.base.context import stack_context_default # with env_vars({}, stack_context_default): # stdout, stderr, rc = run_command(Commands.RUN, *command) stdout, stderr, rc = any_subprocess(command, prefix) finally: os.remove(filename) created_pyc_paths = [] for py_full_path, pyc_full_path in zip(py_full_paths, pyc_full_paths): if not isfile(pyc_full_path): message = dals(""" pyc file failed to compile successfully (run_command failed) python_exe_full_path: %s py_full_path: %s pyc_full_path: %s compile rc: %s compile stdout: %s compile stderr: %s """) log.info(message, python_exe_full_path, py_full_path, pyc_full_path, rc, stdout, stderr) else: created_pyc_paths.append(pyc_full_path) return created_pyc_paths
def pip_subprocess(args, prefix, cwd): if on_win: python_path = os.path.join(prefix, 'python.exe') else: python_path = os.path.join(prefix, 'bin', 'python') run_args = [python_path, '-m', 'pip'] + args stdout, stderr, rc = any_subprocess(run_args, prefix, cwd=cwd) print("Ran pip subprocess with arguments:") print(run_args) print("Pip subprocess output:") print(stdout) if rc != 0: print("Pip subprocess error:") print(stderr)
def pip_subprocess(args, prefix, cwd): if on_win: python_path = os.path.join(prefix, 'python.exe') else: python_path = os.path.join(prefix, 'bin', 'python') run_args = [python_path, '-m', 'pip'] + args stdout, stderr, rc = any_subprocess(run_args, prefix, cwd=cwd) print("Ran pip subprocess with arguments:") print(run_args) print("Pip subprocess output:") print(stdout) if rc != 0: print("Pip subprocess error:") print(stderr)
def pip_subprocess(args, prefix, cwd): if on_win: python_path = os.path.join(prefix, 'python.exe') else: python_path = os.path.join(prefix, 'bin', 'python') run_args = [python_path, '-m', 'pip'] + args stdout, stderr, rc = any_subprocess(run_args, prefix, cwd=cwd) if not context.quiet and not context.json: print("Ran pip subprocess with arguments:") print(run_args) print("Pip subprocess output:") print(stdout) if rc != 0: print("Pip subprocess error:", file=sys.stderr) print(stderr, file=sys.stderr) raise CondaEnvException("Pip failed") # This will modify (break) Context. We have a context stack but need to verify it works # stdout, stderr, rc = run_command(Commands.RUN, *run_args, stdout=None, stderr=None) return stdout, stderr