Skip to content

Commit

Permalink
Replace whitespace in file:// with %20 (#214)
Browse files Browse the repository at this point in the history
* Replace whitespace in `file://` with `%20`

Closes #211

Thanks to @ichard26 in pypa/pip#13139 (comment)

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 <sichard26@gmail.com>

* fix import of urllib

* fix double `file:`

* Add missing //

* Just use `.replace(" ", "%20")` again

---------

Co-authored-by: Richard Si <sichard26@gmail.com>
  • Loading branch information
basnijholt and ichard26 authored Jan 3, 2025
1 parent 3d69198 commit be527d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion unidep/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 4 additions & 1 deletion unidep/_setuptools_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit be527d4

Please sign in to comment.