py2docfx 0.1.10.dev1870743__py3-none-any.whl → 0.1.10.dev1871013__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
py2docfx/__main__.py CHANGED
@@ -245,6 +245,7 @@ async def donwload_package_generate_documents(
245
245
 
246
246
  start_num = len(required_package_list)
247
247
  env_prepare_tasks = []
248
+ env_remove_tasks = []
248
249
 
249
250
  for idx in range(min([py2docfxEnvironment.VENV_BUFFER, len(package_info_list)])):
250
251
  env_prepare_tasks.append(asyncio.create_task(
@@ -308,12 +309,21 @@ async def donwload_package_generate_documents(
308
309
  ado_token)
309
310
  )
310
311
  )
312
+ if idx >= 1:
313
+ env_remove_tasks.append(asyncio.create_task(py2docfxEnvironment.remove_environment(idx-1)))
314
+ if idx > py2docfxEnvironment.VENV_BUFFER and env_remove_tasks[idx-py2docfxEnvironment.VENV_BUFFER] != None:
315
+ print(f"Removing venv {idx-py2docfxEnvironment.VENV_BUFFER}")
316
+ await env_remove_tasks[idx-py2docfxEnvironment.VENV_BUFFER]
311
317
 
312
318
  if output_doc_folder:
313
319
  start_time = time.time()
314
320
  move_root_toc_to_target(YAML_OUTPUT_ROOT, output_doc_folder)
315
321
  end_time = time.time()
316
322
  print(f"<move_root_toc_to_target>{end_time-start_time}<move_root_toc_to_target/>")
323
+
324
+ for idx in range(len(env_remove_tasks)):
325
+ if env_remove_tasks[idx] != None and not env_remove_tasks[idx].done():
326
+ await env_remove_tasks[idx]
317
327
 
318
328
  def prepare_out_dir(output_root: str | os.PathLike) -> os.PathLike | None:
319
329
  # prepare output_root\DOC_FOLDER_NAME (if folder contains files, raise exception)
@@ -343,6 +353,8 @@ def main(argv) -> int:
343
353
  shutil.rmtree("source_repo")
344
354
  if os.path.exists("target_repo"):
345
355
  shutil.rmtree("target_repo")
356
+
357
+ # TODO: may need to purge pip cache
346
358
  (package_info_list, required_package_list, github_token, ado_token, output_root, \
347
359
  venv_required) = parse_command_line_args(argv)
348
360
  venv_required = False
@@ -1,6 +1,7 @@
1
1
  import subprocess
2
2
  import asyncio
3
3
  import os
4
+ import shutil
4
5
  from py2docfx import PACKAGE_ROOT
5
6
  from py2docfx.convert_prepare.package_info import PackageInfo
6
7
  from py2docfx.convert_prepare.get_source import get_source
@@ -9,8 +10,15 @@ from py2docfx.convert_prepare import pip_utils
9
10
  REQUIREMENT_MODULES = ["setuptools", "sphinx==6.1.3", "pyyaml", "jinja2==3.0.3", "wheel"]
10
11
  VENV_DIR = "venv"
11
12
  VENV_BUFFER = 10
13
+ VENV_DELETE_BUFFER = 10
12
14
  PIP_INSTALL_COMMAND = ["-m", "pip", "install", "--upgrade"]
13
15
 
16
+ PIP_INSTALL_VENV_COMMON_OPTIONS = [
17
+ "--quiet",
18
+ "--no-warn-conflicts",
19
+ "--disable-pip-version-check",
20
+ ]
21
+
14
22
  def install_converter_requirements(executable: str):
15
23
  """
16
24
  Install setuptools/sphinx/pyyaml/jinja2
@@ -40,7 +48,7 @@ def get_venv_exe(venv_num: int) -> str:
40
48
  return os.path.join(get_venv_path(venv_num), "Scripts", "python.exe")
41
49
 
42
50
  async def install_converter_requirement_async(executable: str):
43
- pip_cmd = PIP_INSTALL_COMMAND + REQUIREMENT_MODULES
51
+ pip_cmd = PIP_INSTALL_COMMAND + PIP_INSTALL_VENV_COMMON_OPTIONS + REQUIREMENT_MODULES
44
52
  await(await asyncio.create_subprocess_exec(executable, *pip_cmd)).wait()
45
53
 
46
54
  async def install_required_packages(
@@ -50,7 +58,7 @@ async def install_required_packages(
50
58
  # if package.install_type == package.InstallType.SOURCE_CODE:
51
59
  # get_source(package, idx, vststoken=ado_token, githubtoken=github_token)
52
60
  package_name, options = package.get_install_command()
53
- pip_cmd = PIP_INSTALL_COMMAND + pip_utils.pip_install_common_options + options + [package_name]
61
+ pip_cmd = PIP_INSTALL_COMMAND + PIP_INSTALL_VENV_COMMON_OPTIONS + options + [package_name]
54
62
  await(await asyncio.create_subprocess_exec(executable, *pip_cmd)).wait()
55
63
 
56
64
  async def create_environment(venv_num: int):
@@ -63,4 +71,13 @@ async def prepare_venv(venv_num: int, required_package_list: list[PackageInfo],
63
71
  await install_converter_requirement_async(get_venv_exe(venv_num))
64
72
  print(f"<CI INFO>: Installing required packages in venv{venv_num}...")
65
73
  await install_required_packages(get_venv_exe(venv_num), required_package_list, github_token, ado_token)
66
- print(f"<CI INFO>: venv{venv_num} setup complete.")
74
+ print(f"<CI INFO>: venv{venv_num} setup complete.")
75
+
76
+ async def remove_environment(venv_num: int):
77
+ venv_path = get_venv_path(venv_num)
78
+ if os.path.exists(venv_path):
79
+ print(f"<CI INFO>: Removing venv{venv_num}...")
80
+ return asyncio.to_thread(shutil.rmtree, venv_path)
81
+
82
+ # Example usage
83
+ # asyncio.run(remove_environment(1))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py2docfx
3
- Version: 0.1.10.dev1870743
3
+ Version: 0.1.10.dev1871013
4
4
  Summary: A package built based on Sphinx which download source code package and generate yaml files supported by docfx.
5
5
  Author: Microsoft Corporation
6
6
  License: MIT License
@@ -1,7 +1,7 @@
1
1
  py2docfx/__init__.py,sha256=kPRhPGPC1JknDotkksG428c1iIgfFr_4_7Jm-llrowY,72
2
- py2docfx/__main__.py,sha256=wxlErNKLRQGZJAsEwe4JaJTRE48aWRTdJMsOrm5eda8,15084
2
+ py2docfx/__main__.py,sha256=Nq5DzPY8RZNuUqUUTW6rF_k_75LNrGG39lX4injCWrY,15719
3
3
  py2docfx/convert_prepare/__init__.py,sha256=XxtxrP0kmW3ZBHIAoxsPDEHzcgeC0WSnole8Lk6CjKs,11
4
- py2docfx/convert_prepare/environment.py,sha256=ohq072McKtmpRwgzPycocz_PYOyqVMiSC1--N8GEtkE,3167
4
+ py2docfx/convert_prepare/environment.py,sha256=_gGbLRnuOnL8vsU-b7jZITqIN9CUeSXNFB8_xKWtKjk,3656
5
5
  py2docfx/convert_prepare/generate_conf.py,sha256=wqs6iyElzJarH-20_qEL9zvZvt5xfBMsGXSXPSZy6wg,2295
6
6
  py2docfx/convert_prepare/generate_document.py,sha256=cLfFr7od0RHADkXyh2gaPreXZGvKNBUlduBosYTuPbk,3118
7
7
  py2docfx/convert_prepare/get_source.py,sha256=eEIbfLkGdBSOIJElMBTiXkKlkujb_hdFu5g6InNroTg,5851
@@ -1882,7 +1882,7 @@ py2docfx/venv/venv0/Scripts/rst2s5.py,sha256=lnv7lRNv1Oz3gjI5BOJlTqfCJQLJxgwJ9l3
1882
1882
  py2docfx/venv/venv0/Scripts/rst2xetex.py,sha256=5_9VjwA5RKUMJG9L__1ZiS8DIeLHRdPWeWW7B4otM8M,909
1883
1883
  py2docfx/venv/venv0/Scripts/rst2xml.py,sha256=hU2nzGVbXbQBnH_ydI5f2VDkGQyDMUdTgz3rfa45JMg,638
1884
1884
  py2docfx/venv/venv0/Scripts/rstpep2html.py,sha256=uLmCJKfEKPeeWS0n76HharN9YEYIuCRQQXfPPBJaRso,706
1885
- py2docfx-0.1.10.dev1870743.dist-info/METADATA,sha256=f1EhLfHJgC_UWDu-Msa0wdWIvAbqsQrRXL5PQ-9zLH8,601
1886
- py2docfx-0.1.10.dev1870743.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
1887
- py2docfx-0.1.10.dev1870743.dist-info/top_level.txt,sha256=5dH2uP81dczt_qQJ38wiZ-gzoVWasfiJALWRSjdbnYU,9
1888
- py2docfx-0.1.10.dev1870743.dist-info/RECORD,,
1885
+ py2docfx-0.1.10.dev1871013.dist-info/METADATA,sha256=tnMc1MCAhdOQTwQam94xJuJfhlBL1Elbd28qOYpzGFI,601
1886
+ py2docfx-0.1.10.dev1871013.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
1887
+ py2docfx-0.1.10.dev1871013.dist-info/top_level.txt,sha256=5dH2uP81dczt_qQJ38wiZ-gzoVWasfiJALWRSjdbnYU,9
1888
+ py2docfx-0.1.10.dev1871013.dist-info/RECORD,,