Skip to content

Commit

Permalink
Merge branch 'master' into venv-location-rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
techalchemy authored Nov 2, 2018
2 parents 8c65f79 + 7c89a46 commit a757273
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
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)))
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()

0 comments on commit a757273

Please sign in to comment.