def tox_testenv_create(venv: VirtualEnv, action: action.Action) -> Any: clone_pdm_files(str(venv.path), str(venv.envconfig.config.toxinidir)) config_interpreter = venv.getsupportedinterpreter() def patch_getcommandpath(getcommandpath): @functools.wraps(getcommandpath) def patched(self, cmd, *args, **kwargs): if cmd == "python": return config_interpreter return getcommandpath(self, cmd, *args, **kwargs) return patched VirtualEnv.getcommandpath = patch_getcommandpath(VirtualEnv.getcommandpath) if not venv.path.join(".pdm.toml").exists(): venv._pcall( [ venv.envconfig.config.option.pdm, "use", "-f", config_interpreter ], cwd=venv.path, venv=False, action=action, ) return True
def acquire_package(config: config.Config, venv: VirtualEnv) -> py.path.local: target_dir: py.path.local = config.toxworkdir.join( config.isolated_build_env) ensure_empty_dir(target_dir) args = [ venv.envconfig.config.option.pdm, "build", "--no-wheel", "-d", target_dir, ] with venv.new_action("buildpkg") as action: venv._pcall(args, cwd=venv.envconfig.config.toxinidir, venv=False, action=action) path = next(target_dir.visit("*.tar.gz")) action.setactivity("buildpkg", path) return path
def tox_testenv_install_deps(venv: VirtualEnv, action: action.Action) -> Any: if not detect_pdm_files(venv.path): return groups = venv.envconfig.groups or [] if not venv.envconfig.skip_install or groups: action.setactivity("pdminstall", groups) args = [ venv.envconfig.config.option.pdm, "install", "-p", str(venv.path) ] if "default" in groups: groups.remove("default") elif venv.envconfig.skip_install: args.append("--no-default") for group in groups: args.extend(["--group", group]) args.append("--no-self") venv._pcall( args, cwd=venv.envconfig.config.toxinidir, venv=False, action=action, ) deps = venv.get_resolved_dependencies() if deps: depinfo = ", ".join(map(str, deps)) action.setactivity("installdeps", depinfo) venv._install(deps, action=action) lib_path = get_env_lib_path(venv.envconfig.config.option.pdm, venv.path) bin_dir = os.path.join(lib_path, "bin") scripts_dir = os.path.join(os.path.dirname(lib_path), ("Scripts" if os.name == "nt" else "bin")) if os.path.exists(bin_dir): for item in os.listdir(bin_dir): bin_item = os.path.join(bin_dir, item) shutil.move(bin_item, os.path.join(scripts_dir, item)) return True