Skip to content

Commit

Permalink
Workaround symlinks on Windows better (hopefully)
Browse files Browse the repository at this point in the history
Signed-off-by: Vasily Litvinov <vasilij.n.litvinov@intel.com>
  • Loading branch information
vnlitvinov committed Dec 7, 2020
1 parent 96818d7 commit 9449f8f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
From fdeefcf7374a5ff1dd3026a607b08efeb0b69b9b Mon Sep 17 00:00:00 2001
From d2c6fcdc5c5dd2b43c62309b0ab4a02b2cffb786 Mon Sep 17 00:00:00 2001
From: Vasilij Litvinov <vasilij.n.litvinov@intel.com>
Date: Fri, 20 Nov 2020 15:32:19 +0300
Subject: [PATCH 09/12] Convert symlinks to junctions on Windows before
building

Signed-off-by: Vasilij Litvinov <vasilij.n.litvinov@intel.com>
---
python/setup.py | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
python/setup.py | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)

diff --git a/python/setup.py b/python/setup.py
index 024657039..7a225f72d 100644
index 024657039..1e8ae41f7 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -225,6 +225,41 @@ def download_pickle5(pickle5_dir):
@@ -225,6 +225,45 @@ def download_pickle5(pickle5_dir):
finally:
wzf.close()

Expand All @@ -26,11 +26,8 @@ index 024657039..7a225f72d 100644
+ root_dir = os.path.dirname(__file__)
+ for link, default in _LINKS.items():
+ path = os.path.join(root_dir, link)
+ if os.path.exists(os.path.join(path, '__init__.py')):
+ print('"{}" does not need workarounds, skipping'.format(link))
+ continue
+ try:
+ out = subprocess.check_output('DIR /A:L /B', shell=True, cwd=os.path.dirname(path))
+ out = subprocess.check_output('DIR /A:LD /B', shell=True, cwd=os.path.dirname(path))
+ except subprocess.CalledProcessError:
+ out = b''
+ if os.path.basename(path) in out.decode('utf8').splitlines():
Expand All @@ -43,7 +40,14 @@ index 024657039..7a225f72d 100644
+ os.unlink(path)
+ elif os.path.isdir(path):
+ target = default
+ os.rmdir(path)
+ try:
+ # unlink() works on links as well as on regular files,
+ # and links to directories are considered directories now
+ os.unlink(path)
+ except OSError as err:
+ if err.errno != errno.EIO:
+ raise
+ os.rmdir(path)
+ else:
+ raise ValueError('Unexpected type of entry: "{}"'.format(path))
+ target = os.path.abspath(os.path.join(os.path.dirname(path), target))
Expand All @@ -55,7 +59,7 @@ index 024657039..7a225f72d 100644

def build(build_python, build_java):
if tuple(sys.version_info[:2]) not in SUPPORTED_PYTHONS:
@@ -243,6 +278,7 @@ def build(build_python, build_java):
@@ -243,6 +282,7 @@ def build(build_python, build_java):
bazel_env = dict(os.environ, PYTHON3_BIN_PATH=sys.executable)

if is_native_windows_or_msys():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
From 3f509f32d4c3014486e98aa03405335d611bc8f0 Mon Sep 17 00:00:00 2001
From a198dddb9786a10c2eb2470f68bfe50a21d1565b Mon Sep 17 00:00:00 2001
From: Vasilij Litvinov <vasilij.n.litvinov@intel.com>
Date: Mon, 23 Nov 2020 13:14:24 +0300
Subject: [PATCH 10/12] Add workaround for os.path.isdir on Windows

Signed-off-by: Vasilij Litvinov <vasilij.n.litvinov@intel.com>
---
python/setup.py | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
python/setup.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/python/setup.py b/python/setup.py
index 7a225f72d..862e6ae94 100644
index 1e8ae41f7..3ad34870a 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -225,6 +225,24 @@ def download_pickle5(pickle5_dir):
Expand Down Expand Up @@ -37,15 +37,7 @@ index 7a225f72d..862e6ae94 100644
def replace_symlinks_with_junctions():
_LINKS = {
r'ray\new_dashboard': '../../dashboard',
@@ -235,7 +253,6 @@ def replace_symlinks_with_junctions():
for link, default in _LINKS.items():
path = os.path.join(root_dir, link)
if os.path.exists(os.path.join(path, '__init__.py')):
- print('"{}" does not need workarounds, skipping'.format(link))
continue
try:
out = subprocess.check_output('DIR /A:L /B', shell=True, cwd=os.path.dirname(path))
@@ -259,6 +276,7 @@ def replace_symlinks_with_junctions():
@@ -263,6 +281,7 @@ def replace_symlinks_with_junctions():
subprocess.check_call('MKLINK /J "{}" "{}"'.format(os.path.basename(link), target), shell=True, cwd=os.path.dirname(path))

if is_native_windows_or_msys():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 58db1bb52d2fa598d1be413ab0324a1c6cfa4960 Mon Sep 17 00:00:00 2001
From 479036d8d6e4ab66599f970e2743c4f6e04768c5 Mon Sep 17 00:00:00 2001
From: Vasilij Litvinov <vasilij.n.litvinov@intel.com>
Date: Tue, 24 Nov 2020 00:20:34 +0300
Subject: [PATCH 11/12] Include <process.h> for getpid() explicitly on Windows
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 3d53c6d31d05f1c098a99f0ff29f9dcb3d70c7b1 Mon Sep 17 00:00:00 2001
From f7b0ac4a4e8decb49ddc54ba8666d986091d2829 Mon Sep 17 00:00:00 2001
From: Vasily Litvinov <vasilij.n.litvinov@intel.com>
Date: Fri, 4 Dec 2020 12:49:34 +0300
Subject: [PATCH 12/12] Empty install requirements - installed by conda build
Expand All @@ -9,7 +9,7 @@ Signed-off-by: Vasily Litvinov <vasilij.n.litvinov@intel.com>
1 file changed, 2 insertions(+), 26 deletions(-)

diff --git a/python/setup.py b/python/setup.py
index 862e6ae94..8a63bfac2 100644
index 3ad34870a..bd7762372 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -128,31 +128,7 @@ extras["all"] = list(set(chain.from_iterable(extras.values())))
Expand Down Expand Up @@ -45,7 +45,7 @@ index 862e6ae94..8a63bfac2 100644


def is_native_windows_or_msys():
@@ -517,7 +493,7 @@ setuptools.setup(
@@ -522,7 +498,7 @@ setuptools.setup(
# The BinaryDistribution argument triggers build_ext.
distclass=BinaryDistribution,
install_requires=install_requires,
Expand Down

0 comments on commit 9449f8f

Please sign in to comment.