|
17 | 17 | def tox_add_option(parser: ToxParser) -> None:
|
18 | 18 | help_msg = "sets up a development environment at ENVDIR based on the tox configuration specified "
|
19 | 19 | our = parser.add_command("devenv", ["d"], help_msg, devenv)
|
20 |
| - our.add_argument("devenv_path", metavar="path", default=Path("venv").absolute(), nargs="?") |
| 20 | + our.add_argument("devenv_path", metavar="path", default=Path("venv"), nargs="?", type=Path) |
21 | 21 | register_env_select_flags(our, default=CliEnv("py"), multiple=False)
|
22 | 22 | env_run_create_flags(our, mode="devenv")
|
23 | 23 |
|
24 | 24 |
|
25 | 25 | def devenv(state: State) -> int:
|
26 | 26 | opt = state.conf.options
|
| 27 | + opt.devenv_path = opt.devenv_path.absolute() |
27 | 28 | opt.skip_missing_interpreters = False # the target python must exist
|
28 | 29 | opt.no_test = False # do not run the test suite
|
29 | 30 | opt.package_only = False
|
30 | 31 | opt.install_pkg = None # no explicit packages to install
|
31 | 32 | opt.skip_pkg_install = False # always install a package in this case
|
32 | 33 | opt.no_test = True # do not run the test phase
|
| 34 | + loader = MemoryLoader( # these configuration values are loaded from in-memory always (no file conf) |
| 35 | + usedevelop=True, # dev environments must be of type dev |
| 36 | + env_dir=opt.devenv_path, # move it in source |
| 37 | + ) |
| 38 | + state.conf.memory_seed_loaders[list(opt.env)[0]].append(loader) |
33 | 39 |
|
34 | 40 | state.envs.ensure_only_run_env_is_active()
|
35 | 41 | envs = list(state.envs.iter())
|
36 | 42 | if len(envs) != 1:
|
37 | 43 | raise HandledError(f"exactly one target environment allowed in devenv mode but found {', '.join(envs)}")
|
38 |
| - loader = MemoryLoader( # these configuration values are loaded from in-memory always (no file conf) |
39 |
| - usedevelop=True, # dev environments must be of type dev |
40 |
| - env_dir=Path(opt.devenv_path), # move it in source |
41 |
| - ) |
42 |
| - tox_env = state.envs[envs[0]] |
43 |
| - tox_env.conf.loaders.insert(0, loader) |
44 | 44 | result = run_sequential(state)
|
45 | 45 | if result == 0:
|
46 |
| - logging.warning(f"created development environment under {tox_env.conf['env_dir']}") |
| 46 | + logging.warning(f"created development environment under {opt.devenv_path}") |
47 | 47 | return result
|
0 commit comments