Skip to content
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

Proper case windows #3105

Merged
merged 5 commits into from
Nov 2, 2018
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/3104.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the path casing issue that makes `pipenv clean` fail on Windows
13 changes: 9 additions & 4 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import re
import sys
import glob
import base64
import itertools
import fnmatch
Expand Down Expand Up @@ -53,14 +54,18 @@ def _normalized(p):
if p is None:
return None
loc = vistir.compat.Path(p)
if loc.is_absolute():
return normalize_drive(str(loc))
else:
if not loc.is_absolute():
try:
loc = loc.resolve()
except OSError:
loc = loc.absolute()
return normalize_drive(str(loc))
# Recase the path properly on Windows. From https://stackoverflow.com/a/35229734/5043728
if os.name == 'nt':
matches = glob.glob(re.sub(r'([^:/\\])(?=[/\\]|$)', r'[\1]', str(loc)))
frostming marked this conversation as resolved.
Show resolved Hide resolved
path_str = matches and matches[0] or str(loc)
else:
path_str = str(loc)
return normalize_drive(path_str)


DEFAULT_NEWLINES = u"\n"
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/test_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,16 @@ def test_local_path_windows_forward_slash(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi, chdir=True) as p:
c = p.pipenv('install "{0}"'.format(whl.as_posix()))
assert c.return_code == 0


@pytest.mark.cli
def test_pipenv_clean_windows(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi, chdir=True) as p:
c = p.pipenv('install requests')
assert c.return_code == 0
c = p.pipenv('run pip install click')
assert c.return_code == 0

c = p.pipenv('clean --dry-run')
assert c.return_code == 0
assert 'click' in c.out.strip()