@@ -89,6 +89,16 @@ def traverse(f, data):
89
89
def gq (tmp , data ):
90
90
return traverse (mk_tmplt (tmp ), data )
91
91
92
+ class ZipFileWithPermissions (zipfile .ZipFile ):
93
+ def _extract_member (self , member , targetpath , pwd ):
94
+ if not isinstance (member , zipfile .ZipInfo ):
95
+ member = self .getinfo (member )
96
+ targetpath = super ()._extract_member (member , targetpath , pwd )
97
+
98
+ attr = member .external_attr >> 16
99
+ if attr != 0 :
100
+ os .chmod (targetpath , attr )
101
+ return targetpath
92
102
93
103
def get_binary ():
94
104
from purescripto .version import __blueprint_version__
@@ -100,30 +110,29 @@ def get_binary():
100
110
.format (max_fit_tag )).json ()
101
111
print ('Binaries downloaded.' )
102
112
plat_name = get_platform ()
103
-
104
113
matcher = re .compile ('\S+' + re .escape (plat_name ))
105
114
tmplt = {'browser_download_url' : matcher }
106
115
try :
107
116
each = next (gq (tmplt , data ))
108
117
except StopIteration :
109
118
import sys
110
119
print (
111
- "It seems that binaries for your platform is not available.\n "
120
+ f "It seems that binaries for your platform (which name is $ { plat_name } ) is not available.\n "
112
121
"Following way must work, but can be quite time-consuming:\n "
113
122
"Firstly, Install Haskell Stack Build Tool: https://docs.haskellstack.org/en/stable/README/\n "
114
123
"Second, Clone https://github.com/purescript-python/purescript-python, then do `stack install .`"
115
124
)
116
125
sys .exit (1 )
117
126
118
127
url = each ['browser_download_url' ]
119
- zf = zipfile . ZipFile (io .BytesIO (requests .get (url ).content ))
128
+ zf = ZipFileWithPermissions (io .BytesIO (requests .get (url ).content ))
120
129
exe = "pspy-blueprint"
121
130
if 'win' in url :
122
131
exe += '.exe'
123
132
124
- out_path .mkdir (exist_ok = True , parents = True )
133
+ out_path .mkdir (exist_ok = True , parents = True , mode = 0o777 )
125
134
zf .extract (exe , path = str (out_path ))
126
135
make_executable (str (out_path / exe ))
127
136
128
-
129
- get_binary ()
137
+ if __name__ == "__main__" :
138
+ get_binary ()
0 commit comments