python-inspector 0.14.0__py3-none-any.whl → 0.14.2__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.
python_inspector/utils.py CHANGED
@@ -16,20 +16,28 @@ from typing import List
16
16
  from typing import NamedTuple
17
17
  from typing import Optional
18
18
 
19
+ from urllib.parse import urlparse
20
+
19
21
  import aiohttp
20
22
  import requests
21
23
 
22
24
 
23
25
  def get_netrc_auth(url, netrc):
24
26
  """
25
- Return login and password if url is in netrc
27
+ Return login and password if either the hostname is in netrc or a default is set in netrc
26
28
  else return login and password as None
27
29
  """
30
+ hostname = urlparse(url).hostname
28
31
  hosts = netrc.hosts
29
- if url in hosts:
30
- url_auth = hosts.get(url)
32
+ if hostname in hosts:
33
+ url_auth = hosts.get(hostname)
31
34
  # netrc returns a tuple of (login, account, password)
32
35
  return (url_auth[0], url_auth[2])
36
+
37
+ if "default" in hosts:
38
+ default_auth = hosts.get("default")
39
+ return (default_auth[0], default_auth[2])
40
+
33
41
  return (None, None)
34
42
 
35
43
 
@@ -81,7 +89,7 @@ async def get_response_async(url: str) -> Optional[Dict]:
81
89
  Return a mapping of the JSON response from fetching ``url``
82
90
  or None if the ``url`` cannot be fetched.
83
91
  """
84
- async with aiohttp.ClientSession() as session:
92
+ async with aiohttp.ClientSession(trust_env=True) as session:
85
93
  async with session.get(url) as response:
86
94
  if response.status == 200:
87
95
  return await response.json()
@@ -1598,6 +1598,10 @@ class PypiSimpleRepository:
1598
1598
  name using the `index_url` of this repository.
1599
1599
  """
1600
1600
  package_url = f"{self.index_url}/{normalized_name}"
