Skip to content

Commit 7ba23cc

Browse files
committed
add new devcontainer and install scripts
1 parent e888602 commit 7ba23cc

9 files changed

Lines changed: 135 additions & 87 deletions

File tree

pretext/constants.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,22 +226,27 @@
226226
"project.ptx": Path("project.ptx"),
227227
"codechat_config.yaml": Path("codechat_config.yaml"),
228228
".gitignore": Path(".gitignore"),
229-
".devcontainer.json": Path(".devcontainer.json"),
229+
"devcontainer.json": Path(".devcontainer/devcontainer.json"),
230230
"requirements.txt": Path("requirements.txt"),
231231
"pretext-cli.yml": Path(".github", "workflows", "pretext-cli.yml"),
232-
"add-sage.sh": Path(".github", "scirpts", "add-sage.sh"),
233-
"add-latex.sh": Path(".github", "scirpts", "add-latex.sh"),
232+
"installPretext.sh": Path(".devcontainer", "instalPretext.sh"),
233+
"installPandoc.sh": Path(".devcontainer", "instalPandoc.sh"),
234+
"installLatex.sh": Path(".devcontainer", "instalLatex.sh"),
235+
"installSage.sh": Path(".devcontainer", "installSage.sh"),
234236
}
235237

236238
DEPRECATED_PROJECT_RESOURCES = {
237239
"deploy.yml": Path(".github", "workflows", "deploy.yml"),
238240
"test-build.yml": Path(".github", "workflows", "test-build.yml"),
241+
".devcontainer.json": Path(".devcontainer.json"),
239242
}
240243

241244
GIT_RESOURCES = [
242245
".gitignore",
243246
"pretext-cli.yml",
244-
".devcontainer.json",
245-
"add-sage.sh",
246-
"add-latex.sh",
247+
"devcontainer.json",
248+
"installPretext.sh",
249+
"installPandoc.sh",
250+
"installLatex.sh",
251+
"installSage.sh",
247252
]

pretext/resources/resource_hash_table.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@
8080
"project.ptx": "d00aa86d7b2d0d06d5ce0b70ef784ad23c05a2618b888cd797552c477d4bd8c1",
8181
"codechat_config.yaml": "3bf28a68f3349b02f6a8141f07fcfd789073f5bc5da76672e2d86cd7759cdb6d",
8282
".gitignore": "4a7a09d3441f01b6a9bf658e68d1deff640b6b2cf463af3f5e77c2507600b602",
83-
".devcontainer.json": "a2f8449a67baaa23d4b1db811db100033e96a6f509c8494077a21c8dcc35d046",
83+
"devcontainer.json": "4a53842fe887d0698858abc8300f87adf1bcae225322fa7d17510efc011d75f0",
8484
"pretext-cli.yml": "0ea2df984dcfb76ecfaa9bfde26a0da22c006fca1fafd156ca6c57c75679b907",
85-
"add-sage.sh": "910b916e5b31eaf9e805ba83a8dab8ad0eff8f479d54818309beb6b7db2c7932",
86-
"add-latex.sh": "17ee4e4c2961cca3f5149632442d57d79c290b6330b967c335c3a8ac7d9141b8"
85+
"installPretext.sh": "1326840f5ac6438c9327f6f4dbcaf3c28e2862efc5fdf4034e3187653136ad31",
86+
"installPandoc.sh": "f91ead2ad66fd1caf90144b5b52d8473c7ebac1f02c03945a25484719e4d73d2",
87+
"installLatex.sh": "1326840f5ac6438c9327f6f4dbcaf3c28e2862efc5fdf4034e3187653136ad31",
88+
"installSage.sh": "d42af741c9b0fec43ec2ff3aa90e04f17adbd584e429c74ed988d61597e8d2ad"
8789
}
8890
}

templates/add-latex.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

templates/add-sage.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,17 @@
1313
//
1414
///////////////////////////////////////////////////////////////
1515
{
16-
"name": "PreTeXt-Codespaces",
16+
"image": "mcr.microsoft.com/devcontainers/universal:2",
17+
"features": {},
1718

18-
// The default docker image has just pretext and prefigure installed. No LaTeX and no SageMath. Those can be installed using scripts or by switching to one of the larger images below.:
19-
"image": "oscarlevin/pretext:lite",
20-
21-
// This Docker image includes some LaTeX support, but is still not to large. Note that if you keep your codespace running, it will use up your GitHub free storage quota.
22-
// "image": "oscarlevin/pretext:small",
23-
24-
// If you need to generate sageplots, comment out the above line and uncomment the following line.
25-
//"image": "oscarlevin/pretext:full",
26-
27-
28-
// Add gh cli as a feature (to support codechat)
29-
"features": {
30-
"ghcr.io/devcontainers/features/github-cli:1": {}
31-
},
32-
33-
// Respect the project's designated dependencies
34-
"postCreateCommand": "git config --global --add safe.directory $(pwd) && pip install -r requirements.txt",
35-
36-
// If you need LaTeX support (to build pdfs or to generate latex-images), you can uncomment the next line (and comment out the "postCreateCommand" above.)
37-
// "postCreateCommand": "git config --global --add safe.directory $(pwd) && bash ./.github/scripts/add-latex.sh",
38-
39-
// If you need sageplot support, instead of installing the pretext:full image above, you can uncomment the line below and comment out the line above.
40-
// "postCreateCommand": "git config --global --add safe.directory $(pwd) && bash ./.github/scripts/add-sage.sh",
41-
42-
// For both LaTeX and sageplot support, use this "postCreateCommand":
43-
// "postCreateCommand": "git config --global --add safe.directory $(pwd) && bash ./.github/scripts/add-latex.sh && bash ./.github/scripts/add-sage.sh",
19+
// Comment or uncomment lines below if you don't or do need that feature.
20+
"postCreateCommand": {
21+
"install pretext": "bash ./.devcontainer/installPretext.sh",
22+
"install pandoc": "bash ./.devcontainer/installPandoc.sh",
23+
"install latex": "bash ./.devcontainer/installLatex.sh",
24+
// "install sagemath": "bash ./.devcontainer/installSage.sh",
25+
"working": "echo 'installing additional software into codespace.'"
26+
},
4427

4528

4629
// Port forwarding
@@ -74,6 +57,7 @@
7457
}
7558
},
7659

