py2docfx 0.1.11.dev1824276__py3-none-any.whl → 0.1.11.dev1830301__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.
Files changed (127) hide show
  1. py2docfx/convert_prepare/environment.py +1 -1
  2. py2docfx/convert_prepare/package_info.py +1 -1
  3. py2docfx/convert_prepare/pip_utils.py +1 -1
  4. py2docfx/convert_prepare/tests/test_package_info.py +7 -22
  5. py2docfx/convert_prepare/tests/test_params.py +5 -0
  6. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/_collections.py +0 -145
  7. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/bcppcompiler.py +1 -2
  8. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/ccompiler.py +7 -11
  9. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/bdist.py +4 -3
  10. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/build_ext.py +1 -4
  11. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/check.py +3 -4
  12. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/install_data.py +39 -29
  13. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/install_lib.py +1 -3
  14. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/sdist.py +4 -4
  15. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/compat/py38.py +1 -0
  16. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/cygwinccompiler.py +21 -42
  17. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/dist.py +3 -12
  18. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/extension.py +9 -4
  19. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/msvc9compiler.py +1 -3
  20. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/msvccompiler.py +1 -3
  21. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/spawn.py +0 -1
  22. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/sysconfig.py +44 -25
  23. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_archive_util.py +1 -1
  24. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_build.py +1 -2
  25. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_build_ext.py +1 -1
  26. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_cygwinccompiler.py +0 -42
  27. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_dist.py +1 -1
  28. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_extension.py +4 -1
  29. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_install_data.py +17 -9
  30. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_mingwccompiler.py +5 -4
  31. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_spawn.py +1 -1
  32. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_sysconfig.py +6 -3
  33. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_unixccompiler.py +35 -1
  34. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_util.py +4 -24
  35. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/unixccompiler.py +19 -20
  36. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/util.py +20 -26
  37. py2docfx/venv/0/Lib/site-packages/wheel/__init__.py +3 -0
  38. py2docfx/venv/0/Lib/site-packages/wheel/__main__.py +23 -0
  39. py2docfx/venv/0/Lib/site-packages/wheel/_bdist_wheel.py +604 -0
  40. py2docfx/venv/0/Lib/site-packages/wheel/_setuptools_logging.py +26 -0
  41. py2docfx/venv/0/Lib/site-packages/wheel/bdist_wheel.py +11 -0
  42. py2docfx/venv/0/Lib/site-packages/wheel/cli/__init__.py +155 -0
  43. py2docfx/venv/0/Lib/site-packages/wheel/cli/convert.py +273 -0
  44. py2docfx/venv/0/Lib/site-packages/wheel/cli/pack.py +85 -0
  45. py2docfx/venv/0/Lib/site-packages/wheel/cli/tags.py +139 -0
  46. py2docfx/venv/0/Lib/site-packages/wheel/cli/unpack.py +30 -0
  47. py2docfx/venv/0/Lib/site-packages/wheel/macosx_libfile.py +482 -0
  48. py2docfx/venv/0/Lib/site-packages/wheel/metadata.py +183 -0
  49. py2docfx/venv/0/Lib/site-packages/wheel/util.py +26 -0
  50. py2docfx/venv/0/Lib/site-packages/wheel/vendored/__init__.py +0 -0
  51. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/__init__.py +0 -0
  52. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_elffile.py +108 -0
  53. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_manylinux.py +260 -0
  54. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_musllinux.py +83 -0
  55. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_parser.py +356 -0
  56. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_structures.py +61 -0
  57. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_tokenizer.py +192 -0
  58. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/markers.py +253 -0
  59. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/requirements.py +90 -0
  60. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/specifiers.py +1011 -0
  61. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/tags.py +571 -0
  62. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/utils.py +172 -0
  63. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/version.py +561 -0
  64. py2docfx/venv/0/Lib/site-packages/wheel/wheelfile.py +227 -0
  65. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/_collections.py +0 -145
  66. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/bcppcompiler.py +1 -2
  67. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/ccompiler.py +7 -11
  68. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/bdist.py +4 -3
  69. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/build_ext.py +1 -4
  70. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/check.py +3 -4
  71. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/install_data.py +39 -29
  72. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/install_lib.py +1 -3
  73. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/sdist.py +4 -4
  74. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/compat/py38.py +1 -0
  75. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/cygwinccompiler.py +21 -42
  76. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/dist.py +3 -12
  77. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/extension.py +9 -4
  78. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/msvc9compiler.py +1 -3
  79. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/msvccompiler.py +1 -3
  80. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/spawn.py +0 -1
  81. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/sysconfig.py +44 -25
  82. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_archive_util.py +1 -1
  83. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_build.py +1 -2
  84. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_build_ext.py +1 -1
  85. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_cygwinccompiler.py +0 -42
  86. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_dist.py +1 -1
  87. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_extension.py +4 -1
  88. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_install_data.py +17 -9
  89. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_mingwccompiler.py +5 -4
  90. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_spawn.py +1 -1
  91. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_sysconfig.py +6 -3
  92. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_unixccompiler.py +35 -1
  93. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_util.py +4 -24
  94. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/unixccompiler.py +19 -20
  95. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/util.py +20 -26
  96. py2docfx/venv/template/Lib/site-packages/wheel/__init__.py +3 -0
  97. py2docfx/venv/template/Lib/site-packages/wheel/__main__.py +23 -0
  98. py2docfx/venv/template/Lib/site-packages/wheel/_bdist_wheel.py +604 -0
  99. py2docfx/venv/template/Lib/site-packages/wheel/_setuptools_logging.py +26 -0
  100. py2docfx/venv/template/Lib/site-packages/wheel/bdist_wheel.py +11 -0
  101. py2docfx/venv/template/Lib/site-packages/wheel/cli/__init__.py +155 -0
  102. py2docfx/venv/template/Lib/site-packages/wheel/cli/convert.py +273 -0
  103. py2docfx/venv/template/Lib/site-packages/wheel/cli/pack.py +85 -0
  104. py2docfx/venv/template/Lib/site-packages/wheel/cli/tags.py +139 -0
  105. py2docfx/venv/template/Lib/site-packages/wheel/cli/unpack.py +30 -0
  106. py2docfx/venv/template/Lib/site-packages/wheel/macosx_libfile.py +482 -0
  107. py2docfx/venv/template/Lib/site-packages/wheel/metadata.py +183 -0
  108. py2docfx/venv/template/Lib/site-packages/wheel/util.py +26 -0
  109. py2docfx/venv/template/Lib/site-packages/wheel/vendored/__init__.py +0 -0
  110. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/__init__.py +0 -0
  111. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_elffile.py +108 -0
  112. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_manylinux.py +260 -0
  113. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_musllinux.py +83 -0
  114. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_parser.py +356 -0
  115. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_structures.py +61 -0
  116. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_tokenizer.py +192 -0
  117. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/markers.py +253 -0
  118. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/requirements.py +90 -0
  119. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/specifiers.py +1011 -0
  120. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/tags.py +571 -0
  121. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/utils.py +172 -0
  122. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/version.py +561 -0
  123. py2docfx/venv/template/Lib/site-packages/wheel/wheelfile.py +227 -0
  124. {py2docfx-0.1.11.dev1824276.dist-info → py2docfx-0.1.11.dev1830301.dist-info}/METADATA +1 -1
  125. {py2docfx-0.1.11.dev1824276.dist-info → py2docfx-0.1.11.dev1830301.dist-info}/RECORD +127 -71
  126. {py2docfx-0.1.11.dev1824276.dist-info → py2docfx-0.1.11.dev1830301.dist-info}/WHEEL +0 -0
  127. {py2docfx-0.1.11.dev1824276.dist-info → py2docfx-0.1.11.dev1830301.dist-info}/top_level.txt +0 -0
@@ -7,7 +7,7 @@ from py2docfx import PACKAGE_ROOT
7
7
  from py2docfx.convert_prepare.get_source import get_source
8
8
  from py2docfx.convert_prepare.install_package import install_package
9
9
 
10
- REQUIREMENT_MODULES = ["setuptools", "sphinx==6.1.3", "pyyaml", "jinja2==3.0.3"]
10
+ REQUIREMENT_MODULES = ["setuptools", "sphinx==6.1.3", "pyyaml", "jinja2==3.0.3", "wheel"]
11
11
 
12
12
  def install_converter_requirements(executable: str):
13
13
  """
@@ -32,7 +32,7 @@ class PackageInfo:
32
32
  package_info = PackageInfo()
33
33
  package_info.exclude_path = dict.get("exclude_path", [])
34
34
  package_info.extension_config = dict.get("extension_config", {})
35
-
35
+ package_info.sphinx_extensions = dict.get("sphinx_extensions", [])
36
36
  if reading_required_packages:
37
37
  package_info_dict = dict
38
38
  else:
@@ -14,7 +14,7 @@ pip_install_common_options = [
14
14
 
15
15
  def download(package_name, path, executable, extra_index_url=None, prefer_source_distribution=True):
16
16
  # Downloads a package from PyPI to the specified path using pip.
17
- download_param = [executable, "-m", "pip", "download", "--dest", path, "--no-deps", package_name]
17
+ download_param = ["pip", "download", "--dest", path, "--no-deps", package_name]
18
18
  if extra_index_url:
19
19
  download_param.append("--extra-index-url")
20
20
  download_param.append(extra_index_url)
@@ -17,6 +17,8 @@ package_info_1 = PackageInfo.parse_from(test_dict["packages"][1], False)
17
17
 
18
18
  package_info_2 = PackageInfo.parse_from(test_dict["packages"][2], False)
19
19
 
20
+ package_info_3 = PackageInfo.parse_from(test_dict["packages"][3], False)
21
+
20
22
  def test_parse_from():
21
23
  assert package_info_0.exclude_path == ["test*", "example*", "sample*", "doc*"]
22
24
  assert package_info_0.name == "azure-mltable-py2docfxtest"
@@ -26,6 +28,11 @@ def test_get_combined_name_version():
26
28
  name_version = package_info_1.get_combined_name_version()
27
29
  assert name_version == "azureml-accel-models==1.0.0"
28
30
 
31
+ def test_get_sphinx_extensions():
32
+ assert package_info_3.sphinx_extensions == ["sphinx-pydantic"]
33
+ assert package_info_3.name == "semantic-kernel"
34
+ assert package_info_3.install_type.name == "PYPI"
35
+
29
36
  def test_intall_command():
30
37
  install_command = package_info_0.get_install_command()
31
38
  assert install_command[0] == "azure-mltable-py2docfxtest"
@@ -35,28 +42,6 @@ def test_intall_command():
35
42
  assert install_command[0] == "azureml-accel-models==1.0.0"
36
43
  assert install_command[1] == []
37
44
 
38
- def test_get_exclude_command(tmp_path):
39
- source_folder = os.path.join(tmp_path,"source_folder")
40
- yaml_output_folder = os.path.join(tmp_path,"yaml_output_folder")
41
- package_info_0.path = Source(
42
- source_folder = source_folder, yaml_output_folder = yaml_output_folder, package_name = "azure-mltable-py2docfxtest"
43
- )
44
- exclude_path = package_info_0.get_exluded_command()
45
- expected_exclude_path = [
46
- "build/*",
47
- "setup.py",
48
- "test*",
49
- "example*",
50
- "sample*",
51
- "doc*",
52
- "azure/__init__.py",
53
- "azure/mltable/__init__.py"
54
- ]
55
- def form_exclude_path(raletive_path):
56
- return os.path.join(source_folder, raletive_path)
57
- assert exclude_path == [form_exclude_path(path) for path in expected_exclude_path]
58
-
59
-
60
45
  def test_get_exclude_command(tmp_path):
61
46
  source_folder = os.path.join(tmp_path,"source_folder")
62
47
  yaml_output_folder = os.path.join(tmp_path,"yaml_output_folder")
@@ -21,6 +21,11 @@ def package_info_assert(package_info_list, required_package_info_list):
21
21
  assert package.install_type.name == "PYPI"
22
22
  assert package.exclude_path == []
23
23
 
24
+ package = package_info_list[3]
25
+ assert package.name == "semantic-kernel"
26
+ assert package.install_type.name == "PYPI"
27
+ assert package.sphinx_extensions == ["sphinx-pydantic"]
28
+
24
29
  required_package = required_package_info_list[0]
25
30
  assert required_package.name == None
26
31
  assert required_package.install_type.name == "DIST_FILE"
@@ -1,11 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import collections
4
- import functools
5
4
  import itertools
6
- import operator
7
- from collections.abc import Mapping
8
- from typing import Any
9
5
 
10
6
 
11
7
  # from jaraco.collections 3.5.1
@@ -60,144 +56,3 @@ class DictStack(list, collections.abc.Mapping):
60
56
 
61
57
  def __len__(self):
62
58
  return len(list(iter(self)))
63
-
64
-
65
- # from jaraco.collections 5.0.1
66
- class RangeMap(dict):
67
- """
68
- A dictionary-like object that uses the keys as bounds for a range.
69
- Inclusion of the value for that range is determined by the
70
- key_match_comparator, which defaults to less-than-or-equal.
71
- A value is returned for a key if it is the first key that matches in
72
- the sorted list of keys.
73
-
74
- One may supply keyword parameters to be passed to the sort function used
75
- to sort keys (i.e. key, reverse) as sort_params.
76
-
77
- Create a map that maps 1-3 -> 'a', 4-6 -> 'b'
78
-
79
- >>> r = RangeMap({3: 'a', 6: 'b'}) # boy, that was easy
80
- >>> r[1], r[2], r[3], r[4], r[5], r[6]
81
- ('a', 'a', 'a', 'b', 'b', 'b')
82
-
83
- Even float values should work so long as the comparison operator
84
- supports it.
85
-
86
- >>> r[4.5]
87
- 'b'
88
-
89
- Notice that the way rangemap is defined, it must be open-ended
90
- on one side.
91
-
92
- >>> r[0]
93
- 'a'
94
- >>> r[-1]
95
- 'a'
96
-
97
- One can close the open-end of the RangeMap by using undefined_value
98
-
99
- >>> r = RangeMap({0: RangeMap.undefined_value, 3: 'a', 6: 'b'})
100
- >>> r[0]
101
- Traceback (most recent call last):
102
- ...
103
- KeyError: 0
104
-
105
- One can get the first or last elements in the range by using RangeMap.Item
106
-
107
- >>> last_item = RangeMap.Item(-1)
108
- >>> r[last_item]
109
- 'b'
110
-
111
- .last_item is a shortcut for Item(-1)
112
-
113
- >>> r[RangeMap.last_item]
114
- 'b'
115
-
116
- Sometimes it's useful to find the bounds for a RangeMap
117
-
118
- >>> r.bounds()
119
- (0, 6)
120
-
121
- RangeMap supports .get(key, default)
122
-
123
- >>> r.get(0, 'not found')
124
- 'not found'
125
-
126
- >>> r.get(7, 'not found')
127
- 'not found'
128
-
129
- One often wishes to define the ranges by their left-most values,
130
- which requires use of sort params and a key_match_comparator.
131
-
132
- >>> r = RangeMap({1: 'a', 4: 'b'},
133
- ... sort_params=dict(reverse=True),
134
- ... key_match_comparator=operator.ge)
135
- >>> r[1], r[2], r[3], r[4], r[5], r[6]
136
- ('a', 'a', 'a', 'b', 'b', 'b')
137
-
138
- That wasn't nearly as easy as before, so an alternate constructor
139
- is provided:
140
-
141
- >>> r = RangeMap.left({1: 'a', 4: 'b', 7: RangeMap.undefined_value})
142
- >>> r[1], r[2], r[3], r[4], r[5], r[6]
143
- ('a', 'a', 'a', 'b', 'b', 'b')
144
-
145
- """
146
-
147
- def __init__(
148
- self,
149
- source,
150
- sort_params: Mapping[str, Any] = {},
151
- key_match_comparator=operator.le,
152
- ):
153
- dict.__init__(self, source)
154
- self.sort_params = sort_params
155
- self.match = key_match_comparator
156
-
157
- @classmethod
158
- def left(cls, source):
159
- return cls(
160
- source, sort_params=dict(reverse=True), key_match_comparator=operator.ge
161
- )
162
-
163
- def __getitem__(self, item):
164
- sorted_keys = sorted(self.keys(), **self.sort_params)
165
- if isinstance(item, RangeMap.Item):
166
- result = self.__getitem__(sorted_keys[item])
167
- else:
168
- key = self._find_first_match_(sorted_keys, item)
169
- result = dict.__getitem__(self, key)
170
- if result is RangeMap.undefined_value:
171
- raise KeyError(key)
172
- return result
173
-
174
- def get(self, key, default=None):
175
- """
176
- Return the value for key if key is in the dictionary, else default.
177
- If default is not given, it defaults to None, so that this method
178
- never raises a KeyError.
179
- """
180
- try:
181
- return self[key]
182
- except KeyError:
183
- return default
184
-
185
- def _find_first_match_(self, keys, item):
186
- is_match = functools.partial(self.match, item)
187
- matches = list(filter(is_match, keys))
188
- if matches:
189
- return matches[0]
190
- raise KeyError(item)
191
-
192
- def bounds(self):
193
- sorted_keys = sorted(self.keys(), **self.sort_params)
194
- return (sorted_keys[RangeMap.first_item], sorted_keys[RangeMap.last_item])
195
-
196
- # some special values for the RangeMap
197
- undefined_value = type('RangeValueUndefined', (), {})()
198
-
199
- class Item(int):
200
- "RangeMap Item"
201
-
202
- first_item = Item(0)
203
- last_item = Item(-1)
@@ -236,8 +236,7 @@ class BCPPCompiler(CCompiler):
236
236
  temp_dir = os.path.dirname(objects[0]) # preserve tree structure
237
237
  def_file = os.path.join(temp_dir, f'{modname}.def')
238
238
  contents = ['EXPORTS']
239
- for sym in export_symbols or []:
240
- contents.append(f' {sym}=_{sym}')
239
+ contents.extend(f' {sym}=_{sym}' for sym in export_symbols)
241
240
  self.execute(write_file, (def_file, contents), f"writing {def_file}")
242
241
 
243
242
  # Borland C++ has problems with '/' in paths
@@ -22,7 +22,7 @@ from .errors import (
22
22
  )
23
23
  from .file_util import move_file
24
24
  from .spawn import spawn
25
- from .util import execute, split_quoted, is_mingw
25
+ from .util import execute, is_mingw, split_quoted
26
26
 
27
27
 
28
28
  class CCompiler:
@@ -1124,10 +1124,10 @@ def show_compilers():
1124
1124
  # commands that use it.
1125
1125
  from distutils.fancy_getopt import FancyGetopt
1126
1126
 
1127
- compilers = []
1128
- for compiler in compiler_class.keys():
1129
- compilers.append(("compiler=" + compiler, None, compiler_class[compiler][2]))
1130
- compilers.sort()
1127
+ compilers = sorted(
1128
+ ("compiler=" + compiler, None, compiler_class[compiler][2])
1129
+ for compiler in compiler_class.keys()
1130
+ )
1131
1131
  pretty_printer = FancyGetopt(compilers)
1132
1132
  pretty_printer.print_help("List of available compilers:")
1133
1133
 
@@ -1218,8 +1218,7 @@ def gen_preprocess_options(macros, include_dirs):
1218
1218
  # shell at all costs when we spawn the command!
1219
1219
  pp_opts.append("-D{}={}".format(*macro))
1220
1220
 
1221
- for dir in include_dirs:
1222
- pp_opts.append(f"-I{dir}")
1221
+ pp_opts.extend(f"-I{dir}" for dir in include_dirs)
1223
1222
  return pp_opts
1224
1223
 
1225
1224
 
@@ -1230,10 +1229,7 @@ def gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries):
1230
1229
  directories. Returns a list of command-line options suitable for use
1231
1230
  with some compiler (depending on the two format strings passed in).
1232
1231
  """
