py2docfx 0.1.10.dev1870753__py3-none-any.whl → 0.1.10.dev1871193__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(
@@ -263,7 +264,7 @@ async def donwload_package_generate_documents(
263
264
  print(f"<wait_prepare_venv>{end_time-start_time}<wait_prepare_venv/>")
264
265
 
265
266
  start_time = time.time()
266
- get_source(package, package_number, vststoken=ado_token, githubtoken=github_token)
267
+ get_source(py2docfxEnvironment.get_venv_exe(idx), package, package_number, vststoken=ado_token, githubtoken=github_token)
267
268
  end_time = time.time()
268
269
  print(f"<get_source>{package.name},{end_time-start_time}<get_source/>")
269
270
 
@@ -308,13 +309,22 @@ async def donwload_package_generate_documents(
308
309
  ado_token)
309
310
  )
310
311
  )
311
- py2docfxEnvironment.remove_environment(idx)
312
+ if idx >= 1:
313
+ env_remove_tasks.append(asyncio.create_task(
314
+ asyncio.to_thread(py2docfxEnvironment.remove_environment,idx-1)))
315
+ if idx > py2docfxEnvironment.VENV_BUFFER and env_remove_tasks[idx-py2docfxEnvironment.VENV_BUFFER] != None:
316
+ print(f"Removing venv {idx-py2docfxEnvironment.VENV_BUFFER}")
317
+ await env_remove_tasks[idx-py2docfxEnvironment.VENV_BUFFER]
312
318
 
313
319
  if output_doc_folder:
314
320
  start_time = time.time()
315
321
  move_root_toc_to_target(YAML_OUTPUT_ROOT, output_doc_folder)
316
322
  end_time = time.time()
317
323
  print(f"<move_root_toc_to_target>{end_time-start_time}<move_root_toc_to_target/>")
324
+
325
+ for idx in range(len(env_remove_tasks)):
326
+ if env_remove_tasks[idx] != None and not env_remove_tasks[idx].done():
327
+ await env_remove_tasks[idx]
318
328
 
319
329
  def prepare_out_dir(output_root: str | os.PathLike) -> os.PathLike | None:
320
330
  # prepare output_root\DOC_FOLDER_NAME (if folder contains files, raise exception)
@@ -344,6 +354,8 @@ def main(argv) -> int:
344
354
  shutil.rmtree("source_repo")
345
355
  if os.path.exists("target_repo"):
346
356
  shutil.rmtree("target_repo")
357
+
358
+ # TODO: may need to purge pip cache
347
359
  (package_info_list, required_package_list, github_token, ado_token, output_root, \
348
360
  venv_required) = parse_command_line_args(argv)
349
361
  venv_required = False
@@ -10,6 +10,7 @@ from py2docfx.convert_prepare import pip_utils
10
10
  REQUIREMENT_MODULES = ["setuptools", "sphinx==6.1.3", "pyyaml", "jinja2==3.0.3", "wheel"]
11
11
  VENV_DIR = "venv"
12
12
  VENV_BUFFER = 10
13
+ VENV_DELETE_BUFFER = 10
13
14
  PIP_INSTALL_COMMAND = ["-m", "pip", "install", "--upgrade"]
14
15
 
