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

[Fix] Windows rez-bind pip #659

Merged
merged 6 commits into from
Jul 20, 2019
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
8 changes: 7 additions & 1 deletion src/rez/bind/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import subprocess
import os.path
import os
import platform


def log(msg):
Expand Down Expand Up @@ -118,7 +119,12 @@ def _run_command(args):
cmd_str = ' '.join(quote(x) for x in args)
log("running: %s" % cmd_str)

p = popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if "Windows" in platform.system():
p = popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True)
else:
p = popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)


stdout, stderr = p.communicate()
return stdout, stderr, p.returncode

Expand Down
8 changes: 7 additions & 1 deletion src/rez/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import sys
import os
import re
import platform


class InstallMode(Enum):
Expand Down Expand Up @@ -246,7 +247,12 @@ def find_pip(pip_version=None, python_version=None):
# check pip version, must be >=19 to support PEP517
try:
pattern = r"pip\s(?P<ver>\d+\.*\d*\.*\d*)"
ver_str = subprocess.check_output([pip_exe, '-V'])

if "Windows" in platform.system():
ver_str = subprocess.check_output('{} -V'.format(pip_exe), shell=True, universal_newlines=True)
else:
ver_str = subprocess.check_output(['{}'.format(pip_exe), '-V'], universal_newlines=True)

match = re.search(pattern, ver_str)
ver = match.group('ver')
pip_major = ver.split('.')[0]
Expand Down
6 changes: 6 additions & 0 deletions src/rez/utils/platform_.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import os.path
import re
import subprocess
from rez.util import which
from rez.utils.system import popen
from rez.utils.data_utils import cached_property
Expand Down Expand Up @@ -496,6 +497,11 @@ def symlink(self, source, link_name):
# http://stackoverflow.com/questions/6260149/os-symlink-support-in-windows
if callable(getattr(os, "symlink", None)):
os.symlink(source, link_name)
elif "Windows-10" in platform.platform():
# Starting with Windows 10 Insiders build 14972, symlinks can be
# created without needing to elevate the console as administrator.
# https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/#joC5tFKhdXs2gGml.97
subprocess.check_output('mklink %s %s' % (link_name, source), shell=True)
else:
import ctypes
csl = ctypes.windll.kernel32.CreateSymbolicLinkW
Expand Down