Skip to content

Commit c8a0211

Browse files
authored
Merge pull request #47 from trishullab/usr/amit9oct/install-script-fix
Fixed build script; updated pydantic; fixed install race conditions
2 parents 6990366 + 4e4e0c8 commit c8a0211

File tree

3 files changed

+38
-30
lines changed

3 files changed

+38
-30
lines changed

.github/workflows/github-build-actions.yaml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ jobs:
4141
- name: Install package
4242
run: pip install dist/*.whl --break-system-packages
4343

44+
- name: Install Lean (elan) and prepare Lean REPL
45+
shell: bash
46+
run: |
47+
install-lean-repl
48+
source $HOME/.elan/env
49+
50+
- name: Build Lean REPL for itp-interface
51+
shell: bash
52+
run: |
53+
source $HOME/.elan/env
54+
install-itp-interface
55+
4456
- name: Check and Init opam version
4557
run: |
4658
opam --version
@@ -54,24 +66,6 @@ jobs:
5466
opam repo add coq-released https://coq.inria.fr/opam/released
5567
opam pin add -y coq-lsp 0.1.8+8.18
5668
57-
- name: Install Lean (elan)
58-
shell: bash
59-
run: |
60-
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y
61-
source $HOME/.elan/env
62-
63-
- name: Prepare Lean REPL
64-
shell: bash
65-
run: |
66-
source $HOME/.elan/env
67-
install-lean-repl
68-
69-
- name: Build Lean REPL for itp-interface
70-
shell: bash
71-
run: |
72-
source $HOME/.elan/env
73-
install-itp-interface
74-
7569
- name: List repository files (debug step)
7670
run: find . -type f
7771

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ requires = [
55
build-backend = "hatchling.build"
66
[project]
77
name = "itp_interface"
8-
version = "1.1.8"
8+
version = "1.1.9"
99
authors = [
1010
{ name="Amitayush Thakur", email="[email protected]" },
1111
]
@@ -26,7 +26,7 @@ dependencies = [
2626
"sexpdata==1.0.0",
2727
"pampy==0.3.0",
2828
"ray==2.36.0",
29-
"pydantic==1.10.13",
29+
"pydantic>=2.10.6",
3030
"faiss-cpu>=1.6.1",
3131
"filelock==3.12.4",
3232
"regex==2023.10.3",

src/itp_interface/main/install.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import os
2+
import random
3+
import string
24

35
file_path = os.path.abspath(__file__)
6+
def generate_random_string(length, allowed_chars = None):
7+
if allowed_chars is None:
8+
allowed_chars = string.ascii_letters + string.digits
9+
return ''.join(random.choice(allowed_chars) for _ in range(length))
10+
411
def install_itp_interface():
512
print("Installing itp_interface")
613
itp_dir = os.path.dirname(os.path.dirname(file_path))
@@ -62,27 +69,34 @@ def install_lean_repl():
6269
else:
6370
print("Installing .elan")
6471
elan_url = "https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh"
65-
os.system(f"curl -sSL {elan_url} | sh")
72+
os.system(f"curl -sSL {elan_url} -sSf | sh -s -- -y")
6673
print("[OK] .elan installed")
6774
lean_repo = "leanprover/lean4"
6875
# Create a temporary script to run
69-
shell_code = f"""
70-
source $HOME/.elan/env
76+
shell_code = f"""source $HOME/.elan/env
7177
echo "Installing Lean 4 ({lean_repo}:{lean_version})..."
7278
elan toolchain install {lean_repo}:{lean_version}
7379
elan override set {lean_repo}:{lean_version}
7480
echo "Installed Lean 4 ({lean_repo}:{lean_version}) successfully!"
75-
export PATH=$PATH:$HOME/.elan/bin
76-
"""
81+
export PATH=$PATH:$HOME/.elan/bin"""
7782
random_string = os.urandom(8).hex()
78-
with open(f"/tmp/{random_string}.sh", "w") as f:
83+
number = random.randint(1, 10)
84+
lens = [random.randint(1, 10) for _ in range(number)]
85+
rand_dirnames = [generate_random_string(l) for l in lens]
86+
random_path = "/".join(rand_dirnames)
87+
os.makedirs(f"/tmp/{random_path}", exist_ok=True)
88+
random_sh_path = f"/tmp/{random_path}/{random_string}.sh"
89+
print(f"Writing the script to {random_sh_path}")
90+
with open(random_sh_path, "w") as f:
7991
f.write(shell_code)
80-
os.system(f"chmod +x /tmp/{random_string}.sh")
92+
os.system(f"chmod +x {random_sh_path}")
8193
print("Running the script")
82-
os.system(f"bash /tmp/{random_string}.sh")
94+
os.system(f"bash {random_sh_path}")
8395
print("Removing the script")
84-
os.system(f"rm /tmp/{random_string}.sh")
85-
assert os.system("lean --version") == 0, "Lean 4 is not installed aborting"
96+
os.system(f"rm {random_sh_path}")
97+
os.system(f"rmdir /tmp/{random_path}")
98+
os.system("ls -l $HOME/.elan/bin")
99+
assert os.system("export PATH=$PATH:$HOME/.elan/bin && lean --version") == 0, "Lean 4 is not installed aborting"
86100
print("[OK] Lean 4 installed successfully")
87101
print("NOTE: Please run `install-itp-interface` to finish the installation")
88102

0 commit comments

Comments
 (0)