Commit 69a2f5f2 authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

replace "git clone" by git submodules for dependencies management

because the workaround for the read only mode on the Windows file system
is unstable/inconsistent
1 merge request!1release v0.1.0.0
Pipeline #43937 passed with stage
in 4 minutes and 6 seconds
Showing with 21 additions and 44 deletions
+21 -44
.gitmodules 0 → 100644
[submodule "deps/evalhyd"]
path = deps/evalhyd
url = https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd.git
branch = dev
[submodule "deps/xtl"]
path = deps/xtl
url = https://github.com/xtensor-stack/xtl.git
[submodule "deps/xtensor-python"]
path = deps/xtensor-python
url = https://github.com/xtensor-stack/xtensor-python.git
[submodule "deps/xtensor"]
path = deps/xtensor
url = https://github.com/xtensor-stack/xtensor.git
Subproject commit c7a39afa56f78cc64ea58c0502bdd74de53a0941
Subproject commit 545dd7aa78104052bb8e45c3175efff313d477dc
Subproject commit 6a286681c48c35d3df342f291938f4825b20c0a3
Subproject commit fea39142693fbbc2ef19d75012bc6b46ef0a5f8c
import sys
import os
import subprocess
import stat
import shutil
from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import setup
......@@ -13,52 +10,15 @@ import numpy
with open("evalhyd/version.py", 'r') as fv:
exec(fv.read())
# vendor dependencies (unless told otherwise via environment variable)
def git_clone(*args):
r = subprocess.run(
['git', 'clone', *args, '-c', 'advice.detachedHead=false'],
capture_output=True
)
if r.returncode != 0:
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 = [
('xtl', '0.7.0',
'https://github.com/xtensor-stack/xtl'),
('xtensor', '0.24.0',
'https://github.com/xtensor-stack/xtensor'),
('xtensor-python', '0.26.1',
'https://github.com/xtensor-stack/xtensor-python'),
('evalhyd', 'dev',
'https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd')
]
deps = ['xtl', 'xtensor', 'xtensor-python', 'evalhyd']
deps_blank_path = os.path.join(os.getcwd(), 'deps', '{}', 'include')
deps_include_dirs = []
for dep, version, url in deps:
for dep in deps:
if not os.getenv(f"EVALHYD_PYTHON_VENDOR_{dep.upper().replace('-', '_')}") == 'FALSE':
# remove existing dependency if it exists
dir_path = os.path.join(os.getcwd(), 'deps', dep)
if os.path.exists(dir_path) and os.path.isdir(dir_path):
shutil.rmtree(dir_path, onerror=remove_readonly)
print(f"removed existing {dep}")
# fetch dependency
git_clone(url, f'deps/{dep}', '--branch', version)
print(f"vendored {dep} {version}")
# register dependency headers
deps_include_dirs.append(os.path.join(dir_path, 'include'))
deps_include_dirs.append(deps_blank_path.format(dep))
# configure Python extension
ext_modules = [
......
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