1233
- lib_opts = []
1234
-
1235
- for dir in library_dirs:
1236
- lib_opts.append(compiler.library_dir_option(dir))
1232
+ lib_opts = [compiler.library_dir_option(dir) for dir in library_dirs]
1237
1233
 
1238
1234
  for dir in runtime_library_dirs:
1239
1235
  lib_opts.extend(always_iterable(compiler.runtime_library_dir_option(dir)))
@@ -15,9 +15,10 @@ def show_formats():
15
15
  """Print list of available formats (arguments to "--format" option)."""
16
16
  from ..fancy_getopt import FancyGetopt
17
17
 
18
- formats = []
19
- for format in bdist.format_commands:
20
- formats.append(("formats=" + format, None, bdist.format_commands[format][1]))
18
+ formats = [
19
+ ("formats=" + format, None, bdist.format_commands[format][1])
20
+ for format in bdist.format_commands
21
+ ]
21
22
  pretty_printer = FancyGetopt(formats)
22
23
  pretty_printer.print_help("List of available distribution formats:")
23
24
 
@@ -465,10 +465,7 @@ class build_ext(Command):
465
465
  # And build the list of output (built) filenames. Note that this
466
466
  # ignores the 'inplace' flag, and assumes everything goes in the
467
467
  # "build" tree.
