File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 38
38
.PHONY : package
39
39
package : c_lib
40
40
python -m build --no-isolation
41
+ python ./update_sdist.py
41
42
twine check dist/*
Original file line number Diff line number Diff line change
1
+ """
2
+ update_sdist.py
3
+
4
+ Run this script to remove compiled artifacts from source distribution tarballs.
5
+ """
6
+ from pathlib import Path
7
+ from tarfile import open as tar_open
8
+ from tempfile import TemporaryDirectory
9
+
10
+ REMOVE_FILES = frozenset (['ada_url/ada.o' ])
11
+
12
+
13
+ def update_archive (file_path , removals ):
14
+ with TemporaryDirectory () as temp_dir :
15
+ with tar_open (file_path , mode = 'r:gz' ) as tf :
16
+ tf .extractall (temp_dir )
17
+
18
+ dir_path = next (Path (temp_dir ).glob ('ada_url-*' ))
19
+ all_files = []
20
+ for file_path in Path (temp_dir ).glob ('**/*' ):
21
+ if file_path .is_dir ():
22
+ continue
23
+ if str (file_path .relative_to (dir_path )) in REMOVE_FILES :
24
+ continue
25
+ all_files .append (file_path )
26
+
27
+ with tar_open (file_path , mode = 'w:gz' ) as tf :
28
+ for file_path in all_files :
29
+ arcname = file_path .relative_to (temp_dir )
30
+ print (arcname )
31
+ tf .add (file_path , arcname = arcname )
32
+
33
+
34
+ if __name__ == '__main__' :
35
+ for file_path in Path ().glob ('dist/*.tar.gz' ):
36
+ update_archive (file_path , REMOVE_FILES )
37
+ print (f'Updated { file_path } ' )
You can’t perform that action at this time.
0 commit comments