def tox_testenv_create(venv, action): tox.venv.cleanup_for_venv(venv) basepath = venv.path.dirpath() # Check for venv.envconfig.sitepackages and venv.config.alwayscopy here conda_exe = find_conda(action) venv.envconfig.conda_exe = conda_exe envdir = venv.envconfig.envdir python = get_py_version(venv.envconfig, action) # This is a workaround for locating the Python executable in Conda # environments on Windows. venv._venv_lookup = types.MethodType(venv_lookup, venv) args = [conda_exe, "create", "--yes", "-p", envdir] for channel in venv.envconfig.conda_channels: args += ["--channel", channel] args += [python] venv._pcall(args, venv=False, action=action, cwd=basepath) venv.envconfig.conda_python = python return True
def tox_testenv_create(venv, action): venv.session.make_emptydir(venv.path) basepath = venv.path.dirpath() # Check for venv.envconfig.sitepackages and venv.config.alwayscopy here conda_exe = find_conda() venv.envconfig.conda_exe = conda_exe envdir = venv.envconfig.envdir python = get_py_version(venv.envconfig) # This is a workaround for locating the Python executable in Conda # environments on Windows. venv._venv_lookup = types.MethodType(venv_lookup, venv) args = [conda_exe, 'create', '--yes', '-p', envdir] for channel in venv.envconfig.conda_channels: args += ['--channel', channel] args += [python] venv._pcall(args, venv=False, action=action, cwd=basepath) venv.envconfig.conda_python = python return True
def install_conda_env(venv, action, basepath, envdir): conda_exe = venv.envconfig.conda_exe # Account for the fact that we have a list of DepOptions action.setactivity("installcondadeps", f"{venv.envconfig.conda_env[0]}") args = [ conda_exe, "env", "update", "-p", envdir, "-f", f"../{venv.envconfig.conda_env[0]}" ] venv._pcall(args, venv=False, action=action, cwd=basepath)
def install_conda_deps(venv, action, basepath, envdir): conda_exe = venv.envconfig.conda_exe # Account for the fact that we have a list of DepOptions conda_deps = [str(dep.name) for dep in venv.envconfig.conda_deps] action.setactivity("installcondadeps", ", ".join(conda_deps)) args = [conda_exe, "install", "--yes", "-p", envdir] for channel in venv.envconfig.conda_channels: args += ["--channel", channel] # We include the python version in the conda requirements in order to make # sure that none of the other conda requirements inadvertently downgrade # python in this environment. If any of the requirements are in conflict # with the installed python version, installation will fail (which is what # we want). args += [venv.envconfig.conda_python] + conda_deps venv._pcall(args, venv=False, action=action, cwd=basepath)
def tox_testenv_create(venv, action): # pylint: disable=protected-access,missing-docstring config_interpreter = venv.getsupportedinterpreter() args = [sys.executable, "-m", "virtualenv"] if venv.envconfig.sitepackages: args.append("--system-site-packages") if venv.envconfig.alwayscopy: args.append("--always-copy") if not venv.envconfig.download: args.append("--no-download") else: args.append("--download") # add interpreter explicitly, to prevent using default (virtualenv.ini) args.extend(["--python", str(config_interpreter)]) # Disables it for whole function but place here to consolidate changes args = list(_augmented_virtualenv_args(args, venv.envconfig.deps)) tox.venv.cleanup_for_venv(venv) base_path = venv.path.dirpath() base_path.ensure(dir=1) args.append(venv.path.basename) if not tox.venv._SKIP_VENV_CREATION: try: venv._pcall( args, venv=False, action=action, cwd=base_path, redirect=tox.reporter.verbosity() < tox.reporter.Verbosity.DEBUG, ) except KeyboardInterrupt: venv.status = "keyboardinterrupt" raise return True # Return non-None to indicate plugin has completed