468
- outputs = []
469
- for ext in self.extensions:
470
- outputs.append(self.get_ext_fullpath(ext.name))
471
- return outputs
468
+ return [self.get_ext_fullpath(ext.name) for ext in self.extensions]
472
469
 
473
470
  def build_extensions(self):
474
471
  # First, sanity-check the 'extensions' list
@@ -100,10 +100,9 @@ class check(Command):
100
100
  """
101
101
  metadata = self.distribution.metadata
102
102
 
103
- missing = []
104
- for attr in 'name', 'version':
105
- if not getattr(metadata, attr, None):
106
- missing.append(attr)
103
+ missing = [
104
+ attr for attr in ('name', 'version') if not getattr(metadata, attr, None)
105
+ ]
107
106
 
108
107
  if missing:
109
108
  self.warn("missing required meta-data: {}".format(', '.join(missing)))
@@ -5,7 +5,11 @@ platform-independent data files."""
5
5
 
6
6
  # contributed by Bastian Kleineidam
7
7
 
8
+ from __future__ import annotations
9
+
10
+ import functools
8
11
  import os
12
+ from typing import Iterable
9
13
 
10
14
  from ..core import Command
11
15
  from ..util import change_root, convert_path
@@ -46,36 +50,42 @@ class install_data(Command):
46
50
  def run(self):
47
51
  self.mkpath(self.install_dir)
48
52
  for f in self.data_files:
49
- if isinstance(f, str):
50
- # it's a simple file, so copy it
51
- f = convert_path(f)
52
- if self.warn_dir:
53
- self.warn(
54
- "setup script did not provide a directory for "
55
- f"'{f}' -- installing right in '{self.install_dir}'"
56
- )
57
- (out, _) = self.copy_file(f, self.install_dir)
53
+ self._copy(f)
54
+
55
+ @functools.singledispatchmethod
56
+ def _copy(self, f: tuple[str | os.PathLike, Iterable[str | os.PathLike]]):
57
+ # it's a tuple with path to install to and a list of files
58
+ dir = convert_path(f[0])
59
+ if not os.path.isabs(dir):
60
+ dir = os.path.join(self.install_dir, dir)
61
+ elif self.root:
62
+ dir = change_root(self.root, dir)
63
+ self.mkpath(dir)
64
+
65
+ if f[1] == []:
66
+ # If there are no files listed, the user must be
67
+ # trying to create an empty directory, so add the
68
+ # directory to the list of output files.
69
+ self.outfiles.append(dir)
70
+ else:
71
+ # Copy files, adding them to the list of output files.
72
+ for data in f[1]:
73
+ data = convert_path(data)
74
+ (out, _) = self.copy_file(data, dir)
58
75
  self.outfiles.append(out)
59
- else:
60
- # it's a tuple with path to install to and a list of files
61
- dir = convert_path(f[0])
62
- if not os.path.isabs(dir):
63
- dir = os.path.join(self.install_dir, dir)
64
- elif self.root:
65
- dir = change_root(self.root, dir)
66
- self.mkpath(dir)
67
-
68
- if f[1] == []:
69
- # If there are no files listed, the user must be
70
- # trying to create an empty directory, so add the
71
- # directory to the list of output files.
72
- self.outfiles.append(dir)
73
- else:
74
- # Copy files, adding them to the list of output files.
75
- for data in f[1]:
76
- data = convert_path(data)
77
- (out, _) = self.copy_file(data, dir)
78
- self.outfiles.append(out)
76
+
77
+ @_copy.register(str)
78
+ @_copy.register(os.PathLike)
79
+ def _(self, f: str | os.PathLike):
80
+ # it's a simple file, so copy it
81
+ f = convert_path(f)
82
+ if self.warn_dir:
83
+ self.warn(
84
+ "setup script did not provide a directory for "
85
+ f"'{f}' -- installing right in '{self.install_dir}'"
86
+ )
87
+ (out, _) = self.copy_file(f, self.install_dir)
88
+ self.outfiles.append(out)
79
89
 
80
90
  def get_inputs(self):
81
91
  return self.data_files or []
@@ -161,9 +161,7 @@ class install_lib(Command):
161
161
  build_dir = getattr(build_cmd, cmd_option)
162
162
 
163
163
  prefix_len = len(build_dir) + len(os.sep)
164
- outputs = []
165
- for file in build_files:
166
- outputs.append(os.path.join(output_dir, file[prefix_len:]))
164
+ outputs = [os.path.join(output_dir, file[prefix_len:]) for file in build_files]
167
165
 
168
166
  return outputs
169
167
 
@@ -24,10 +24,10 @@ def show_formats():
24
24
  from ..archive_util import ARCHIVE_FORMATS
25
25
  from ..fancy_getopt import FancyGetopt
26
26
 
27
- formats = []
28
- for format in ARCHIVE_FORMATS.keys():
29
- formats.append(("formats=" + format, None, ARCHIVE_FORMATS[format][2]))
30
- formats.sort()
27
+ formats = sorted(
28
+ ("formats=" + format, None, ARCHIVE_FORMATS[format][2])
29
+ for format in ARCHIVE_FORMATS.keys()
30
+ )
31
31
  FancyGetopt(formats).print_help("List of available source distribution formats:")