1601
+
1602
+ if not package_url.endswith("/"):
1603
+ package_url += "/"
1604
+
1601
1605
  text, _ = await CACHE.get(
1602
1606
  path_or_url=package_url,
1603
1607
  credentials=self.credentials,
@@ -1797,9 +1801,12 @@ async def get_remote_file_content(
1797
1801
 
1798
1802
  auth = None
1799
1803
  if credentials:
1800
- auth = (credentials.get("login"), credentials.get("password"))
1804
+ login = credentials.get("login")
1805
+ password = credentials.get("password")
1806
+ if login and password:
1807
+ auth = aiohttp.BasicAuth(login, password)
1801
1808
 
1802
- async with aiohttp.ClientSession() as session:
1809
+ async with aiohttp.ClientSession(trust_env=True) as session:
1803
1810
  async with session.get(url, allow_redirects=True, headers=headers, auth=auth) as response:
1804
1811
  status = response.status
1805
1812
  if status != requests.codes.ok: # NOQA
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-inspector
3
- Version: 0.14.0
3
+ Version: 0.14.2
4
4
  Summary: python-inspector is is a collection of utilities to collect PyPI package metadata and resolve packages dependencies.
5
5
  Home-page: https://github.com/aboutcode-org/python-inspector
6
6
  Author: nexB. Inc. and others
@@ -62,10 +62,6 @@ python-inspector - inspect Python package dependencies and metadata
62
62
  =====================================================================
63
63
 
64
64
 
65
- Copyright (c) nexB Inc. and others.
66
- SPDX-License-Identifier: Apache-2.0
67
- Homepage: https://github.com/aboutcode-org/python-inspector and https://www.aboutcode.org/
68
-
69
65
 
70
66
  ``python-inspector`` is a collection of utilities to:
71
67
 
@@ -88,21 +84,21 @@ The goal of python-inspector is to be a comprehensive library
88
84
  that can handle every style of Python package layouts, manifests and lockfiles.
89
85
 
90
86
 
91
- Testing
92
- --------
87
+ SPDX-License-Identifier: Apache-2.0
93
88
 
94
- - Run the tests with::
89
+ Copyright (c) AboutCode, nexB Inc. and others.
95
90
 
96
- pytest -vvs
97
-
98
- - There are live tests to regenerate the tests with updated data run::
91
+ Homepage: https://github.com/aboutcode-org/python-inspector and https://www.aboutcode.org/
99
92
 
100
- PYINSP_REGEN_TEST_FIXTURES=yes pytest -vvs
101
93
 
102
94
  Usage
103
95
  --------
104
96
 
105
- - Install with pip::
97
+ - Install the stable release with pip from PyPI::
98
+
99
+ pip install python-inspector
100
+
101
+ - Or install the latest with pip::
106
102
 
107
103
  pip install git+https://github.com/aboutcode-org/python-inspector
108
104
 
@@ -111,8 +107,71 @@ Usage
111
107
  python-inspector --help
112
108
 
113
109
 
110
+ Development
111
+ --------------
112
+
113
+ Run::
114
+
115
+ git clone https://github.com/aboutcode-org/python-inspector
116
+
117
+ Create a virtual environment and install deps locally::
118
+
119
+ make dev
120
+ source venv/bin/activate
121
+
122
+
123
+ When in the virtual environment, run python-inspector from that clone::
124
+
125
+ python-inspector --help
126
+
127
+
128
+ Run tests::
129
+
130
+ make test
131
+
132
+ Run code checks::
114
133
 
115
- Its companion libraries are:
134
+ make check
135
+
136
+ Run code formatting::
137
+
138
+ make valie
139
+
140
+ Check available make targets for further details
141
+
142
+
143
+
144
+ More testing
145
+ ------------------
146
+
147
+ - Run the tests with pytest::
148
+
149
+ pytest -vvs
150
+
151
+ - Or run them faster using 12 cores ::
152
+
153
+ pytest -vvs --numprocesses=12
154
+
155
+
156
+ Regenerate test files
157
+ -----------------------------
158
+
159
+ Some tests use live data from Pypi.org to run resolutions. When the package versions have
160
+ changed, the resolution can change and some of the tests fail. We have an environment variable
161
+ that regenerates the expected JSON result files when set.
162
+
163
+ To regenerate expected test result files for the failed tests, use this command::
164
+
165
+ PYINSP_REGEN_TEST_FIXTURES=yes pytest -vvs --lf
166
+
167
+ Then, carefully review the diff before committing the expected JSON test result files to validate
168
+ that the changes are OK and mostly affect small changes in resolved package versions.
169
+
170
+
171
+ Credits and dependencies
172
+ ---------------------------
173
+
174
+ For info, python-inspector embeds or depends on these libraries:
116
175
 
117
176
  - ``pip-requirements-parser``, a mostly correct pip requirements parsing
118
177
  library extracted from pip.
@@ -132,6 +191,8 @@ Its companion libraries are:
132
191
 
133
192
  - ``packageurl-python`` to use Package URL to reference Python packages
134
193
 
194
+ - ``scancode-toolkit`` for Python package manifest parsing.
195
+
135
196
 
136
197
 
137
198
  Acknowledgements, Funding, Support and Sponsoring
@@ -22,21 +22,21 @@ python_inspector/settings.py,sha256=r4711MS_nFyXU4pWWhLtXt3mGo3QJBIZV28IttZT7gI,
22
22
  python_inspector/setup_py_live_eval.py,sha256=6uJLJT_Aw5SEeybe8JEaEiWCHOTbpsJ0BinN4mlprUE,7601
23
23
  python_inspector/setup_py_live_eval.py.ABOUT,sha256=ecRsdi0Z--mX8gnSwQzE2OqucpmD0AsmPlojp70uPxI,396
24
24
  python_inspector/setup_py_live_eval.py.LICENSE,sha256=5wfEqJLf5ANizw20WUURuTgoZOzMRK_4iGA39BApyRk,1643
25
- python_inspector/utils.py,sha256=ZQlg0SsdlJ0sjYJv4hy_p-hoeFIovB41IRpUI6uk3wE,3276
25
+ python_inspector/utils.py,sha256=cQWtdVT0RZ8XGj_sxYu_lX_sg-Iz3NCCtsg-haYbwiM,3541
26
26
  python_inspector/utils_pip_compatibility_tags.py,sha256=8ZQkXLldhqqO4sJ0aVXQwWYdw3Qo1_C9MhntShVlgE8,6831
27
27
  python_inspector/utils_pip_compatibility_tags.py.ABOUT,sha256=tFhzj7qUEA9H-Tg6K1BI5QBtmQEq0vHg0X2Ws7t073U,540
28
- python_inspector/utils_pypi.py,sha256=_AOJhnKmEgakF2yueuiaYWk1zVB8uEcTw4VElky2Ydg,58794
28
+ python_inspector/utils_pypi.py,sha256=ZA4J_PEbG31vFbR4n8CT9ToAXY9g5P5POa6idPmlG3E,58985
29
29
  python_inspector/utils_pypi.py.ABOUT,sha256=7s9WCNmS-qJJgHC979fI4whrM5Y41-Ar-LZoIfZXPVU,635
30
30
  python_inspector/utils_pypi_supported_tags.py,sha256=SdbIlKoCgyqBZIesEdrFhVMnYikBirvSDvPUPIomTSo,2850
31
31
  python_inspector/utils_pypi_supported_tags.py.ABOUT,sha256=ndJ1kQS6u7caYmLc6XVnNIdKfpnvGjKepxpmhQJWJyA,741
32
- python_inspector-0.14.0.dist-info/licenses/AUTHORS.rst,sha256=rRa-_IwbfBl84NqT5QZWFTXHsJnvRz8SP9dymwrEDAE,87
33
- python_inspector-0.14.0.dist-info/licenses/CHANGELOG.rst,sha256=PPxAfnWyf1tzwksoVZC--_UYHIXqd2dSd_obU4Buvn0,5617
34
- python_inspector-0.14.0.dist-info/licenses/CODE_OF_CONDUCT.rst,sha256=xXDTFpYY3Y7JoxrWADihieUvhGlwJc_oxsbmLJaBvE4,3422
35
- python_inspector-0.14.0.dist-info/licenses/NOTICE,sha256=fkLIlzyP8zWNnPbFSXkTInNgYl35THH5-J8vMKuNzhc,761
36
- python_inspector-0.14.0.dist-info/licenses/README.rst,sha256=HU7XjhHojHF4Q_aVt0dibl2UIPDXGr0HTEifRKqjufY,5717
37
- python_inspector-0.14.0.dist-info/licenses/apache-2.0.LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
38
- python_inspector-0.14.0.dist-info/METADATA,sha256=tWOsG1OCR4EkSrr8850FuGXpZ6J2TCv-MGK02ip-RLA,8064
39
- python_inspector-0.14.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
- python_inspector-0.14.0.dist-info/entry_points.txt,sha256=2s9F95rPWbgz3cOnKN3Z7PwzglPt2EsX2qf7W0Xubpk,87
41
- python_inspector-0.14.0.dist-info/top_level.txt,sha256=C-KAHTL8C6jd7QULvFk83YjOBVxDrnyefG3RikRHRlw,31
42
- python_inspector-0.14.0.dist-info/RECORD,,
32
+ python_inspector-0.14.2.dist-info/licenses/AUTHORS.rst,sha256=rRa-_IwbfBl84NqT5QZWFTXHsJnvRz8SP9dymwrEDAE,87
33
+ python_inspector-0.14.2.dist-info/licenses/CHANGELOG.rst,sha256=PPxAfnWyf1tzwksoVZC--_UYHIXqd2dSd_obU4Buvn0,5617
34
+ python_inspector-0.14.2.dist-info/licenses/CODE_OF_CONDUCT.rst,sha256=xXDTFpYY3Y7JoxrWADihieUvhGlwJc_oxsbmLJaBvE4,3422
35
+ python_inspector-0.14.2.dist-info/licenses/NOTICE,sha256=fkLIlzyP8zWNnPbFSXkTInNgYl35THH5-J8vMKuNzhc,761
36
+ python_inspector-0.14.2.dist-info/licenses/README.rst,sha256=ucUCSQt39WlNfVdOl_1WbuvBqEN0NZm_h5o_vltNFps,7033
37
+ python_inspector-0.14.2.dist-info/licenses/apache-2.0.LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
38
+ python_inspector-0.14.2.dist-info/METADATA,sha256=EMdgOl1DHfmevtsFhIQW9-JaWGdovOo7gvth-0Xft_o,9380
39
+ python_inspector-0.14.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
+ python_inspector-0.14.2.dist-info/entry_points.txt,sha256=2s9F95rPWbgz3cOnKN3Z7PwzglPt2EsX2qf7W0Xubpk,87
41
+ python_inspector-0.14.2.dist-info/top_level.txt,sha256=C-KAHTL8C6jd7QULvFk83YjOBVxDrnyefG3RikRHRlw,31
42
+ python_inspector-0.14.2.dist-info/RECORD,,
@@ -2,10 +2,6 @@ python-inspector - inspect Python package dependencies and metadata
2
2
  =====================================================================
3
3
 
4
4
 
5
- Copyright (c) nexB Inc. and others.
6
- SPDX-License-Identifier: Apache-2.0
7
- Homepage: https://github.com/aboutcode-org/python-inspector and https://www.aboutcode.org/
8
-
9
5
 
10
6
  ``python-inspector`` is a collection of utilities to:
11
7
 
@@ -28,21 +24,21 @@ The goal of python-inspector is to be a comprehensive library
28
24
  that can handle every style of Python package layouts, manifests and lockfiles.
29
25
 
30
26
 
31
- Testing
32
- --------
27
+ SPDX-License-Identifier: Apache-2.0
33
28
 
34
- - Run the tests with::
29
+ Copyright (c) AboutCode, nexB Inc. and others.
35
30
 
36
- pytest -vvs
37
-
38
- - There are live tests to regenerate the tests with updated data run::
31
+ Homepage: https://github.com/aboutcode-org/python-inspector and https://www.aboutcode.org/
39
32
 
40
- PYINSP_REGEN_TEST_FIXTURES=yes pytest -vvs
41
33
 
42
34
  Usage
43
35
  --------
44
36
 
45
- - Install with pip::
37
+ - Install the stable release with pip from PyPI::
38
+
39
+ pip install python-inspector
40
+
41
+ - Or install the latest with pip::
46
42
 
47
43
  pip install git+https://github.com/aboutcode-org/python-inspector
48
44
 
@@ -51,8 +47,71 @@ Usage
51
47
  python-inspector --help
52
48
 
53
49
 
50
+ Development
51
+ --------------
52
+
53
+ Run::
54
+
55
+ git clone https://github.com/aboutcode-org/python-inspector
56
+
57
+ Create a virtual environment and install deps locally::
58
+
59
+ make dev
60
+ source venv/bin/activate
61
+
62
+
63
+ When in the virtual environment, run python-inspector from that clone::
64
+
65
+ python-inspector --help
66
+
67
+
68
+ Run tests::
69
+
70
+ make test
71
+
72
+ Run code checks::
54
73
 
55
- Its companion libraries are:
74
+ make check
75
+
76
+ Run code formatting::
77
+
78
+ make valie
79
+
80
+ Check available make targets for further details
81
+
82
+
83
+
84
+ More testing
85
+ ------------------
86
+
87
+ - Run the tests with pytest::
88
+
89
+ pytest -vvs
90
+
91
+ - Or run them faster using 12 cores ::
92
+
93
+ pytest -vvs --numprocesses=12
94
+
95
+
96
+ Regenerate test files
97
+ -----------------------------
98
+
99
+ Some tests use live data from Pypi.org to run resolutions. When the package versions have
100
+ changed, the resolution can change and some of the tests fail. We have an environment variable
101
+ that regenerates the expected JSON result files when set.
102
+
103
+ To regenerate expected test result files for the failed tests, use this command::
104
+
105
+ PYINSP_REGEN_TEST_FIXTURES=yes pytest -vvs --lf
106
+
107
+ Then, carefully review the diff before committing the expected JSON test result files to validate
108
+ that the changes are OK and mostly affect small changes in resolved package versions.
109
+
110
+
111
+ Credits and dependencies
112
+ ---------------------------
113
+
114
+ For info, python-inspector embeds or depends on these libraries:
56
115
 
57
116
  - ``pip-requirements-parser``, a mostly correct pip requirements parsing
58
117
  library extracted from pip.
@@ -72,6 +131,8 @@ Its companion libraries are:
72
131
 
73
132
  - ``packageurl-python`` to use Package URL to reference Python packages
74
133
 
134
+ - ``scancode-toolkit`` for Python package manifest parsing.
135
+
75
136
 
76
137
 
77
138
  Acknowledgements, Funding, Support and Sponsoring