|
4 | 4 | from subprocess import CalledProcessError |
5 | 5 | import os |
6 | 6 | from pathlib import Path |
| 7 | +import shutil |
7 | 8 |
|
8 | 9 | from sphinx_polyversion.api import apply_overrides |
9 | 10 | from sphinx_polyversion.builder import BuildError |
|
31 | 32 | root = Git.root(Path(__file__).parent) |
32 | 33 |
|
33 | 34 | #: CodeRegex matching the branches to build docs for |
34 | | -BRANCH_REGEX = r"^(master)$" |
| 35 | +BRANCH_REGEX = r"^(master|dev)$" |
35 | 36 |
|
36 | 37 | #: Regex matching the tags to build docs for |
37 | 38 | TAG_REGEX = r"^v[\.0-9]*$" |
|
69 | 70 | "tensorflow", |
70 | 71 | ] |
71 | 72 |
|
| 73 | +VENV_DIR_NAME = ".bf_doc_gen_venv" |
| 74 | + |
72 | 75 |
|
73 | 76 | #: Data passed to templates |
74 | 77 | def data(driver, rev, env): |
@@ -248,13 +251,22 @@ async def selector(rev, keys): |
248 | 251 | return None |
249 | 252 |
|
250 | 253 |
|
| 254 | +class DestructingDynamicPip(DynamicPip): |
| 255 | + async def __aexit__(self, exc_type, exc, tb): |
| 256 | + if self.venv.parent.name == VENV_DIR_NAME: |
| 257 | + logger.info("Removing environment " + str(self.venv)) |
| 258 | + shutil.rmtree(self.venv) |
| 259 | + |
| 260 | + |
| 261 | +pip_cls = DynamicPip if PARALLEL_BUILDS else DestructingDynamicPip |
| 262 | + |
251 | 263 | ENVIRONMENT = { |
252 | 264 | # configuration for v2 and dev |
253 | | - None: DynamicPip.factory(venv=Path(".venv"), args=["-e", "."] + SPHINX_DEPS + V2_BACKEND_DEPS, creator=creator), |
| 265 | + None: pip_cls.factory(venv=Path(VENV_DIR_NAME), args=["-e", "."] + SPHINX_DEPS + V2_BACKEND_DEPS, creator=creator), |
254 | 266 | # configuration for v1 and master (remove master here and in selector when it moves to v2) |
255 | | - "v1": DynamicPip.factory(venv=Path(".venv"), args=["-e", "."] + SPHINX_DEPS + V1_BACKEND_DEPS, creator=creator), |
256 | | - "master": DynamicPip.factory( |
257 | | - venv=Path(".venv"), |
| 267 | + "v1": pip_cls.factory(venv=Path(VENV_DIR_NAME), args=["-e", "."] + SPHINX_DEPS + V1_BACKEND_DEPS, creator=creator), |
| 268 | + "master": pip_cls.factory( |
| 269 | + venv=Path(VENV_DIR_NAME), |
258 | 270 | args=["-vv", "-e", "."] + V1_BACKEND_DEPS + SPHINX_DEPS, |
259 | 271 | creator=creator, |
260 | 272 | env_vars={"SETUPTOOLS_SCM_PRETEND_VERSION_FOR_BAYESFLOW": "1.1.6dev"}, |
|
0 commit comments