15
16
  PIP_INSTALL_VENV_COMMON_OPTIONS = [
@@ -73,7 +74,10 @@ async def prepare_venv(venv_num: int, required_package_list: list[PackageInfo],
73
74
  print(f"<CI INFO>: venv{venv_num} setup complete.")
74
75
 
75
76
  def remove_environment(venv_num: int):
76
- if os.path.exists(get_venv_path(venv_num)):
77
+ venv_path = get_venv_path(venv_num)
78
+ if os.path.exists(venv_path):
77
79
  print(f"<CI INFO>: Removing venv{venv_num}...")
78
- shutil.rmtree(get_venv_path(venv_num))
79
- print(f"<CI INFO>: venv{venv_num} removed.")
80
+ shutil.rmtree(venv_path)
81
+
82
+ # Example usage
83
+ # asyncio.run(remove_environment(1))
@@ -11,7 +11,7 @@ from py2docfx.convert_prepare.source import Source
11
11
 
12
12
  YAML_OUTPUT_ROOT = path.join("target_repo", "docs-ref-autogen")
13
13
 
14
- def update_package_info(pkg: PackageInfo, source_folder: str):
14
+ def update_package_info(executable: str, pkg: PackageInfo, source_folder: str):
15
15
  cur_path = os.getcwd()
16
16
  os.chdir(source_folder) # TODO: replace it
17
17
 
@@ -23,7 +23,7 @@ def update_package_info(pkg: PackageInfo, source_folder: str):
23
23
  if "setup.py" in files:
24
24
  for attr in attrs:
25
25
  proc_ret = subprocess.run(
26
- ["python", "setup.py", "--quiet", "--dry-run", f"--{attr}"],
26
+ [executable, "setup.py", "--quiet", "--dry-run", f"--{attr}"],
27
27
  capture_output=True,
28
28
  text=True,
29
29
  check=True
@@ -70,7 +70,7 @@ def update_package_info(pkg: PackageInfo, source_folder: str):
70
70
  source_folder=source_folder, yaml_output_folder=yaml_output_folder, package_name=pkg.name
71
71
  )
72
72
 
73
- def get_source(pkg: PackageInfo, cnt: int, vststoken=None, githubtoken=None):
73
+ def get_source(executable: str, pkg: PackageInfo, cnt: int, vststoken=None, githubtoken=None):
74
74
  path_cnt = str(cnt)
75
75
  dist_dir = path.join("dist_temp", path_cnt)
76
76
 
@@ -138,6 +138,6 @@ def get_source(pkg: PackageInfo, cnt: int, vststoken=None, githubtoken=None):
138
138
  raise ValueError(f"Unknown install type: {pkg.install_type}")
139
139
 
140
140
  start_time = time.time()
141
- update_package_info(pkg, source_folder)
141
+ update_package_info(executable, pkg, source_folder)
142
142
  end_time = time.time()
143
143
  print(f"<update_package_info>{pkg.name},{end_time-start_time}<update_package_info/>")
@@ -5,6 +5,7 @@ import os
5
5
  import shutil
6
6
  import stat
7
7
  import pytest
8
+ import sys
8
9
  from py2docfx.convert_prepare import git
9
10
  from py2docfx.convert_prepare import get_source
10
11
  from py2docfx.convert_prepare.package_info import PackageInfo
@@ -44,19 +45,19 @@ def test_update_package_info(init_package_info):
44
45
  base_path = "convert_prepare/tests/data/get_source/"
45
46
 
46
47
  # case of setup.py
47
- get_source.update_package_info(package, os.path.join(base_path, "mock-1"))
48
+ get_source.update_package_info(sys.executable, package, os.path.join(base_path, "mock-1"))
48
49
  assert package.name == "dummy_package"
49
50
  assert package.version == "3.1.0"
50
51
 
51
52
  # case of metadata
52
53
  package = init_package_info
53
- get_source.update_package_info(package, os.path.join(base_path, "mock-2"))
54
+ get_source.update_package_info(sys.executable, package, os.path.join(base_path, "mock-2"))
54
55
  assert package.name == "mock_package"
55
56
  assert package.version == "2.2.0"
56
57
 
57
58
  # case of dist-info folder
58
59
  package = init_package_info
59
- get_source.update_package_info(package, os.path.join(base_path, "mock-3"))
60
+ get_source.update_package_info(sys.executable, package, os.path.join(base_path, "mock-3"))
60
61
  assert package.name == "mock_package"
61
62
  assert package.version == "1.2.0"
62
63
 
@@ -75,7 +76,7 @@ def test_get_source_git_clone(init_package_info):
75
76
  package.branch = "main"
76
77
  package.folder = None
77
78
  package.url = "https://github.com/Azure/azure-iot-hub-python"
78
- get_source.get_source(package, 0)
79
+ get_source.get_source(sys.executable, package, 0)
79
80
  assert git.status("source_repo/0") is True
80
81
 
81
82
  def test_get_source_dist_file_zip(init_package_info):
@@ -91,7 +92,7 @@ def test_get_source_dist_file_zip(init_package_info):
91
92
  package.extra_index_url = None
92
93
  package.prefer_source_distribution = True
93
94
  package.location = "https://files.pythonhosted.org/packages/3e/71/f6f71a276e2e69264a97ad39ef850dca0a04fce67b12570730cb38d0ccac/azure-common-1.1.28.zip"
94
- get_source.get_source(package, 1)
95
+ get_source.get_source(sys.executable, package, 1)
95
96
  assert os.path.exists("dist_temp/1/azure-common-1.1.28")
96
97
  assert package.path.source_folder == "dist_temp\\1\\azure-common-1.1.28"
97
98
  assert os.path.exists("dist_temp/1/azure-common-1.1.28.zip") is False
@@ -109,7 +110,7 @@ def test_get_source_dist_file_whl(init_package_info):
109
110
  package.extra_index_url = None
110
111
  package.prefer_source_distribution = True
111
112
  package.location = "https://files.pythonhosted.org/packages/62/55/7f118b9c1b23ec15ca05d15a578d8207aa1706bc6f7c87218efffbbf875d/azure_common-1.1.28-py2.py3-none-any.whl"
112
- get_source.get_source(package, 2)
113
+ get_source.get_source(sys.executable, package, 2)
113
114
  assert os.path.exists("dist_temp/2/azure_common-1.1.28")
114
115
  assert package.path.source_folder == "dist_temp\\2\\azure_common-1.1.28"
115
116
  assert os.path.exists("dist_temp/2/azure_common-1.1.28-py2.py3-none-any.whl") is False
@@ -127,7 +128,7 @@ def test_get_source_dist_file_tar(init_package_info):
127
128
  package.extra_index_url = None
128
129
  package.prefer_source_distribution = True
129
130
  package.location = "https://files.pythonhosted.org/packages/fa/19/43a9eb812b4d6071fdc2c55640318f7eb5a1be8dbd3b6f9d96a1996e1bb6/azure-core-1.29.4.tar.gz"
130
- get_source.get_source(package, 3)
131
+ get_source.get_source(sys.executable, package, 3)
131
132
  assert os.path.exists("dist_temp/3/azure-core-1.29.4")
132
133
  assert package.path.source_folder == "dist_temp\\3\\azure-core-1.29.4"
133
134
  assert os.path.exists("dist_temp/3/azure-core-1.29.4.tar.gz") is False
@@ -144,7 +145,7 @@ def test_get_source_pip_whl(init_package_info):
144
145
  package.build_in_subpackage = False
145
146
  package.extra_index_url = None
146
147
  package.prefer_source_distribution = False
147
- get_source.get_source(package, 4)
148
+ get_source.get_source(sys.executable, package, 4)
148
149
  assert os.path.exists("dist_temp/4/azure_common-1.1.28")
149
150
  assert package.path.source_folder == "dist_temp\\4\\azure_common-1.1.28"
150
151
  assert os.path.exists("dist_temp/4/azure_common-1.1.28-py2.py3-none-any.whl") is False
@@ -161,7 +162,7 @@ def test_get_source_pip_zip(init_package_info):
161
162
  package.build_in_subpackage = False
162
163
  package.extra_index_url = None
163
164
  package.prefer_source_distribution = True
164
- get_source.get_source(package, 5)
165
+ get_source.get_source(sys.executable, package, 5)
165
166
  assert os.path.exists("dist_temp/5/azure-common-1.1.28")
166
167
  assert package.path.source_folder == "dist_temp\\5\\azure-common-1.1.28"
167
168
  assert os.path.exists("dist_temp/5/azure-common-1.1.28.zip") is False
@@ -178,7 +179,7 @@ def test_get_source_zip_file_at_position_0(init_package_info):
178
179
  package.build_in_subpackage = False
179
180
  package.extra_index_url = None
180
181
  package.prefer_source_distribution = True
181
- get_source.get_source(package, 6)
182
+ get_source.get_source(sys.executable, package, 6)
182
183
  assert os.path.exists("dist_temp/6/azure_template-0.1.0b3942895")
183
184
  assert package.path.source_folder == "dist_temp\\6\\azure_template-0.1.0b3942895"
184
185
  assert os.path.exists("dist_temp/6/azure_template-0.1.0b3942895.tar.gz") is False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py2docfx
3
- Version: 0.1.10.dev1870753
3
+ Version: 0.1.10.dev1871193
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,10 +1,10 @@
1
1
  py2docfx/__init__.py,sha256=kPRhPGPC1JknDotkksG428c1iIgfFr_4_7Jm-llrowY,72
2
- py2docfx/__main__.py,sha256=l0CbFZzaDitZHv84xL99FQ9YBNIRxapQ4MF3nu_7mEI,15137
2
+ py2docfx/__main__.py,sha256=NeNJ-Vu1C16P9vTYhp1TcujtK52QQRPsjnnV0nBKnss,15794
3
3
  py2docfx/convert_prepare/__init__.py,sha256=XxtxrP0kmW3ZBHIAoxsPDEHzcgeC0WSnole8Lk6CjKs,11
4
- py2docfx/convert_prepare/environment.py,sha256=gJTGV632VAbOiYbWbLLv47wP8ffjnKLa2yFPH3wBWiQ,3583
4
+ py2docfx/convert_prepare/environment.py,sha256=ihivOlbJ_AipP2OrgrvYcaE3EBYg4yqqsS4LzFl54m0,3624
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
- py2docfx/convert_prepare/get_source.py,sha256=eEIbfLkGdBSOIJElMBTiXkKlkujb_hdFu5g6InNroTg,5851
7
+ py2docfx/convert_prepare/get_source.py,sha256=hvWR_yPlfliLI9wywtnimKpjhJkx-LUYD6adGHgYTFA,5899
8
8
  py2docfx/convert_prepare/git.py,sha256=xGJp2nDWLfVljrxyPnFKPoLIqmBh6by-QdITogIuxi0,5893
9
9
  py2docfx/convert_prepare/install_package.py,sha256=hATmgazcSX7k2n4jQXh9sQMyNUc1k1YqHv5K5UMALq4,262
10
10
  py2docfx/convert_prepare/pack.py,sha256=vZS67_GzEhUmZWHU1dxm8gnWyRBs-kB6-KjX1d_FdOU,1260
@@ -24,7 +24,7 @@ py2docfx/convert_prepare/subpackage_merge/merge_root_package.py,sha256=uK96qL2as
24
24
  py2docfx/convert_prepare/subpackage_merge/merge_toc.py,sha256=nkVqe8R0m8D6cyTYV7aIpMDXorvn4-LXfU_vIK_hJBg,1706
25
25
  py2docfx/convert_prepare/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  py2docfx/convert_prepare/tests/test_generate_document.py,sha256=FpxwyRQFBfEdYUH16tpcJrqTAC0J5mq-Edn-N7Lz0rY,2413
27
- py2docfx/convert_prepare/tests/test_get_source.py,sha256=70EVlIZe71aDYDOXMnhqzZclKL8KuIg4t-X0U-pVyhA,7429
27
+ py2docfx/convert_prepare/tests/test_get_source.py,sha256=pry20HGWLfQGDtpNoj2uc_y1AwgNGWEvBWPpJUEVSVY,7601
28
28
  py2docfx/convert_prepare/tests/test_pack.py,sha256=46JWMNzknIptDVs7D3CuxcmqBr_OKMmaw1br9H7wqco,4134
29
29
  py2docfx/convert_prepare/tests/test_package_info.py,sha256=3B-IzmUjETVO-5s3g3Lmh2E6JgopwnRauv8mB-SDZEM,3361
30
30
  py2docfx/convert_prepare/tests/test_params.py,sha256=C-aY9xDjsNTcGQATco_J_i4nF4JSmaeFPEMI3-NtiGE,2229
@@ -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.dev1870753.dist-info/METADATA,sha256=vWePDertTTMqAuxEcNX9IOfZ3sLfT68TEprsg62yYk0,601
1886
- py2docfx-0.1.10.dev1870753.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
1887
- py2docfx-0.1.10.dev1870753.dist-info/top_level.txt,sha256=5dH2uP81dczt_qQJ38wiZ-gzoVWasfiJALWRSjdbnYU,9
1888
- py2docfx-0.1.10.dev1870753.dist-info/RECORD,,
1885
+ py2docfx-0.1.10.dev1871193.dist-info/METADATA,sha256=z9gHaJOpywGaoBDTaHhjL33nrLivlXQilUFNMiy30KU,601
1886
+ py2docfx-0.1.10.dev1871193.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
1887
+ py2docfx-0.1.10.dev1871193.dist-info/top_level.txt,sha256=5dH2uP81dczt_qQJ38wiZ-gzoVWasfiJALWRSjdbnYU,9
1888
+ py2docfx-0.1.10.dev1871193.dist-info/RECORD,,