generated from aboutcode-org/skeleton
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix resolving requirements with percent encoded characters
`Distribution.from_link()` derives the version string of a package from the given (percent encoded) `Link.url`. That derivation lacks the decoding, so the resulting version string may also contain percent encoded characters in which case the dependency resolution fails. Fix the resolution by URL adding the missing unquoting. Fixes #143. Signed-off-by: Frank Viernau <[email protected]>
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
from python_inspector.resolution import parse_reqs_from_setup_py_insecurely | ||
from python_inspector.utils_pypi import PYPI_PUBLIC_REPO | ||
from python_inspector.utils_pypi import Environment | ||
from python_inspector.utils_pypi import PypiSimpleRepository | ||
|
||
setup_test_env = FileDrivenTesting() | ||
setup_test_env.test_data_dir = os.path.join(os.path.dirname(__file__), "data") | ||
|
@@ -130,6 +131,34 @@ def test_get_resolved_dependencies_with_tilde_requirement_using_json_api(): | |
] | ||
|
||
|
||
@pytest.mark.online | ||
def test_get_resolved_dependencies_with_url_encoded_char_plus(): | ||
req = Requirement("torch==2.0.0+cpu") | ||
req.is_requirement_resolved = True | ||
_, plist = get_resolved_dependencies( | ||
requirements=[req], | ||
environment=Environment( | ||
python_version="310", | ||
operating_system="linux", | ||
), | ||
repos=[ | ||
PypiSimpleRepository(index_url="https://download.pytorch.org/whl/cpu", credentials=None) | ||
], | ||
as_tree=False, | ||
) | ||
|
||
assert plist == [ | ||
"pkg:pypi/[email protected]", | ||
"pkg:pypi/[email protected]", | ||
"pkg:pypi/[email protected]", | ||
"pkg:pypi/[email protected]", | ||
"pkg:pypi/[email protected]", | ||
"pkg:pypi/[email protected]", | ||
"pkg:pypi/[email protected]%2Bcpu", | ||
"pkg:pypi/[email protected]", | ||
] | ||
|
||
|
||
@pytest.mark.online | ||
def test_without_supported_wheels(): | ||
req = Requirement("autobahn==22.3.2") | ||
|