Created
August 5, 2021 04:46
-
-
Save malfet/932311d0e7321cfdeed9e814a759b84e to your computer and use it in GitHub Desktop.
Ugly script that removes python_abi dep from conda packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from conda_build.convert import extract_temporary_directory, create_target_archive | |
import shutil | |
import os | |
import sys | |
def remove_line_with_pattern(fname, pattern): | |
with open(fname) as f: | |
lines = f.read().split('\n') | |
del_idx = [] | |
for idx, line in enumerate(lines): | |
if pattern in line: | |
del_idx.insert(0, idx) | |
for idx in del_idx: | |
del lines[idx] | |
with open(fname, "w") as f: | |
f.write("\n".join(lines)) | |
def remove_abi(file_path): | |
temp_dir = extract_temporary_directory(file_path) | |
remove_line_with_pattern(os.path.join(temp_dir, "info/recipe/meta.yaml"), "python_abi") | |
remove_line_with_pattern(os.path.join(temp_dir, "info/index.json"), "python_abi") | |
create_target_archive(file_path, temp_dir, os.path.dirname(file_path), "noabi") | |
shutil.rmtree(temp_dir) | |
if __name__ == "__main__": | |
remove_abi(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment