Skip to content

Commit 862ed51

Browse files
authored
Devcontainer improvements (#1003)
* Update devcontainer and related templates * update core commit * update changelog * update build process to only update hash when deploying * format * flake
1 parent edba358 commit 862ed51

11 files changed

Lines changed: 39 additions & 86 deletions

CHANGELOG.md

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

1010
## [Unreleased]
1111

12+
13+
### Changed
14+
15+
- Default devcontainer setup now uses a simplified, versioned `pretext-full` docker image.
16+
1217
### Fixed
1318

1419
- Fill-in-the-blank questions do not need dynamic-subs assets for HTML-format builds; now they will no longer be generated.
@@ -17,6 +22,7 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change
1722

1823
- Sometimes something goes wrong with the pretext resources in `~/.ptx`. You can now run `pretext init --system` to reinstall these resources for the current version. This will also try to run `npm install` for the css themes.
1924

25+
2026
## [2.19.3] - 2025-06-14
2127

2228
Includes updates to core through commit: [1b65b63](https://github.com/PreTeXtBook/pretext/commit/1b65b63c3a83292c22b46cf1e12795c4dd519cc0)

pretext/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
VERSION = get_version("pretext", Path(__file__).parent.parent)
2020

21-
CORE_COMMIT = "2721dfdb393bcc2e66f7c07f279c81d132b7a75f"
21+
22+
CORE_COMMIT = "1ef97c03fda832b25d60d78edfbc729ee3a75683"
2223

2324

2425
def activate() -> None:

pretext/constants.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,25 +228,23 @@
228228
"requirements.txt": Path("requirements.txt"),
229229
"pretext-cli.yml": Path(".github", "workflows", "pretext-cli.yml"),
230230
"pretext-deploy.yml": Path(".github", "workflows", "pretext-deploy.yml"),
231-
"installPretext.sh": Path(".devcontainer", "installPretext.sh"),
232231
"installPandoc.sh": Path(".devcontainer", "installPandoc.sh"),
233-
"installLatex.sh": Path(".devcontainer", "installLatex.sh"),
234232
"installSage.sh": Path(".devcontainer", "installSage.sh"),
235233
}
236234

237235
DEPRECATED_PROJECT_RESOURCES = {
238236
"deploy.yml": Path(".github", "workflows", "deploy.yml"),
239237
"test-build.yml": Path(".github", "workflows", "test-build.yml"),
240238
".devcontainer.json": Path(".devcontainer.json"),
239+
"installPretext": Path(".devcontainer", "installPretext"),
240+
"installLatex": Path(".devcontainer", "installLatex"),
241241
}
242242

243243
GIT_RESOURCES = [
244244
".gitignore",
245245
"pretext-cli.yml",
246246
"pretext-deploy.yml",
247247
"devcontainer.json",
248-
"installPretext.sh",
249248
"installPandoc.sh",
250-
"installLatex.sh",
251249
"installSage.sh",
252250
]

pretext/resources/resource_hash_table.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,13 @@
274274
"installSage.sh": "d167efbf07ea099aba56864e21eeb7c13462203d0a38cafbbef15e34379732de"
275275
},
276276
"2.19.4": {
277-
"project.ptx": "2dc2900025b5cd39b0f7c8890c1debc2cf2102875bed5b3634aa0e9b151b1711",
278-
"codechat_config.yaml": "89dc598ea7db1c91ec8882e2737aff9d683d7123187c288e16f1617a39f9d9e3",
279-
".gitignore": "721a3a2c412782db41cb72441eaef2b9bffdb6d927fde87f67ada1f44a78af90",
280-
"devcontainer.json": "5695d90f4194164b092038133b6675544c81d5ea2cf4c5eeec8075e26890998d",
281-
"pretext-cli.yml": "e2d6d3a23cd2a955c998ec5cb4005d4cd67cc3d3a2cafc6af618bf5ce0b64009",
282-
"pretext-deploy.yml": "4aa427a79fac24030f5a21f49a0a75c333f62f2c0bd44d2d403126eaca0e8ea3",
283-
"installPretext.sh": "99676bf6224335cd1dfd8efebd0835ce255366bf3aa10d04388d5fda8134a44e",
284-
"installPandoc.sh": "67f9a2418ca80b79fa796d31c77b6f230dba4a496021c6fcf39b67ddba35f013",
285-
"installLatex.sh": "51905c51e0b3c95121caab413de37b670aedf712f432bfcdd38c1fe8f312dbc6",
286-
"installSage.sh": "1c4b41cba70577b78552884755674fcc91cb2a039aafa63915fc6e7b7165345f"
277+
"project.ptx": "9b85a183aec4e47d18ccf02f96da22243398e70a431d0c9ea161f4366b63f838",
278+
"codechat_config.yaml": "5ddce213cc31a32747455c07c750b3909779f7877884921eb51e1f4568cab4b7",
279+
".gitignore": "227d5cda5d8b21cf6f92adf3a0b186ecd106e7595c280b30378e98caf87c3116",
280+
"devcontainer.json": "17e819d3753a69b8462011c46431ade2fc12e3d56c338ec6236426be0f9fae5e",
281+
"pretext-cli.yml": "cad032873daa6663b46224234876664f70482903a3f8165a56be098521aff239",
282+
"pretext-deploy.yml": "25857a8fff8bdc7a77db07a1d5745faffe1e1954f32037fe658431f3d30aa9e7",
283+
"installPandoc.sh": "dad9b628ac453a8ae45ce78f5228cf2ea6413f12e33194abe249ea2f69f60d35",
284+
"installSage.sh": "75e746217f7459f62d140a82a20bbf7e7be094e0d68aeabfaed9fca6efa95476"
287285
}
288286
}

