Skip to content

Fix editable installation from relative paths on Windows #6416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from urllib.parse import unquote, urljoin

from pipenv.utils.constants import VCS_LIST
from pipenv.utils.dependencies import extract_vcs_url
from pipenv.utils.dependencies import extract_vcs_url, normalize_editable_path_for_pip
from pipenv.vendor.tomlkit.items import SingleKey, Table

try:
Expand Down Expand Up @@ -1187,9 +1187,14 @@ def generate_package_pipfile_entry(
if extras:
entry["extras"] = list(extras)
if path_specifier:
entry["file"] = unquote(str(path_specifier))
if pip_line.startswith("-e"):
entry["editable"] = True
editable = pip_line.startswith("-e")
entry["file"] = unquote(
normalize_editable_path_for_pip(path_specifier)
if editable
else str(path_specifier)
)
if editable:
entry["editable"] = editable
elif vcs_specifier:
for vcs in VCS_LIST:
if vcs in package.link.scheme:
Expand Down
11 changes: 9 additions & 2 deletions pipenv/routines/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
expansive_install_req_from_line,
get_lockfile_section_using_pipfile_category,
install_req_from_pipfile,
normalize_editable_path_for_pip,
)
from pipenv.utils.indexes import get_source_list
from pipenv.utils.internet import download_file, is_valid_url
Expand Down Expand Up @@ -44,7 +45,9 @@ def handle_new_packages(
new_packages = []
if packages or editable_packages:

pkg_list = packages + [f"-e {pkg}" for pkg in editable_packages]
pkg_list = packages + [
f"-e {normalize_editable_path_for_pip(pkg)}" for pkg in editable_packages
]

for pkg_line in pkg_list:
console.print(f"Installing {pkg_line}...", style="bold green")
Expand Down Expand Up @@ -262,7 +265,11 @@ def do_install(
)
warnings.filterwarnings("ignore", category=ResourceWarning)
packages = packages if packages else []
editable_packages = editable_packages if editable_packages else []
editable_packages = (
[normalize_editable_path_for_pip(p) for p in editable_packages]
if editable_packages
else []
)
package_args = [p for p in packages if p] + [p for p in editable_packages if p]
new_packages = []
if dev and not pipfile_categories:
Expand Down
9 changes: 8 additions & 1 deletion pipenv/utils/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,13 @@ def expansive_install_req_from_line(
return install_req, name


def normalize_editable_path_for_pip(path_str):
"""Normalize an editable package path for pip."""
# Windows paths need to be converted to POSIX paths otherwise path
# separators (back slashes) are interpreted as escape characters.
return path_str.replace(os.path.sep, "/")


def file_path_from_pipfile(path_str, pipfile_entry):
"""Creates an installable file path from a pipfile entry.
Handles local and remote paths, files and directories;
Expand All @@ -1082,7 +1089,7 @@ def file_path_from_pipfile(path_str, pipfile_entry):
if pipfile_entry.get("extras"):
req_str = f"{req_str}[{','.join(pipfile_entry['extras'])}]"
if pipfile_entry.get("editable", False):
req_str = f"-e {req_str}"
req_str = f"-e {normalize_editable_path_for_pip(req_str)}"

return req_str

Expand Down