Skip to content

Commit 005f3f3

Browse files
committed
colored warning
1 parent 2598fa4 commit 005f3f3

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

purescripto/configure.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import json
2222
import sys
2323
import os
24+
import wisepy2
2425

2526
_TEMPLATE = {
2627
CKey.CoreFnDir: CValue.CoreFnDir,
@@ -30,6 +31,9 @@
3031
}
3132

3233

34+
def warn(s: str):
35+
print(wisepy2.Yellow(s))
36+
3337
def 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"

purescripto/pspy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from purescripto.configure import build
1+
from purescripto.configure import pspy
22

33

44
def main():
55
import wisepy2
6-
wisepy2.wise(build)()
6+
wisepy2.wise(pspy)()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup
22
from pathlib import Path
33

4-
version = "0.7.4"
4+
version = "0.7.5"
55
with Path('README.md').open() as readme:
66
readme = readme.read()
77

0 commit comments

Comments
 (0)