Skip to content

Commit f2d6b86

Browse files
authored
devcontainer improvements (#950)
* update devcontainer and include sage install script * switch to small devcontainer image by default * add changes to log * add container scripts * add new devcontainer and install scripts * update changelog and version * fix installLatex script and update template readme's * update codespace-template workflow
1 parent 9fca4c5 commit f2d6b86

16 files changed

Lines changed: 373 additions & 40 deletions

.github/workflows/codespace-template.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/setup-python@v4
1818
with:
19-
python-version: "3.11"
19+
python-version: "3.12"
2020

2121
- name: Checkout codespace
2222
uses: actions/checkout@v4
@@ -30,11 +30,11 @@ jobs:
3030
python -m pip install --upgrade pip
3131
python -m pip install --upgrade pretext[all]
3232
33-
- name: pretext new book
33+
- name: pretext new hello
3434
shell: bash
3535
run: |
3636
rm -rf *
37-
python -m pretext new book -d .
37+
python -m pretext new hello -d .
3838
3939
- name: setup git config
4040
run: |
@@ -45,12 +45,12 @@ jobs:
4545
- name: restore previous files
4646
run: |
4747
git restore README.md
48-
git restore GenerateAssetsHelp.md
4948
git restore LICENSE
5049
51-
- name: commit
50+
- name: commit (only .devcontainer and .gitignore files)
5251
run: |
5352
# Stage the file, commit and push
54-
git add .
55-
git commit -m "update to latest `pretext new book`" || echo "No new commit needed"
53+
git add .devcontainer/*
54+
git add .gitignore
55+
git commit -m "update to latest `devcontainer files`" || echo "No new commit needed"
5656
git push origin main || echo "All done"

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change
99

1010
## [Unreleased]
1111

12+
### Changed
13+
14+
- The default devcontainer no longer includes a full LaTeX install. If you run into trouble generating latex-images or building pdfs, see the README.md file for assistance.
15+
- The default devcontainer no longer includes sagemath. If you want to build sageplot assets, see the README.md file for assistance.
16+
17+
1218
## [2.15.2] - 2025-03-31
1319

1420
Includes updates to core through commit: [7017d8f](https://github.com/PreTeXtBook/pretext/commit/7017d8fcc7005984ffc7fad81d0a37062a529a9d)
1521

22+
### Fixed
23+
24+
- Bug preventing github actions from completing deploy (internal).
25+
26+
1627
## [2.15.1] - 2025-03-24
1728

1829
Includes updates to core through commit: [7017d8f](https://github.com/PreTeXtBook/pretext/commit/7017d8fcc7005984ffc7fad81d0a37062a529a9d)

pretext/constants.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +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+
"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"),
232236
}
233237

234238
DEPRECATED_PROJECT_RESOURCES = {
235239
"deploy.yml": Path(".github", "workflows", "deploy.yml"),
236240
"test-build.yml": Path(".github", "workflows", "test-build.yml"),
241+
".devcontainer.json": Path(".devcontainer.json"),
237242
}
238243

239244
GIT_RESOURCES = [
240245
".gitignore",
241246
"pretext-cli.yml",
242-
".devcontainer.json",
247+
"devcontainer.json",
248+
"installPretext.sh",
249+
"installPandoc.sh",
250+
"installLatex.sh",
251+
"installSage.sh",
243252
]

templates/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was automatically generated with PreTeXt 2.15.1.
1+
# This file was automatically generated with PreTeXt 2.15.3.
22
# If you modify this file, PreTeXt will no longer automatically update it.
33
#
44
# Boilerplate list of files in a PreTeXt project for git to ignore

templates/article/README.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,61 @@
1-
# My Great Article
1+
# My PreTeXt Article
2+
3+
This README was generated by running `pretext new article`. You should feel free to edit this to describe your project.
24

35
The main source file is `source/main.ptx`. This includes the other sections of the paper.
46

57
To compile the paper as an accessible website, run `pretext build web` in a terminal from any directory of this project.
68

9+
To preview your output, run `pretext view web`.
10+
11+
To deploy your output to GitHub pages, run `pretext deploy`.
12+
713
To compile a pdf, run `pretext build print`.
814

915

10-
Visit <https://pretextbook.org/documentation.html> to learn more about PreTeXT.
16+
---
17+
18+
Below you will find some advice for working with PreTeXt, including help with using the [PreTeXt Codespace](https://github.com/PreTeXtBook/pretext-codespace) online editor through GitHub if you don't want to install the required software on your own computer.
19+
20+
## Learning PreTeXt
21+
22+
See the [PreTeXt documentation](https://pretextbook.org/documentation.html) for links to a variety of resources.
23+
24+
We also recommend browsing through the [annotated sample article](https://pretextbook.org/examples/sample-article/annotated) and [annotated sample book](https://pretextbook.org/examples/sample-book/annotated/) if you want to find examples and see the PreTeXt source for those examples quickly.
25+
26+
## Using GitHub Codespaces
27+
28+
GitHub Codespaces are a way to set up your whole authoring system entirely in your browser. In case you are not already reading this inside a codespace, you can create one specifically designed for authoring in PreTeXt by using [this template](https://github.com/PreTeXtBook/pretext-codespace).
29+
30+
### Important: how to save your files
31+
32+
The most important thing to remember when authoring in a codespace is that you are making all your edits on a *virtual machine* off in some remote server farm. This means there is an extra step to save your files. You can save files in the editor (in your browser), but this just saves them to that virtual machine. To make sure you can access these files, even if the virtual machine goes away, you need to sync them to github.com. This is done by *committing* your changes and then *pushing* those commits (or "syncing" them). You might see a warning when you restart your codespace that you have "uncommitted changes" -- make sure you commit them when you are done working.
33+
34+
### Troubleshooting: Latex-images and pdfs
35+
36+
We have tried to keep the codespace small (so it starts up quickly and doesn't eat through your monthly storage allotment), so we do not include a full TeXLive distribution. We have tried to include most packages and fonts you are likely to need to generate images using `<latex-image>` elements, and to generate PDF print output. However, if you run into a situation where the LaTeX gives errors about packages missing (like it cannot find a `mypackage.sty` file), here is what you should do.
37+
38+
1. To quickly resolve the issue yourself, open a terminal (``Ctrl+Shift+` ``) and use the TeXLive Package Manager to install the missing package.
39+
1. If you know that the package is called `mypackage` then enter the following two lines:
40+
41+
```bash
42+
tlmgr install mypackage
43+
tlmgr path add
44+
```
45+
46+
2. If you don't know the name of the package, but know it should contain `mypackage.sty`, then you can search using
47+
48+
```bash
49+
tlmgr search --global --all "mypackage.sty"
50+
```
51+
52+
53+
2. To ensure that you don't have to repeat this step every time you recreate the codespace, add the package name to the list of installs inside the file `.devcontainer/installLatex.sh` which gets run every time a codespace is created.
54+
55+
3. Better yet, post the name of the missing package to this [GitHub issue](https://github.com/PreTeXtBook/pretext-codespace/issues/21) and we will add it to the devcontainer. This has the advantage that you will still get updates that other authors submit (if you edit the `installLatex.sh` file, then it won't be updated when you run `pretext update`).
56+
57+
### Troubleshooting: sageplot images
58+
59+
By far the largest space-hog in a PreTeXt authoring environment is SageMath, which is only required if you generate images using sageplots. By default, SageMath is not installed in a PreTeXt codespace, but it should be easy to install if you need it.
60+
61+
Just open the command palette (`Ctrl+Shift+P` of `F1`) and search for "PreTeXt: Install SageMath". This will also update the `.devcontainer/devcontainer.json` file so that the next time you create a codespace for this project, it should install automatically.

templates/book/README.md

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1-
# My Great Book
1+
# My PreTeXt Book
2+
3+
This README was generated by running `pretext new book`. You should feel free to edit this to describe your project.
4+
5+
6+
The main source file is `source/main.ptx`. This includes the other chapters of the book.
7+
8+
To compile the book as an accessible website, run `pretext build web` in a terminal from any directory of this project.
9+
10+
To preview your output, run `pretext view web`.
11+
12+
To deploy your output to GitHub pages, run `pretext deploy`.
13+
14+
To compile a pdf, run `pretext build print`.
15+
16+
---
17+
18+
Below you will find some advice for working with PreTeXt, including help with using the [PreTeXt Codespace](https://github.com/PreTeXtBook/pretext-codespace) online editor through GitHub if you don't want to install the required software on your own computer.
19+
20+
21+
## Learning PreTeXt
22+
23+
See the [PreTeXt documentation](https://pretextbook.org/documentation.html) for links to a variety of resources.
24+
25+
We also recommend browsing through the [annotated sample article](https://pretextbook.org/examples/sample-article/annotated) and [annotated sample book](https://pretextbook.org/examples/sample-book/annotated/) if you want to find examples and see the PreTeXt source for those examples quickly.
26+
27+
## Using GitHub Codespaces
28+
29+
GitHub Codespaces are a way to set up your whole authoring system entirely in your browser. In case you are not already reading this inside a codespace, you can create one specifically designed for authoring in PreTeXt by using [this template](https://github.com/PreTeXtBook/pretext-codespace).
30+
31+
### Important: how to save your files
32+
33+
The most important thing to remember when authoring in a codespace is that you are making all your edits on a *virtual machine* off in some remote server farm. This means there is an extra step to save your files. You can save files in the editor (in your browser), but this just saves them to that virtual machine. To make sure you can access these files, even if the virtual machine goes away, you need to sync them to github.com. This is done by *committing* your changes and then *pushing* those commits (or "syncing" them). You might see a warning when you restart your codespace that you have "uncommitted changes" -- make sure you commit them when you are done working.
34+
35+
### Troubleshooting: Latex-images and pdfs
36+
37+
We have tried to keep the codespace small (so it starts up quickly and doesn't eat through your monthly storage allotment), so we do not include a full TeXLive distribution. We have tried to include most packages and fonts you are likely to need to generate images using `<latex-image>` elements, and to generate PDF print output. However, if you run into a situation where the LaTeX gives errors about packages missing (like it cannot find a `mypackage.sty` file), here is what you should do.
38+
39+
1. To quickly resolve the issue yourself, open a terminal (``Ctrl+Shift+` ``) and use the TeXLive Package Manager to install the missing package.
40+
1. If you know that the package is called `mypackage` then enter the following two lines:
41+
42+
```bash
43+
tlmgr install mypackage
44+
tlmgr path add
45+
```
46+
47+
2. If you don't know the name of the package, but know it should contain `mypackage.sty`, then you can search using
48+
49+
```bash
50+
tlmgr search --global --all "mypackage.sty"
51+
```
52+
53+
54+
2. To ensure that you don't have to repeat this step every time you recreate the codespace, add the package name to the list of installs inside the file `.devcontainer/installLatex.sh` which gets run every time a codespace is created.
55+
56+
3. Better yet, post the name of the missing package to this [GitHub issue](https://github.com/PreTeXtBook/pretext-codespace/issues/21) and we will add it to the devcontainer. This has the advantage that you will still get updates that other authors submit (if you edit the `installLatex.sh` file, then it won't be updated when you run `pretext update`).
57+
58+
### Troubleshooting: sageplot images
59+
60+
By far the largest space-hog in a PreTeXt authoring environment is SageMath, which is only required if you generate images using sageplots. By default, SageMath is not installed in a PreTeXt codespace, but it should be easy to install if you need it.
61+
62+
Just open the command palette (`Ctrl+Shift+P` of `F1`) and search for "PreTeXt: Install SageMath". This will also update the `.devcontainer/devcontainer.json` file so that the next time you create a codespace for this project, it should install automatically.
263

3-
Visit <https://pretextbook.org/documentation.html> to learn more.

templates/codechat_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was automatically generated with PreTeXt 2.15.1.
1+
# This file was automatically generated with PreTeXt 2.15.3.
22
# If you modify this file, PreTeXt will no longer automatically update it.
33
#
44
#############################################################

templates/course/README.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Demo Course
1+
# My PreTeXt Course
22

3-
This is an example of how you could set up a "course" in PreTeXt.
3+
This README was generated by running `pretext new course`. You should feel free to edit this to describe your project.
44

55
## Instructions
66

@@ -38,3 +38,50 @@ Look at the source files, in particular `source/acitivies.ptx` and `source/activ
3838

3939
The use of `xpointer="/1/1/1"` is a little mysterious; we could have also used `xpoint="Activity-magic-beans"` to refer to the activity by its `xml:id`, although this would require us changing that for each included activity.
4040

41+
42+
---
43+
44+
Below you will find some advice for working with PreTeXt, including help with using the [PreTeXt Codespace](https://github.com/PreTeXtBook/pretext-codespace) online editor through GitHub if you don't want to install the required software on your own computer.
45+
46+
## Learning PreTeXt
47+
48+
See the [PreTeXt documentation](https://pretextbook.org/documentation.html) for links to a variety of resources.
49+
50+
We also recommend browsing through the [annotated sample article](https://pretextbook.org/examples/sample-article/annotated) and [annotated sample book](https://pretextbook.org/examples/sample-book/annotated/) if you want to find examples and see the PreTeXt source for those examples quickly.
51+
52+
## Using GitHub Codespaces
53+
54+
GitHub Codespaces are a way to set up your whole authoring system entirely in your browser. In case you are not already reading this inside a codespace, you can create one specifically designed for authoring in PreTeXt by using [this template](https://github.com/PreTeXtBook/pretext-codespace).
55+
56+
### Important: how to save your files
57+
58+
The most important thing to remember when authoring in a codespace is that you are making all your edits on a *virtual machine* off in some remote server farm. This means there is an extra step to save your files. You can save files in the editor (in your browser), but this just saves them to that virtual machine. To make sure you can access these files, even if the virtual machine goes away, you need to sync them to github.com. This is done by *committing* your changes and then *pushing* those commits (or "syncing" them). You might see a warning when you restart your codespace that you have "uncommitted changes" -- make sure you commit them when you are done working.
59+
60+
### Troubleshooting: Latex-images and pdfs
61+
62+
We have tried to keep the codespace small (so it starts up quickly and doesn't eat through your monthly storage allotment), so we do not include a full TeXLive distribution. We have tried to include most packages and fonts you are likely to need to generate images using `<latex-image>` elements, and to generate PDF print output. However, if you run into a situation where the LaTeX gives errors about packages missing (like it cannot find a `mypackage.sty` file), here is what you should do.
63+
64+
1. To quickly resolve the issue yourself, open a terminal (``Ctrl+Shift+` ``) and use the TeXLive Package Manager to install the missing package.
65+
1. If you know that the package is called `mypackage` then enter the following two lines:
66+
67+
```bash
68+
tlmgr install mypackage
69+
tlmgr path add
70+
```
71+
72+
2. If you don't know the name of the package, but know it should contain `mypackage.sty`, then you can search using
73+
74+
```bash
75+
tlmgr search --global --all "mypackage.sty"
76+
```
77+
78+
79+
2. To ensure that you don't have to repeat this step every time you recreate the codespace, add the package name to the list of installs inside the file `.devcontainer/installLatex.sh` which gets run every time a codespace is created.
80+
81+
3. Better yet, post the name of the missing package to this [GitHub issue](https://github.com/PreTeXtBook/pretext-codespace/issues/21) and we will add it to the devcontainer. This has the advantage that you will still get updates that other authors submit (if you edit the `installLatex.sh` file, then it won't be updated when you run `pretext update`).
82+
83+
### Troubleshooting: sageplot images
84+
85+
By far the largest space-hog in a PreTeXt authoring environment is SageMath, which is only required if you generate images using sageplots. By default, SageMath is not installed in a PreTeXt codespace, but it should be easy to install if you need it.
86+
87+
Just open the command palette (`Ctrl+Shift+P` of `F1`) and search for "PreTeXt: Install SageMath". This will also update the `.devcontainer/devcontainer.json` file so that the next time you create a codespace for this project, it should install automatically.

0 commit comments

Comments
 (0)