Skip to content

Commit

Permalink
build: add local patching support to our external dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mbouron committed Mar 4, 2024
1 parent cc0e1bb commit e37daa2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,15 @@ def _download_extract(args, dep_item):
assert _file_chk(dst_path, chksum)

# Extract
extracted = False
if tarfile.is_tarfile(dst_path):
with tarfile.open(dst_path) as tar:
dirs = {f.name for f in tar.getmembers() if f.isdir()}
extract_dir = op.join(dst_base, dst_dir or _guess_base_dir(dirs))
if not op.exists(extract_dir):
logging.info("extracting %s", dst_file)
tar.extractall(op.join(dst_base, dst_dir))
extracted = True

elif zipfile.is_zipfile(dst_path):
with zipfile.ZipFile(dst_path) as zip_:
Expand All @@ -332,9 +334,17 @@ def _download_extract(args, dep_item):
if not op.exists(extract_dir):
logging.info("extracting %s", dst_file)
zip_.extractall(op.join(dst_base, dst_dir))
extracted = True
else:
assert False

# Patch
if extracted:
patch_basedir = op.join(_ROOTDIR, "patches", name)
for patch in dep.get("patches", []):
patch_path = op.join(patch_basedir, patch)
run(["patch", "-p1", "-i", patch_path], cwd=extract_dir)

# Remove previous link if needed
target = op.join(dst_base, name)
rel_extract_dir = op.basename(extract_dir)
Expand Down

0 comments on commit e37daa2

Please sign in to comment.