Support forward slash on windows (#4563)

Support forward slash on windows
This commit is contained in:
Pradyun S. Gedam 2017-06-27 02:37:49 +05:30 committed by Paul Moore
parent 21be153044
commit 29bab5adbd
3 changed files with 22 additions and 3 deletions

1
news/4563.feature Normal file
View File

@ -0,0 +1 @@
Local Packages can now be referenced using forward slashes on Windows.

View File

@ -194,9 +194,12 @@ class InstallRequirement(object):
link = Link(name)
else:
p, extras = _strip_extras(path)
if (os.path.isdir(p) and
(os.path.sep in name or name.startswith('.'))):
looks_like_dir = os.path.isdir(p) and (
os.path.sep in name or
(os.path.altsep is not None and os.path.altsep in name) or
name.startswith('.')
)
if looks_like_dir:
if not is_installable_dir(p):
raise InstallationError(
"Directory %r is not installable. File 'setup.py' "

View File

@ -26,3 +26,18 @@ class TestInstallRequirementBuildDirectory(object):
assert os.path.dirname(tmp_build_dir) == os.path.dirname(tmp_dir)
os.rmdir(tmp_dir)
assert not os.path.exists(tmp_dir)
def test_forward_slash_results_in_a_link(self, tmpdir):
install_dir = tmpdir / "foo" / "bar"
# Just create a file for letting the logic work
setup_py_path = install_dir / "setup.py"
os.makedirs(str(install_dir))
with open(setup_py_path, 'w') as f:
f.write('')
requirement = InstallRequirement.from_line(
str(install_dir).replace(os.sep, os.altsep or os.sep)
)
assert requirement.link is not None