File tree 1 file changed +22
-0
lines changed 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 3
3
import argparse
4
4
import logging
5
5
import os
6
+ import io
6
7
import contextlib
7
8
import pytoml
8
9
import shutil
9
10
import errno
10
11
import tempfile
12
+ import zipfile
11
13
12
14
from .envbuild import BuildEnvironment
13
15
from .wrappers import Pep517HookCaller
@@ -68,6 +70,26 @@ def build_meta(source_dir, dest=None):
68
70
_prep_meta (hooks , env , dest )
69
71
70
72
73
+ def dir_to_zipfile (root ):
74
+ buffer = io .BytesIO ()
75
+ zip_file = zipfile .ZipFile (buffer , 'w' )
76
+ for root , dirs , files in os .walk (root ):
77
+ for path in dirs :
78
+ fs_path = os .path .join (root , path )
79
+ rel_path = os .path .relpath (fs_path , root )
80
+ zip_file .writestr (rel_path + '/' , '' )
81
+ for path in files :
82
+ fs_path = os .path .join (root , path )
83
+ rel_path = os .path .relpath (fs_path , root )
84
+ zip_file .write (fs_path , rel_path )
85
+
86
+
87
+ def build_meta_as_zip (source_dir = '.' ):
88
+ with tempdir () as out_dir :
89
+ build_meta (source_dir , out_dir )
90
+ return dir_to_zipfile (out_dir )
91
+
92
+
71
93
parser = argparse .ArgumentParser ()
72
94
parser .add_argument (
73
95
'source_dir' ,
You can’t perform that action at this time.
0 commit comments