32
32
 
33
33
 
@@ -14,6 +14,7 @@ if sys.version_info < (3, 9):
14
14
  return self[len(prefix) :]
15
15
  else:
16
16
  return self[:]
17
+
17
18
  else:
18
19
 
19
20
  def removesuffix(self, suffix):
@@ -9,13 +9,11 @@ cygwin in no-cygwin mode).
9
9
  import copy
10
10
  import os
11
11
  import pathlib
12
- import re
13
12
  import shlex
14
13
  import sys
15
14
  import warnings
16
15
  from subprocess import check_output
17
16
 
18
- from ._collections import RangeMap
19
17
  from .errors import (
20
18
  CCompilerError,
21
19
  CompileError,
@@ -26,42 +24,10 @@ from .file_util import write_file
26
24
  from .unixccompiler import UnixCCompiler
27
25
  from .version import LooseVersion, suppress_known_deprecation
28
26
 
29
- _msvcr_lookup = RangeMap.left(
30
- {
31
- # MSVC 7.0
32
- 1300: ['msvcr70'],
33
- # MSVC 7.1
34
- 1310: ['msvcr71'],
35
- # VS2005 / MSVC 8.0
36
- 1400: ['msvcr80'],
37
- # VS2008 / MSVC 9.0
38
- 1500: ['msvcr90'],
39
- # VS2010 / MSVC 10.0
40
- 1600: ['msvcr100'],
41
- # VS2012 / MSVC 11.0
42
- 1700: ['msvcr110'],
43
- # VS2013 / MSVC 12.0
44
- 1800: ['msvcr120'],
45
- # VS2015 / MSVC 14.0
46
- 1900: ['vcruntime140'],
47
- 2000: RangeMap.undefined_value,
48
- },
49
- )
50
-
51
27
 
52
28
  def get_msvcr():
53
- """Include the appropriate MSVC runtime library if Python was built
54
- with MSVC 7.0 or later.
55
- """
56
- match = re.search(r'MSC v\.(\d{4})', sys.version)
57
- try:
58
- msc_ver = int(match.group(1))
59
- except AttributeError:
60
- return []
61
- try:
62
- return _msvcr_lookup[msc_ver]
63
- except KeyError:
64
- raise ValueError(f"Unknown MS Compiler version {msc_ver} ")
29
+ """No longer needed, but kept for backward compatibility."""
30
+ return []
65
31
 
66
32
 
67
33
  _runtime_library_dirs_msg = (
@@ -99,18 +65,20 @@ class CygwinCCompiler(UnixCCompiler):
99
65
  self.cxx = os.environ.get('CXX', 'g++')
100
66
 
101
67
  self.linker_dll = self.cc
68
+ self.linker_dll_cxx = self.cxx
102
69
  shared_option = "-shared"
103
70
 
104
71
  self.set_executables(
105
72
  compiler=f'{self.cc} -mcygwin -O -Wall',
106
73
  compiler_so=f'{self.cc} -mcygwin -mdll -O -Wall',
107
74
  compiler_cxx=f'{self.cxx} -mcygwin -O -Wall',
75
+ compiler_so_cxx=f'{self.cxx} -mcygwin -mdll -O -Wall',
108
76
  linker_exe=f'{self.cc} -mcygwin',
109
- linker_so=(f'{self.linker_dll} -mcygwin {shared_option}'),
77
+ linker_so=f'{self.linker_dll} -mcygwin {shared_option}',
78
+ linker_exe_cxx=f'{self.cxx} -mcygwin',
79
+ linker_so_cxx=f'{self.linker_dll_cxx} -mcygwin {shared_option}',
110
80
  )
111
81
 
112
- # Include the appropriate MSVC runtime library if Python was built
113
- # with MSVC 7.0 or later.
114
82
  self.dll_libraries = get_msvcr()
115
83
 
116
84
  @property
@@ -138,9 +106,17 @@ class CygwinCCompiler(UnixCCompiler):
138
106
  raise CompileError(msg)
139
107
  else: # for other files use the C-compiler
140
108
  try:
141
- self.spawn(
142
- self.compiler_so + cc_args + [src, '-o', obj] + extra_postargs
143
- )
109
+ if self.detect_language(src) == 'c++':
110
+ self.spawn(
111
+ self.compiler_so_cxx
112
+ + cc_args
113
+ + [src, '-o', obj]
114
+ + extra_postargs
115
+ )
116
+ else:
117
+ self.spawn(
118
+ self.compiler_so + cc_args + [src, '-o', obj] + extra_postargs
119
+ )
144
120
  except DistutilsExecError as msg:
145
121
  raise CompileError(msg)
146
122
 
@@ -276,9 +252,12 @@ class Mingw32CCompiler(CygwinCCompiler):
276
252
  self.set_executables(
277
253
  compiler=f'{self.cc} -O -Wall',
278
254
  compiler_so=f'{self.cc} -shared -O -Wall',
255
+ compiler_so_cxx=f'{self.cxx} -shared -O -Wall',
279
256
  compiler_cxx=f'{self.cxx} -O -Wall',
280
257
  linker_exe=f'{self.cc}',
281
258
  linker_so=f'{self.linker_dll} {shared_option}',
259
+ linker_exe_cxx=f'{self.cxx}',
260
+ linker_so_cxx=f'{self.linker_dll_cxx} {shared_option}',
282
261
  )
283
262
 
284
263
  def runtime_library_dir_option(self, dir):
@@ -745,10 +745,7 @@ Common commands: (see '--help-commands' for more)
745
745
  for cmd in std_commands:
746
746
  is_std.add(cmd)
747
747
 
748
- extra_commands = []
749
- for cmd in self.cmdclass.keys():
750
- if cmd not in is_std:
751
- extra_commands.append(cmd)
748
+ extra_commands = [cmd for cmd in self.cmdclass.keys() if cmd not in is_std]
752
749
 
753
750
  max_length = 0
754
751
  for cmd in std_commands + extra_commands:
@@ -776,10 +773,7 @@ Common commands: (see '--help-commands' for more)
776
773
  for cmd in std_commands:
777
774
  is_std.add(cmd)
778
775
 
779
- extra_commands = []
780
- for cmd in self.cmdclass.keys():
781
- if cmd not in is_std:
782
- extra_commands.append(cmd)
776
+ extra_commands = [cmd for cmd in self.cmdclass.keys() if cmd not in is_std]
783
777
 
784
778
  rv = []
785
779
  for cmd in std_commands + extra_commands:
@@ -1301,7 +1295,4 @@ def fix_help_options(options):
1301
1295
  """Convert a 4-tuple 'help_options' list as found in various command
1302
1296
  classes to the 3-tuple form required by FancyGetopt.
1303
1297
  """
1304
- new_options = []
1305
- for help_tuple in options:
1306
- new_options.append(help_tuple[0:3])
1307
- return new_options
1298
+ return [opt[0:3] for opt in options]
@@ -26,7 +26,7 @@ class Extension:
26
26
  name : string
27
27
  the full name of the extension, including any packages -- ie.
28
28
  *not* a filename or pathname, but Python dotted name
29
- sources : [string]
29
+ sources : [string | os.PathLike]
30
30
  list of source filenames, relative to the distribution root
31
31
  (where the setup script lives), in Unix form (slash-separated)
32
32
  for portability. Source files may be C, C++, SWIG (.i),
@@ -106,11 +106,16 @@ class Extension:
106
106
  ):
107
107
  if not isinstance(name, str):
108
108
  raise AssertionError("'name' must be a string")
109
- if not (isinstance(sources, list) and all(isinstance(v, str) for v in sources)):
110
- raise AssertionError("'sources' must be a list of strings")
109
+ if not (
110
+ isinstance(sources, list)
111
+ and all(isinstance(v, (str, os.PathLike)) for v in sources)
112
+ ):
113
+ raise AssertionError(
114
+ "'sources' must be a list of strings or PathLike objects."
115
+ )
111
116
 
112
117
  self.name = name
113
- self.sources = sources
118
+ self.sources = list(map(os.fspath, sources))
114
119
  self.include_dirs = include_dirs or []
115
120
  self.define_macros = define_macros or []
116
121
  self.undef_macros = undef_macros or []
@@ -640,9 +640,7 @@ class MSVCCompiler(CCompiler):
640
640
  else:
641
641
  ldflags = self.ldflags_shared
642
642
 
643
- export_opts = []
644
- for sym in export_symbols or []:
645
- export_opts.append("/EXPORT:" + sym)
643
+ export_opts = [f"/EXPORT:{sym}" for sym in export_symbols or []]
646
644
 
647
645
  ld_args = (
648
646
  ldflags + lib_opts + export_opts + objects + ['/OUT:' + output_filename]