py2docfx 0.1.20.dev2245077__py3-none-any.whl → 0.1.20.dev2245319__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/convert_prepare/package_info.py +37 -27
- py2docfx/convert_prepare/tests/test_package_info.py +159 -1
- {py2docfx-0.1.20.dev2245077.dist-info → py2docfx-0.1.20.dev2245319.dist-info}/METADATA +1 -1
- {py2docfx-0.1.20.dev2245077.dist-info → py2docfx-0.1.20.dev2245319.dist-info}/RECORD +6 -6
- {py2docfx-0.1.20.dev2245077.dist-info → py2docfx-0.1.20.dev2245319.dist-info}/WHEEL +0 -0
- {py2docfx-0.1.20.dev2245077.dist-info → py2docfx-0.1.20.dev2245319.dist-info}/top_level.txt +0 -0
@@ -13,7 +13,7 @@ class PackageInfo:
|
|
13
13
|
path: Source
|
14
14
|
def __init__(self) -> None:
|
15
15
|
pass
|
16
|
-
|
16
|
+
|
17
17
|
@classmethod
|
18
18
|
def report_error(cls, name, value, condition=None):
|
19
19
|
py2docfx_logger = get_logger(__name__)
|
@@ -53,6 +53,7 @@ class PackageInfo:
|
|
53
53
|
|
54
54
|
package_info.version = package_info_dict.get("version", None)
|
55
55
|
package_info.extra_index_url = package_info_dict.get("extra_index_url", None)
|
56
|
+
package_info.extras = package_info_dict.get("extras", [])
|
56
57
|
|
57
58
|
if package_info.install_type == cls.InstallType.SOURCE_CODE:
|
58
59
|
package_info.url = package_info_dict.get("url", None)
|
@@ -93,56 +94,65 @@ class PackageInfo:
|
|
93
94
|
return package_info
|
94
95
|
|
95
96
|
def get_combined_name_version(self):
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
return f"{self.name.strip()}=={self.version.strip()}"
|
97
|
+
base_name = (
|
98
|
+
f"{self.name}[{','.join(extras)}]"
|
99
|
+
if (extras := getattr(self, "extras", []))
|
100
|
+
else self.name
|
101
|
+
)
|
102
102
|
|
103
|
-
|
104
|
-
|
105
|
-
|
103
|
+
version = getattr(self, "version", None)
|
104
|
+
if not version:
|
105
|
+
return base_name
|
106
|
+
elif re.match("^(<|>|<=|>=|==).+$", version.strip()):
|
107
|
+
return base_name.strip() + version.strip()
|
108
|
+
else:
|
109
|
+
return f"{base_name.strip()}=={version.strip()}"
|
106
110
|
|
111
|
+
def get_install_command(self) -> tuple[str, list]:
|
107
112
|
if self.install_type == self.InstallType.DIST_FILE:
|
108
|
-
if hasattr(self, "location")
|
109
|
-
packageInstallName = self.location
|
110
|
-
else:
|
113
|
+
if not hasattr(self, "location") or not self.location:
|
111
114
|
self.__class__.report_error(
|
112
115
|
"location", "None", condition="When install_type is dist_file"
|
113
116
|
)
|
117
|
+
return (
|
118
|
+
f"{self.location}[{','.join(extras)}]"
|
119
|
+
if (extras := getattr(self, "extras", None))
|
120
|
+
else self.location,
|
121
|
+
[],
|
122
|
+
)
|
114
123
|
|
115
|
-
|
124
|
+
if self.install_type == self.InstallType.PYPI:
|
116
125
|
if not hasattr(self, "name") or not self.name:
|
117
126
|
self.__class__.report_error(
|
118
127
|
"name", "None", condition="When install_type is pypi"
|
119
128
|
)
|
120
|
-
|
121
|
-
|
122
|
-
else:
|
123
|
-
packageInstallName = self.name
|
129
|
+
pipInstallExtraOptions = []
|
130
|
+
if not hasattr(self, "version") or self.version is None:
|
124
131
|
pipInstallExtraOptions.append("--upgrade")
|
125
|
-
|
126
132
|
if hasattr(self, "extra_index_url") and self.extra_index_url:
|
127
133
|
pipInstallExtraOptions.extend(
|
128
134
|
["--extra-index-url", self.extra_index_url]
|
129
135
|
)
|
136
|
+
return (self.get_combined_name_version(), pipInstallExtraOptions)
|
130
137
|
|
131
|
-
|
132
|
-
if hasattr(self, "path")
|
133
|
-
packageInstallName = self.path.source_folder
|
134
|
-
else:
|
138
|
+
if self.install_type == self.InstallType.SOURCE_CODE:
|
139
|
+
if not hasattr(self, "path") or not self.path.source_folder:
|
135
140
|
self.__class__.report_error(
|
136
141
|
"path.source_folder",
|
137
142
|
"None",
|
138
143
|
condition="When install_type is source_code",
|
139
144
|
)
|
140
|
-
|
141
|
-
|
145
|
+
return (
|
146
|
+
f"{self.path.source_folder}[{','.join(extras)}]"
|
147
|
+
if (extras := getattr(self, "extras", None))
|
148
|
+
else self.path.source_folder,
|
149
|
+
[],
|
150
|
+
)
|
151
|
+
|
152
|
+
self.__class__.report_error("install_type", self.install_type)
|
142
153
|
|
143
|
-
return (packageInstallName, pipInstallExtraOptions)
|
144
154
|
|
145
|
-
def get_exluded_command(self) ->
|
155
|
+
def get_exluded_command(self) -> list:
|
146
156
|
py2docfx_logger = get_logger(__name__)
|
147
157
|
if hasattr(self, "path"):
|
148
158
|
code_location = self.path.source_folder
|
@@ -80,4 +80,162 @@ def test_get_exclude_command_check_extra_exclude(tmp_path):
|
|
80
80
|
]
|
81
81
|
def form_exclude_path(raletive_path):
|
82
82
|
return os.path.join(source_folder, raletive_path)
|
83
|
-
assert exclude_path == [form_exclude_path(path) for path in expected_exclude_path]
|
83
|
+
assert exclude_path == [form_exclude_path(path) for path in expected_exclude_path]
|
84
|
+
|
85
|
+
|
86
|
+
def test_get_combined_name_version_with_extras():
|
87
|
+
"""Test get_combined_name_version with extras"""
|
88
|
+
# Test package with extras but no version
|
89
|
+
test_data = {
|
90
|
+
"package_info": {
|
91
|
+
"install_type": "pypi",
|
92
|
+
"name": "test-package",
|
93
|
+
"extras": ["dev", "test"],
|
94
|
+
},
|
95
|
+
}
|
96
|
+
pkg = PackageInfo.parse_from(test_data)
|
97
|
+
assert pkg.get_combined_name_version() == "test-package[dev,test]"
|
98
|
+
|
99
|
+
# Test package with extras and version
|
100
|
+
test_data_with_version = {
|
101
|
+
"package_info": {
|
102
|
+
"install_type": "pypi",
|
103
|
+
"name": "test-package",
|
104
|
+
"version": "1.0.0",
|
105
|
+
"extras": ["dev", "test"],
|
106
|
+
},
|
107
|
+
}
|
108
|
+
pkg_with_version = PackageInfo.parse_from(test_data_with_version)
|
109
|
+
assert (
|
110
|
+
pkg_with_version.get_combined_name_version() == "test-package[dev,test]==1.0.0"
|
111
|
+
)
|
112
|
+
|
113
|
+
# Test package with extras and version operator
|
114
|
+
test_data_with_operator = {
|
115
|
+
"package_info": {
|
116
|
+
"install_type": "pypi",
|
117
|
+
"name": "test-package",
|
118
|
+
"version": ">=1.0.0",
|
119
|
+
"extras": ["dev"],
|
120
|
+
},
|
121
|
+
}
|
122
|
+
pkg_with_operator = PackageInfo.parse_from(test_data_with_operator)
|
123
|
+
assert pkg_with_operator.get_combined_name_version() == "test-package[dev]>=1.0.0"
|
124
|
+
|
125
|
+
|
126
|
+
def test_install_command_pypi_with_extras():
|
127
|
+
"""Test get_install_command for PYPI packages with extras"""
|
128
|
+
# Test PYPI package with extras and version
|
129
|
+
test_data = {
|
130
|
+
"package_info": {
|
131
|
+
"install_type": "pypi",
|
132
|
+
"name": "test-package",
|
133
|
+
"version": "1.0.0",
|
134
|
+
"extras": ["dev", "test"],
|
135
|
+
},
|
136
|
+
}
|
137
|
+
pkg = PackageInfo.parse_from(test_data)
|
138
|
+
install_command = pkg.get_install_command()
|
139
|
+
assert install_command[0] == "test-package[dev,test]==1.0.0"
|
140
|
+
assert install_command[1] == []
|
141
|
+
|
142
|
+
# Test PYPI package with extras but no version (should get --upgrade)
|
143
|
+
test_data_no_version = {
|
144
|
+
"package_info": {
|
145
|
+
"install_type": "pypi",
|
146
|
+
"name": "test-package",
|
147
|
+
"extras": ["dev"],
|
148
|
+
},
|
149
|
+
}
|
150
|
+
pkg_no_version = PackageInfo.parse_from(test_data_no_version)
|
151
|
+
install_command = pkg_no_version.get_install_command()
|
152
|
+
assert install_command[0] == "test-package[dev]"
|
153
|
+
assert install_command[1] == ["--upgrade"]
|
154
|
+
|
155
|
+
|
156
|
+
def test_install_command_source_code_with_extras(tmp_path):
|
157
|
+
"""Test get_install_command for SOURCE_CODE packages with extras"""
|
158
|
+
source_folder = os.path.join(tmp_path, "source_folder")
|
159
|
+
yaml_output_folder = os.path.join(tmp_path, "yaml_output_folder")
|
160
|
+
|
161
|
+
test_data = {
|
162
|
+
"package_info": {
|
163
|
+
"install_type": "source_code",
|
164
|
+
"name": "test-package",
|
165
|
+
"url": "https://github.com/test/test-package.git",
|
166
|
+
"extras": ["dev", "test"],
|
167
|
+
},
|
168
|
+
}
|
169
|
+
pkg = PackageInfo.parse_from(test_data)
|
170
|
+
pkg.path = Source(
|
171
|
+
source_folder=source_folder,
|
172
|
+
yaml_output_folder=yaml_output_folder,
|
173
|
+
package_name="test-package",
|
174
|
+
)
|
175
|
+
|
176
|
+
install_command = pkg.get_install_command()
|
177
|
+
assert install_command[0] == f"{source_folder}[dev,test]"
|
178
|
+
assert install_command[1] == []
|
179
|
+
|
180
|
+
|
181
|
+
def test_install_command_dist_file_with_extras():
|
182
|
+
"""Test get_install_command for DIST_FILE packages with extras"""
|
183
|
+
test_data = {
|
184
|
+
"package_info": {
|
185
|
+
"install_type": "dist_file",
|
186
|
+
"location": "/path/to/package.whl",
|
187
|
+
"extras": ["dev"],
|
188
|
+
},
|
189
|
+
}
|
190
|
+
pkg = PackageInfo.parse_from(test_data)
|
191
|
+
install_command = pkg.get_install_command()
|
192
|
+
assert install_command[0] == "/path/to/package.whl[dev]"
|
193
|
+
assert install_command[1] == []
|
194
|
+
|
195
|
+
|
196
|
+
def test_install_command_without_extras():
|
197
|
+
"""Test that packages without extras work as before"""
|
198
|
+
# Test PYPI package without extras
|
199
|
+
test_data = {
|
200
|
+
"package_info": {
|
201
|
+
"install_type": "pypi",
|
202
|
+
"name": "test-package",
|
203
|
+
"version": "1.0.0",
|
204
|
+
}
|
205
|
+
}
|
206
|
+
pkg = PackageInfo.parse_from(test_data)
|
207
|
+
install_command = pkg.get_install_command()
|
208
|
+
assert install_command[0] == "test-package==1.0.0"
|
209
|
+
assert install_command[1] == []
|
210
|
+
|
211
|
+
|
212
|
+
def test_install_command_empty_extras():
|
213
|
+
"""Test that packages with empty extras list work correctly"""
|
214
|
+
test_data = {
|
215
|
+
"package_info": {
|
216
|
+
"install_type": "pypi",
|
217
|
+
"name": "test-package",
|
218
|
+
"version": "1.0.0",
|
219
|
+
"extras": [],
|
220
|
+
},
|
221
|
+
}
|
222
|
+
pkg = PackageInfo.parse_from(test_data)
|
223
|
+
install_command = pkg.get_install_command()
|
224
|
+
assert install_command[0] == "test-package==1.0.0"
|
225
|
+
assert install_command[1] == []
|
226
|
+
|
227
|
+
|
228
|
+
def test_install_command_single_extra():
|
229
|
+
"""Test package with single extra"""
|
230
|
+
test_data = {
|
231
|
+
"package_info": {
|
232
|
+
"install_type": "pypi",
|
233
|
+
"name": "test-package",
|
234
|
+
"version": "1.0.0",
|
235
|
+
"extras": ["dev"],
|
236
|
+
},
|
237
|
+
}
|
238
|
+
pkg = PackageInfo.parse_from(test_data)
|
239
|
+
install_command = pkg.get_install_command()
|
240
|
+
assert install_command[0] == "test-package[dev]==1.0.0"
|
241
|
+
assert install_command[1] == []
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: py2docfx
|
3
|
-
Version: 0.1.20.
|
3
|
+
Version: 0.1.20.dev2245319
|
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
|
@@ -10,7 +10,7 @@ py2docfx/convert_prepare/get_source.py,sha256=I_-QXXFFraMruDf13xlkwGAs5hDuv-wAjW
|
|
10
10
|
py2docfx/convert_prepare/git.py,sha256=Cq76ooxejKlVJiJWWbBhbLZ_JvxqN2ka12L8jkl80b4,6492
|
11
11
|
py2docfx/convert_prepare/install_package.py,sha256=aJxQBwLRPTIKpdtLVl-SaXPaF_OX_H1ZtWmcKD8Zzuk,274
|
12
12
|
py2docfx/convert_prepare/pack.py,sha256=Jjj9ps8ESoKUFmSk6VgNmxOwMhuwirnQ-rhqigH-4VY,1578
|
13
|
-
py2docfx/convert_prepare/package_info.py,sha256
|
13
|
+
py2docfx/convert_prepare/package_info.py,sha256=K9bkS--64XEfyZTYS3ms1xGEgy3tdAWav94wj-7BBnw,8126
|
14
14
|
py2docfx/convert_prepare/package_info_extra_settings.py,sha256=u5B5e8hc0m9PA_-0kJzq1LtKn-xzZlucwXHTFy49mDg,1475
|
15
15
|
py2docfx/convert_prepare/params.py,sha256=PXMB8pLtb4XbfI322avA47q0AO-TyBE6kZf7FU8I6v4,1771
|
16
16
|
py2docfx/convert_prepare/paths.py,sha256=964RX81Qf__rzXgEATfqBNFCKTYVjLt9J7WCz2TnNdc,485
|
@@ -30,7 +30,7 @@ py2docfx/convert_prepare/tests/test_environment.py,sha256=oJ_IuVQ-zwWNQZRXR74RDW
|
|
30
30
|
py2docfx/convert_prepare/tests/test_generate_document.py,sha256=mY8DRT-WRGIBFdDRdFwa7ZSUQwR-fTQtyKwzrzFZLU8,2621
|
31
31
|
py2docfx/convert_prepare/tests/test_get_source.py,sha256=IGBLAemm5SWUnNJJh6GJE5gBtAAdlC_cxS1xSeugzBI,7949
|
32
32
|
py2docfx/convert_prepare/tests/test_pack.py,sha256=Gw-LkIcbQuQHpoSbvkybYt4_fVw-LL12dceWw5AUKdE,4242
|
33
|
-
py2docfx/convert_prepare/tests/test_package_info.py,sha256=
|
33
|
+
py2docfx/convert_prepare/tests/test_package_info.py,sha256=iUJIfTEPVuGnA8aypL7TLJhfY3F3gdzJUpig5pSYYPk,8635
|
34
34
|
py2docfx/convert_prepare/tests/test_params.py,sha256=itwmVdBMtU1qIXAGaIoaDfvTOYyAL2B_WLsaBV9KUZY,2232
|
35
35
|
py2docfx/convert_prepare/tests/test_post_process_merge_toc.py,sha256=YKOcn4_lf4syGsAvJ9BqpdUUc3SLfK4TiOX1lpXJT_Y,885
|
36
36
|
py2docfx/convert_prepare/tests/test_source.py,sha256=LNFZtvjz6QhVLOxatjWokYCCcoSm0bhTikMF9KoTPIE,2025
|
@@ -3914,7 +3914,7 @@ py2docfx/venv/venv1/Lib/site-packages/wheel/_commands/convert.py,sha256=0wSJMU0m
|
|
3914
3914
|
py2docfx/venv/venv1/Lib/site-packages/wheel/_commands/pack.py,sha256=o3iwjfRHl7N9ul-M2kHbewLJZnqBLAWf0tzUCwoiTMw,3078
|
3915
3915
|
py2docfx/venv/venv1/Lib/site-packages/wheel/_commands/tags.py,sha256=Rv2ySVb8-qX3osKp3uJgxcIMXkjt43XUD0-zvC6KvnY,4775
|
3916
3916
|
py2docfx/venv/venv1/Lib/site-packages/wheel/_commands/unpack.py,sha256=Y_J7ynxPSoFFTT7H0fMgbBlVErwyDGcObgme5MBuz58,1021
|
3917
|
-
py2docfx-0.1.20.
|
3918
|
-
py2docfx-0.1.20.
|
3919
|
-
py2docfx-0.1.20.
|
3920
|
-
py2docfx-0.1.20.
|
3917
|
+
py2docfx-0.1.20.dev2245319.dist-info/METADATA,sha256=alQjhdxpFKoY6UaTnlfj_pbVltuQejW_-otvBlc9Odg,548
|
3918
|
+
py2docfx-0.1.20.dev2245319.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
3919
|
+
py2docfx-0.1.20.dev2245319.dist-info/top_level.txt,sha256=5dH2uP81dczt_qQJ38wiZ-gzoVWasfiJALWRSjdbnYU,9
|
3920
|
+
py2docfx-0.1.20.dev2245319.dist-info/RECORD,,
|
File without changes
|
File without changes
|