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
33 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 |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
import packvers | ||
import pytest | ||
from commoncode.system import on_mac | ||
from commoncode.testcase import FileDrivenTesting | ||
from packvers.requirements import Requirement | ||
|
||
|
@@ -26,6 +27,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 +132,35 @@ def test_get_resolved_dependencies_with_tilde_requirement_using_json_api(): | |
] | ||
|
||
|
||
@pytest.mark.online | ||
@pytest.mark.skipif(on_mac, reason="torch is only available for linux and windows.") | ||
def test_get_resolved_dependencies_for_version_containing_local_version_identifier(): | ||
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") | ||
|