From be527d4612327091e9607fbe79d2f437e862ff2a Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Thu, 2 Jan 2025 20:43:18 -0800 Subject: [PATCH] Replace whitespace in `file://` with `%20` (#214) * Replace whitespace in `file://` with `%20` Closes https://github.com/basnijholt/unidep/issues/211 Thanks to @ichard26 in https://github.com/pypa/pip/issues/13139#issuecomment-2568620587 cc @dustin-dawind * Fix editable install for whl and zip * Fix typo in test_split_path_and_extras * Use manual replace instead of quote * use `urllib.request.pathname2url` Co-authored-by: Richard Si * fix import of urllib * fix double `file:` * Add missing // * Just use `.replace(" ", "%20")` again --------- Co-authored-by: Richard Si --- tests/test_utils.py | 2 +- unidep/_cli.py | 6 +++++- unidep/_setuptools_integration.py | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 0e4042c0..668a9fe7 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -278,7 +278,7 @@ def test_extract_matching_platforms() -> None: extract_matching_platforms(incorrect_platform) -def testsplit_path_and_extras() -> None: +def test_split_path_and_extras() -> None: # parse_with_extras s = "any/path[something, another]" path, extras = split_path_and_extras(s) diff --git a/unidep/_cli.py b/unidep/_cli.py index 43612ac7..1db12af7 100755 --- a/unidep/_cli.py +++ b/unidep/_cli.py @@ -850,7 +850,11 @@ def _pip_install_local( relative_prefix = ".\\" if os.name == "nt" else "./" folder = f"{relative_prefix}{folder}" # noqa: PLW2901 - if editable: + if ( + editable + and not str(folder).endswith(".whl") + and not str(folder).endswith(".zip") + ): pip_command.extend(["-e", str(folder)]) else: pip_command.append(str(folder)) diff --git a/unidep/_setuptools_integration.py b/unidep/_setuptools_integration.py index 51c32e8d..97923a9f 100755 --- a/unidep/_setuptools_integration.py +++ b/unidep/_setuptools_integration.py @@ -151,7 +151,10 @@ def get_python_dependencies( for paths in local_dependencies.values(): for path in paths: name = _package_name_from_path(path) - dependencies.append(f"{name} @ file://{path.as_posix()}") + # TODO: Consider doing this properly using pathname2url # noqa: FIX002 + # https://github.com/basnijholt/unidep/pull/214#issuecomment-2568663364 + uri = path.as_posix().replace(" ", "%20") + dependencies.append(f"{name} @ file://{uri}") return Dependencies(dependencies=dependencies, extras=extras)