create a conda-forge archive creator tool
import os
import tarfile
import json
+import hashlib
from glob import glob
-def main():
+def tar_filter(tar_info: tarfile.TarInfo):
+ if 'tests' in tar_info.name:
+ return None
+ else:
+ return tar_info
+
+def main():
with open('lerna.json') as lerna_json:
version = json.load(lerna_json)['version']
licenses = glob('LICENSE*')
to_archive = ['packages', 'package.json', 'README.rst'] + licenses
+ to_ignore = glob('*tests*')
output_filename = 'v{}.tar.gz'.format(version)
+ try:
+ os.remove(output_filename)
+ except FileNotFoundError:
+ pass
+
with tarfile.open(output_filename, "w:gz") as tar:
for path in to_archive:
- tar.add(path, arcname=os.path.basename(path))
+ tar.add(path, arcname=os.path.basename(path), filter=tar_filter)
+
+ with open(output_filename, "rb") as created_tar:
+ hash_result = hashlib.sha256(created_tar.read()).hexdigest()
+
+ print(hash_result)
if __name__ == "__main__":
