Commit 6c0730f2 authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

add fix for Windows read-only access error

1 merge request!1release v0.1.0.0
Pipeline #42915 failed with stage
in 3 minutes and 4 seconds
Showing with 10 additions and 1 deletion
+10 -1
import sys import sys
import os import os
import subprocess import subprocess
import stat
import shutil import shutil
from pybind11.setup_helpers import Pybind11Extension, build_ext from pybind11.setup_helpers import Pybind11Extension, build_ext
...@@ -21,6 +22,14 @@ def git_clone(*args): ...@@ -21,6 +22,14 @@ def git_clone(*args):
raise RuntimeError(r.stderr.decode('utf-8')) raise RuntimeError(r.stderr.decode('utf-8'))
def remove_readonly(func, path, exc):
# fix for Windows: change access permission for read-only files
# so that they can be removed
if not os.access(path, os.W_OK):
os.chmod(path, stat.S_IWUSR)
func(path)
deps = [ deps = [
('xtl', '0.7.0', ('xtl', '0.7.0',
'https://github.com/xtensor-stack/xtl'), 'https://github.com/xtensor-stack/xtl'),
...@@ -38,7 +47,7 @@ for dep, version, url in deps: ...@@ -38,7 +47,7 @@ for dep, version, url in deps:
# remove existing dependency if it exists # remove existing dependency if it exists
dir_path = os.path.join(os.getcwd(), 'deps', dep) dir_path = os.path.join(os.getcwd(), 'deps', dep)
if os.path.exists(dir_path) and os.path.isdir(dir_path): if os.path.exists(dir_path) and os.path.isdir(dir_path):
shutil.rmtree(dir_path) shutil.rmtree(dir_path, onerror=remove_readonly)
print(f"removed existing {dep}") print(f"removed existing {dep}")
# fetch dependency # fetch dependency
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment