2121import json
2222import sys
2323import os
24+ import wisepy2
2425
2526_TEMPLATE = {
2627 CKey .CoreFnDir : CValue .CoreFnDir ,
3031}
3132
3233
34+ def warn (s : str ):
35+ print (wisepy2 .Yellow (s ))
36+
3337def mk_ps_blueprint_cmd (pspy_blueprint , python_pack_name : str , entry : str ,
3438 ffi_deps_path : str ):
3539 return [
@@ -49,13 +53,32 @@ def solve_ffi(conf: CValue, update_mirror: bool) -> Iterable[str]:
4953
5054 if update_mirror :
5155 import git
56+ if not mirror_repo .exists ():
57+ warn ("The mirror {} not found at {}" .format (mirror_name , str (mirror_repo )))
58+ if mirror_name == 'default' :
59+ warn ("We're going to clone the mirror"
60+ "https://github.com/purescript-python/purescript-python-ffi-index,\n "
61+ "to ~/.pspy/mirrors/default." )
62+ git .Repo .clone_from (r"https://github.com/purescript-python/purescript-python-ffi-index" , str (mirror_repo ))
63+ else :
64+ raise IOError ("Mirror not found" )
5265 git .Repo (str (mirror_repo )).git .pull ("origin" )
5366
5467 mirror_entry = mirror_repo / "entry.py"
5568
5669 if not mirror_entry .exists ():
57- raise IOError ("Mirror {} not found in {}" .format (
58- mirror_name , mirror_entry .parent ))
70+ if mirror_name != 'default' :
71+ raise IOError ("Mirror {} not found in {}" .format (
72+ mirror_name , mirror_entry .parent ))
73+ else :
74+ import git
75+ warn ("The mirror {} not found at {}" .format (mirror_name , str (mirror_repo )))
76+ if mirror_name == 'default' :
77+ warn ("We're going to clone the mirror"
78+ "https://github.com/purescript-python/purescript-python-ffi-index,\n "
79+ "to ~/.pspy/mirrors/default." )
80+ git .Repo .clone_from (r"https://github.com/purescript-python/purescript-python-ffi-index" ,
81+ str (mirror_repo ))
5982
6083 mirror_mod = import_from_path (mirror_name , str (mirror_entry ))
6184 solve_github_repo_url = mirror_mod .solve
@@ -85,10 +108,10 @@ def solve_ffi(conf: CValue, update_mirror: bool) -> Iterable[str]:
85108 yield solve_github_repo_url (package_name , version )
86109
87110
88- def build (run : bool = False ,
89- version : bool = False ,
90- init : bool = False ,
91- update : bool = False ):
111+ def pspy (run : bool = False ,
112+ version : bool = False ,
113+ init : bool = False ,
114+ update : bool = False ):
92115 """PureScript Python compiler"""
93116 path = Path ().absolute ()
94117 pure_py_conf = path / "pure-py.json"
0 commit comments