Skip to content
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
1 change: 1 addition & 0 deletions news/6381.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an issue with installing local packages that have spaces in their path names.
5 changes: 5 additions & 0 deletions pipenv/utils/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,11 @@ def expansive_install_req_from_line(
"""
name = None
pip_line = pip_line.strip("'").lstrip(" ")

# Handle paths with escaped spaces
if os.path.exists(os.path.expanduser(pip_line.replace("\\ ", " "))):
pip_line = pip_line.replace("\\ ", " ")

for new_req_symbol in ("@ ", " @ "): # Check for new style pip lines
if new_req_symbol in pip_line:
pip_line_parts = pip_line.split(new_req_symbol, 1)
Expand Down
60 changes: 60 additions & 0 deletions tests/integration/test_install_paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import os
from pathlib import Path

import pytest


@pytest.mark.install
@pytest.mark.needs_internet
@pytest.mark.skipif(
os.name == "nt",
reason="This test is not for Windows",
)
def test_install_path_with_spaces(pipenv_instance_pypi):
with pipenv_instance_pypi() as p:
# Create a test directory with spaces in the name
test_dir = Path(p.path) / "test dir with spaces"
test_dir.mkdir()

# Create a simple package in the directory with spaces
package_dir = test_dir / "simple_package"
package_dir.mkdir()

# Create a simple setup.py file
with open(package_dir / "setup.py", "w") as f:
f.write("""
from setuptools import setup

setup(
name="simple-package",
version="0.1.0",
)
""")

# Create the package module
with open(package_dir / "simple_package.py", "w") as f:
f.write("""
def hello():
return "Hello from simple package!"
""")

# Install the package using a path with spaces
# Use both escaped spaces and quoted path to test both scenarios
c = p.pipenv(f'install "{package_dir}"')
assert c.returncode == 0

# Verify the package was installed correctly
c = p.pipenv('run python -c "import simple_package; print(simple_package.hello())"')
assert c.returncode == 0
assert "Hello from simple package!" in c.stdout

# Test with escaped spaces
p.pipenv("uninstall simple-package")
escaped_path = package_dir.as_posix().replace(" ", "\\ ")
c = p.pipenv(f'install {escaped_path}')
assert c.returncode == 0

# Verify the package was installed correctly
c = p.pipenv('run python -c "import simple_package; print(simple_package.hello())"')
assert c.returncode == 0
assert "Hello from simple package!" in c.stdout