scripts/build_package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def main() -> None:
99
arguments = sys.argv[1:]
1010
print(f"Building package for version {pretext.VERSION}.")
1111
# ensure up-to-date "static" resources
12-
fetch_core.main(arguments)
12+
fetch_core.main(arguments, update_templates=True)
1313

1414
# Build package
1515
subprocess.run(["poetry", "build"], shell=True)

scripts/bundle_resources.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ def resource_hashes() -> None:
3434
r"PreTeXt \d+\.\d+\.\d+", f"PreTeXt {VERSION}", line
3535
)
3636
f.write(new_line)
37+
elif '"image": "oscarlevin/pretext' in line:
38+
new_line = re.sub(
39+
r'("image": "oscarlevin/pretext(-full)?):latest"',
40+
rf'\1:{VERSION}"',
41+
line,
42+
)
43+
f.write(new_line)
3744
else:
3845
f.write(line)
3946
# Now hash the updated file to add to a hash-table for this version
@@ -53,9 +60,12 @@ def resource_hashes() -> None:
5360
)
5461

5562

56-
def main() -> None:
63+
def main(update_templates: bool = False) -> None:
5764
# Take care of boilerplate files and their hashes
58-
resource_hashes()
65+
if update_templates:
66+
resource_hashes()
67+
else:
68+
print("Skipping resource hash generation.")
5969

6070
# Zip the templates and pelican resources
6171
shutil.make_archive(

scripts/fetch_core.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ def get_runestone_services() -> None:
5151
zip_ref.write(rs_services_tgz_path, arcname=services_file_name)
5252

5353

54-
def main(args=None) -> None:
55-
print(args)
54+
def main(args: any = None, update_templates: bool = False) -> None:
5655
if args:
57-
print(f"Arguments: {args}")
5856
repo_name = args[0]
5957
else:
6058
repo_name = "PreTeXtBook/pretext"
@@ -127,7 +125,7 @@ def main(args=None) -> None:
127125
# Get Runestone services file
128126
get_runestone_services()
129127

130-
bundle_resources.main()
128+
bundle_resources.main(update_templates=update_templates)
131129
print("Successfully bundled core PreTeXtBook/pretext resources.")
132130

133131

templates/devcontainer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was automatically generated with PreTeXt 2.19.4.
1+
// This file was automatically generated with PreTeXt 2.19.3.
22
// If you modify this file, PreTeXt will no longer automatically update it.
33
//
44
//////////////////////////////////////////////////////////////
@@ -13,15 +13,15 @@
1313
//
1414
///////////////////////////////////////////////////////////////
1515
{
16-
"image": "mcr.microsoft.com/devcontainers/universal:2",
16+
"image": "oscarlevin/pretext-full:latest",
17+
// If you don't need sagemath, you can use a smaller base image. Comment out the line above and uncomment the line below to use a smaller image.
18+
// "image": "oscarlevin/pretext:latest",
1719
"features": {},
1820

19-
// Comment or uncomment lines below if you don't or do need that feature.
21+
// The pretext-full image above includes pretext, prefigure, and enough parts of latex and sagemath for most cases. If there are errors with sage, you can install the full sagemath package through Conda by running ./.devcontainer/installSage.sh, or uncommenting that line and rebuilding the container.
2022
"postCreateCommand": {
2123
// "install sagemath": "bash ./.devcontainer/installSage.sh",
2224
"install pandoc": "bash ./.devcontainer/installPandoc.sh",
23-
"install latex": "bash ./.devcontainer/installLatex.sh",
24-
"install pretext": "bash ./.devcontainer/installPretext.sh",
2525
"mark repo as safe": "git config --global --add safe.directory $(pwd)"
2626
},
2727

templates/installLatex.sh

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

templates/installPretext.sh

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

0 commit comments

Comments
 (0)