60+
7761
// Configure tool-specific properties.
7862
"customizations": {
7963
"codespaces": {
@@ -89,13 +73,9 @@
8973
"CodeChat.CodeChatServer.Command": "CodeChat_Server"
9074
},
9175
"extensions": [
92-
"ms-vscode.live-server",
9376
"oscarlevin.pretext-tools",
9477
"CodeChat.codechat"
9578
]
9679
}
9780
}
98-
99-
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
100-
// "remoteUser": "root"
10181
}

templates/installLatex.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# This file was automatically generated with PreTeXt 2.15.2.
4+
# If you modify this file, PreTeXt will no longer automatically update it.
5+
6+
while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do
7+
echo "Waiting for apt-get to be free..."
8+
sleep 15
9+
done
10+
sudo apt-get update
11+
sudo apt-get install -y --no-install-recommends \
12+
python3-louis \
13+
libcairo2-dev \
14+
librsvg2-bin
15+
16+
pip install --upgrade pip --break-system-packages
17+
18+
pip install pretext[homepage,prefigure] --only-binary {greenlet} --break-system-packages
19+
20+
pip install codechat-server --break-system-packages
21+
22+
while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do
23+
echo "Waiting for apt-get to be free..."
24+
sleep 15
25+
done
26+
playwright install-deps
27+
28+
playwright install
29+
30+
# Install mermaid for diagrams
31+
npm install -g @mermaid-js/mermaid-cli
32+
33+
# echo '/usr/lib/python3/dist-packages' > /usr/local/lib/python3.8/dist-packages/louis.pth
34+
35+
prefig init

templates/installPandoc.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
# This file was automatically generated with PreTeXt 2.15.2.
4+
# If you modify this file, PreTeXt will no longer automatically update it.
5+
6+
wget https://github.com/jgm/pandoc/releases/download/3.6.4/pandoc-3.6.4-1-amd64.deb -O pandoc.deb
7+
8+
# wait for 30 second and then double check that no other script is using apt-get:
9+
sleep 60
10+
while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do
11+
echo "Waiting for apt-get to be free..."
12+
sleep 15
13+
done
14+
# Install pandoc
15+
sudo apt-get install -y --no-install-recommends ./pandoc.deb
16+
17+
rm pandoc.deb

templates/installPretext.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# This file was automatically generated with PreTeXt 2.15.2.
4+
# If you modify this file, PreTeXt will no longer automatically update it.
5+
6+
while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do
7+
echo "Waiting for apt-get to be free..."
8+
sleep 15
9+
done
10+
sudo apt-get update
11+
sudo apt-get install -y --no-install-recommends \
12+
python3-louis \
13+
libcairo2-dev \
14+
librsvg2-bin
15+
16+
pip install --upgrade pip --break-system-packages
17+
18+
pip install pretext[homepage,prefigure] --only-binary {greenlet} --break-system-packages
19+
20+
pip install codechat-server --break-system-packages
21+
22+
while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do
23+
echo "Waiting for apt-get to be free..."
24+
sleep 15
25+
done
26+
playwright install-deps
27+
28+
playwright install
29+
30+
# Install mermaid for diagrams
31+
npm install -g @mermaid-js/mermaid-cli
32+
33+
# echo '/usr/lib/python3/dist-packages' > /usr/local/lib/python3.8/dist-packages/louis.pth
34+
35+
prefig init

templates/installSage.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
# This file was automatically generated with PreTeXt 2.15.2.
4+
# If you modify this file, PreTeXt will no longer automatically update it.
5+
6+
# Conda should already be installed in the codespace. We need to add the conda-forge channel
7+
8+
conda config --add channels conda-forge
9+
conda config --set channel_priority strict
10+
11+
# We don't want conda to open the base environment always:
12+
conda config --set auto_activate_base false
13+
14+
# Now create a conda environment for sage (called sage):
15+
conda create --yes -n sage sage python=3.12
16+
17+
conda init
18+
19+
echo 'conda activate sage' >> ~/.bashrc
20+
21+
source ~/.bashrc

0 commit comments

Comments
 (0)