pretext 2.33.2__py3-none-any.whl → 2.33.2.dev20251211064632__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pretext/__init__.py +1 -1
- pretext/codechat.py +1 -3
- pretext/project/__init__.py +32 -25
- pretext/resources/core.zip +0 -0
- pretext/resources/pelican.zip +0 -0
- pretext/resources/resource_hash_table.json +9 -9
- pretext/resources/rs_cache.zip +0 -0
- pretext/resources/templates.zip +0 -0
- pretext/utils.py +6 -30
- {pretext-2.33.2.dist-info → pretext-2.33.2.dev20251211064632.dist-info}/METADATA +3 -3
- {pretext-2.33.2.dist-info → pretext-2.33.2.dev20251211064632.dist-info}/RECORD +14 -14
- {pretext-2.33.2.dist-info → pretext-2.33.2.dev20251211064632.dist-info}/LICENSE +0 -0
- {pretext-2.33.2.dist-info → pretext-2.33.2.dev20251211064632.dist-info}/WHEEL +0 -0
- {pretext-2.33.2.dist-info → pretext-2.33.2.dev20251211064632.dist-info}/entry_points.txt +0 -0
pretext/__init__.py
CHANGED
|
@@ -19,7 +19,7 @@ from single_version import get_version
|
|
|
19
19
|
VERSION = get_version("pretext", Path(__file__).parent.parent)
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
CORE_COMMIT =
|
|
22
|
+
CORE_COMMIT = '1c97959297d51749717f9b34ce5da131c960b92d'
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def activate() -> None:
|
pretext/codechat.py
CHANGED
|
@@ -88,9 +88,7 @@ def map_path_to_xml_id(
|
|
|
88
88
|
# Load the XML, performing xincludes using this loader.
|
|
89
89
|
huge_parser = ET.XMLParser(huge_tree=True)
|
|
90
90
|
src_tree = ET.parse(_xml, parser=huge_parser)
|
|
91
|
-
|
|
92
|
-
# lxml.ElementInclude.include(src_tree, loader=my_loader)
|
|
93
|
-
src_tree.xinclude()
|
|
91
|
+
lxml.ElementInclude.include(src_tree, loader=my_loader)
|
|
94
92
|
|
|
95
93
|
# Walk though every element with an xml ID. Note: the type stubs don't have the ``iterfind`` method, hence the ignore in the next line.
|
|
96
94
|
for elem in src_tree.iterfind(f".//*[@{xml_id_attrib}]"): # type: ignore
|
pretext/project/__init__.py
CHANGED
|
@@ -128,8 +128,6 @@ class Target(pxml.BaseXmlModel, tag="target", search_mode=SearchMode.UNORDERED):
|
|
|
128
128
|
#
|
|
129
129
|
# A path to the root source for this target, relative to the project's `source` path.
|
|
130
130
|
source: Path = pxml.attr(default=Path("main.ptx"))
|
|
131
|
-
# Cache of assembled source element.
|
|
132
|
-
_source_element: t.Optional[ET._Element] = None
|
|
133
131
|
# A path to the publication file for this target, relative to the project's `publication` path. This is mostly validated by `post_validate`.
|
|
134
132
|
publication: Path = pxml.attr(default=None)
|
|
135
133
|
latex_engine: LatexEngine = pxml.attr(
|
|
@@ -370,9 +368,29 @@ class Target(pxml.BaseXmlModel, tag="target", search_mode=SearchMode.UNORDERED):
|
|
|
370
368
|
if server.name not in self_server_names:
|
|
371
369
|
self.server.append(server)
|
|
372
370
|
|
|
373
|
-
#
|
|
374
|
-
|
|
375
|
-
|
|
371
|
+
# For the Runestone format, determine the `<document-id>`, which specifies the `output_dir`.
|
|
372
|
+
if self.format == Format.HTML and self.platform == Platform.RUNESTONE:
|
|
373
|
+
# We expect `d_list == ["document-id contents here"]`.
|
|
374
|
+
d_list = self.source_element().xpath("/pretext/docinfo/document-id/text()")
|
|
375
|
+
if isinstance(d_list, list):
|
|
376
|
+
if len(d_list) != 1:
|
|
377
|
+
raise ValueError(
|
|
378
|
+
"Only one `document-id` tag is allowed in a PreTeXt document."
|
|
379
|
+
)
|
|
380
|
+
# NB as of 2025-04-08, we are no longer setting the output directory automatically for
|
|
381
|
+
# Runestone targets. This must be managed by the project.ptx file or by a client script.
|
|
382
|
+
# The commented code below is how we used to do this.
|
|
383
|
+
|
|
384
|
+
# d = d_list[0]
|
|
385
|
+
# assert isinstance(d, str)
|
|
386
|
+
# # Use the correct number of `../` to undo the project's `output-dir`, so the output from the build is located in the correct directory of `published/document-id`.
|
|
387
|
+
# self.output_dir = Path(
|
|
388
|
+
# f"{'../'*len(self._project.output_dir.parents)}published/{d}"
|
|
389
|
+
# )
|
|
390
|
+
else:
|
|
391
|
+
raise ValueError(
|
|
392
|
+
"The `document-id` tag must be defined for the Runestone format."
|
|
393
|
+
)
|
|
376
394
|
|
|
377
395
|
def source_abspath(self) -> Path:
|
|
378
396
|
return self._project.source_abspath() / self.source
|
|
@@ -390,21 +408,14 @@ class Target(pxml.BaseXmlModel, tag="target", search_mode=SearchMode.UNORDERED):
|
|
|
390
408
|
def source_element(self) -> ET._Element:
|
|
391
409
|
"""
|
|
392
410
|
Returns the root element for the assembled source, after processing with the "version-only" assembly.
|
|
393
|
-
Caches the result for future calls.
|
|
394
411
|
"""
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
)
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
stringparams=self.stringparams.copy(),
|
|
403
|
-
method="version",
|
|
404
|
-
).getroot()
|
|
405
|
-
else:
|
|
406
|
-
log.debug(f"Using cached source_element for target {self.name}")
|
|
407
|
-
return self._source_element
|
|
412
|
+
assembled = core.assembly_internal(
|
|
413
|
+
xml=self.source_abspath(),
|
|
414
|
+
pub_file=self.publication_abspath().as_posix(),
|
|
415
|
+
stringparams=self.stringparams.copy(),
|
|
416
|
+
method="version",
|
|
417
|
+
)
|
|
418
|
+
return assembled.getroot()
|
|
408
419
|
|
|
409
420
|
def publication_abspath(self) -> Path:
|
|
410
421
|
return self._project.publication_abspath() / self.publication
|
|
@@ -671,16 +682,12 @@ class Target(pxml.BaseXmlModel, tag="target", search_mode=SearchMode.UNORDERED):
|
|
|
671
682
|
self.stringparams["cli.version"] = VERSION[: VERSION.rfind(".")]
|
|
672
683
|
|
|
673
684
|
# Check for xml syntax errors and quit if xml invalid:
|
|
674
|
-
|
|
675
|
-
# Access the source_element to trigger assembly if it hasn't been done yet.
|
|
676
|
-
self.source_element()
|
|
677
|
-
except Exception as e:
|
|
678
|
-
log.error(f"Error assembling source file: {e}")
|
|
685
|
+
if not utils.xml_syntax_is_valid(self.source_abspath()):
|
|
679
686
|
raise RuntimeError("XML syntax for source file is invalid")
|
|
680
687
|
if not utils.xml_syntax_is_valid(self.publication_abspath(), "publication"):
|
|
681
688
|
raise RuntimeError("XML syntax for publication file is invalid")
|
|
682
689
|
# Validate xml against schema; continue with warning if invalid:
|
|
683
|
-
utils.
|
|
690
|
+
utils.xml_source_validates_against_schema(self.source_abspath())
|
|
684
691
|
|
|
685
692
|
# Clean output upon request
|
|
686
693
|
if clean:
|
pretext/resources/core.zip
CHANGED
|
Binary file
|
pretext/resources/pelican.zip
CHANGED
|
Binary file
|
|
@@ -513,14 +513,14 @@
|
|
|
513
513
|
"installPandoc.sh": "3d4ee0fe164575e7f17dda651c12570f12fed3e042ca4739edd5bbfcaaec5c24",
|
|
514
514
|
"installSage.sh": "e9682f35f46c2faf5c062b679fd2e17d9767098022b5f10164b8c4e5439544a9"
|
|
515
515
|
},
|
|
516
|
-
"2.33.2": {
|
|
517
|
-
"project.ptx": "
|
|
518
|
-
"codechat_config.yaml": "
|
|
519
|
-
".gitignore": "
|
|
520
|
-
"devcontainer.json": "
|
|
521
|
-
"pretext-cli.yml": "
|
|
522
|
-
"pretext-deploy.yml": "
|
|
523
|
-
"installPandoc.sh": "
|
|
524
|
-
"installSage.sh": "
|
|
516
|
+
"2.33.2.dev20251211064632": {
|
|
517
|
+
"project.ptx": "2ab72c22ee7e4c2fa44428c41b26f991ef457ac543886029473e400413b7dcfd",
|
|
518
|
+
"codechat_config.yaml": "2f22e90dbf76a7918556f7f0ba43dc7b503b02c15c246757b4a53e093c69d04e",
|
|
519
|
+
".gitignore": "c34611fa875e15a57a1aeddaad5a403933ac179e83333f78cbf6dfb00900624f",
|
|
520
|
+
"devcontainer.json": "6674ef076ce8df47d288c59a366b59e0a01039c2195eb7aba99ca9eb7b751c34",
|
|
521
|
+
"pretext-cli.yml": "cbffb8d0663cefc11832ebcff190bdfea67ec7caf99faa00276b47aa188e684f",
|
|
522
|
+
"pretext-deploy.yml": "d9bfed1750deaf694651e4113f1b3c5215153b429460bd08b6b3c683857529fc",
|
|
523
|
+
"installPandoc.sh": "28e29981435545a4cea0ad2fc0df8603ad51a32181b12e40c253396cc02a655f",
|
|
524
|
+
"installSage.sh": "2504f9fad7cb557b4f5a653f48868f53a6fa1abf66ce43a3c052cc76129c3c52"
|
|
525
525
|
}
|
|
526
526
|
}
|
pretext/resources/rs_cache.zip
CHANGED
|
Binary file
|
pretext/resources/templates.zip
CHANGED
|
Binary file
|
pretext/utils.py
CHANGED
|
@@ -12,7 +12,6 @@ import shutil
|
|
|
12
12
|
import socketserver
|
|
13
13
|
import socket
|
|
14
14
|
import subprocess
|
|
15
|
-
import time as time
|
|
16
15
|
import logging
|
|
17
16
|
import logging.handlers
|
|
18
17
|
import psutil
|
|
@@ -204,13 +203,17 @@ def xml_syntax_is_valid(xmlfile: Path, root_tag: str = "pretext") -> bool:
|
|
|
204
203
|
return True
|
|
205
204
|
|
|
206
205
|
|
|
207
|
-
def
|
|
206
|
+
def xml_source_validates_against_schema(xmlfile: Path) -> bool:
|
|
208
207
|
# get path to RelaxNG schema file:
|
|
209
208
|
schemarngfile = resources.resource_base_path() / "core" / "schema" / "pretext.rng"
|
|
210
209
|
|
|
211
210
|
# Open schemafile for validation:
|
|
212
211
|
relaxng = ET.RelaxNG(file=schemarngfile)
|
|
213
212
|
|
|
213
|
+
# Parse xml file:
|
|
214
|
+
source_xml = ET.parse(xmlfile)
|
|
215
|
+
source_xml.xinclude()
|
|
216
|
+
|
|
214
217
|
# just for testing
|
|
215
218
|
# ----------------
|
|
216
219
|
# relaxng.validate(source_xml)
|
|
@@ -219,7 +222,7 @@ def xml_validates_against_schema(etree: _Element) -> bool:
|
|
|
219
222
|
|
|
220
223
|
# validate against schema
|
|
221
224
|
try:
|
|
222
|
-
relaxng.assertValid(
|
|
225
|
+
relaxng.assertValid(source_xml)
|
|
223
226
|
log.info("PreTeXt source passed schema validation.")
|
|
224
227
|
except ET.DocumentInvalid as err:
|
|
225
228
|
log.debug(
|
|
@@ -1101,30 +1104,3 @@ def rs_methods(
|
|
|
1101
1104
|
f"PTX-BUG: Format {format} not recognized for running ext_rs_methods. Something is wrong with the pretext script."
|
|
1102
1105
|
)
|
|
1103
1106
|
return None
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
class Stopwatch:
|
|
1107
|
-
"""A simple stopwatch class for measuring elapsed time."""
|
|
1108
|
-
|
|
1109
|
-
"""print_log set to false disables logging of elapsed time """
|
|
1110
|
-
|
|
1111
|
-
def __init__(self, name: str = "", print_log: bool = True):
|
|
1112
|
-
self.name = name
|
|
1113
|
-
self.print_log = print_log
|
|
1114
|
-
self.start_time = time.time()
|
|
1115
|
-
self.last_log_time = self.start_time
|
|
1116
|
-
|
|
1117
|
-
def reset(self) -> None:
|
|
1118
|
-
"""Reset the log timer to the current time."""
|
|
1119
|
-
self.last_log_time = time.time()
|
|
1120
|
-
|
|
1121
|
-
def log(self, timepoint_description: str = "") -> None:
|
|
1122
|
-
"""Print a log message with the elapsed time since the last log event."""
|
|
1123
|
-
if self.print_log:
|
|
1124
|
-
cur_time = time.time()
|
|
1125
|
-
elapsed_time = cur_time - self.start_time
|
|
1126
|
-
since_last_log_time = cur_time - self.last_log_time
|
|
1127
|
-
self.reset()
|
|
1128
|
-
log.debug(
|
|
1129
|
-
f"** Timing report from {self.name}: {timepoint_description}, {since_last_log_time:.2f}s since last watch reset. {elapsed_time:.2f}s total elapsed time."
|
|
1130
|
-
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pretext
|
|
3
|
-
Version: 2.33.2
|
|
3
|
+
Version: 2.33.2.dev20251211064632
|
|
4
4
|
Summary: A package to author, build, and deploy PreTeXt projects.
|
|
5
5
|
Home-page: https://pretextbook.org
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -24,12 +24,12 @@ Requires-Dist: click-log (>=0.4,<0.5)
|
|
|
24
24
|
Requires-Dist: coloraide (>=4,<5)
|
|
25
25
|
Requires-Dist: ghp-import (>=2,<3)
|
|
26
26
|
Requires-Dist: jinja2 (>=3,<4)
|
|
27
|
-
Requires-Dist: lxml (>=6
|
|
27
|
+
Requires-Dist: lxml (>=5.3,<6.0)
|
|
28
28
|
Requires-Dist: pdfCropMargins (>=1.0.9,<1.1.0)
|
|
29
29
|
Requires-Dist: pelican[markdown] (>=4.10,<5.0) ; extra == "homepage" or extra == "all"
|
|
30
30
|
Requires-Dist: plastex (>=3,<4)
|
|
31
31
|
Requires-Dist: playwright (>=1,<2)
|
|
32
|
-
Requires-Dist: prefig[text] (>=0.4.
|
|
32
|
+
Requires-Dist: prefig[text] (>=0.4.2,<0.5.0) ; extra == "prefigure" or extra == "all"
|
|
33
33
|
Requires-Dist: psutil (>=7,<8)
|
|
34
34
|
Requires-Dist: pyMuPDF (>=1.24,<2.0)
|
|
35
35
|
Requires-Dist: pydantic-xml (==2.14.3)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
pretext/__init__.py,sha256=
|
|
1
|
+
pretext/__init__.py,sha256=MkSLodjubtmL4pHXaPrwTyY3-YrIdvLYKkQBLCcKqtc,1453
|
|
2
2
|
pretext/__main__.py,sha256=MSmt_5Xg84uHqzTN38JwgseJK8rsJn_11A8WD99VtEo,61
|
|
3
3
|
pretext/cli.py,sha256=VkDFWViY4Wa8aYdXC4rIHaAEq5-UUuVZR4Pw8mqp1f0,40546
|
|
4
|
-
pretext/codechat.py,sha256=
|
|
4
|
+
pretext/codechat.py,sha256=SezcA7kn-_4lvWSXbqILV2shzA_77NDNx_LryJiD6lk,6164
|
|
5
5
|
pretext/constants.py,sha256=cKxyUUy0SNX1M41CtJJtBpaHXTrKrZQPLrrbOJpCoU8,6843
|
|
6
6
|
pretext/core/__init__.py,sha256=CmOXWPslsSiVzldc2UXNRug-xL8Ax601zGrp_3VhWxQ,739
|
|
7
7
|
pretext/core/braille_format.py,sha256=ra1zVsyoUSUuGWCtY0VGF0FuEfHQ34oXtJvgKiiImdg,36377
|
|
@@ -46,20 +46,20 @@ pretext/plastex/tikzcd.jinja2,sha256=SwJvImtyumC0Xq-PJvfGeBPAGa8bR_T9U_i60pO3OkI
|
|
|
46
46
|
pretext/plastex/tikzpicture.jinja2,sha256=uceZoDivG5sF6-ASG8j22pbZ4GoGQ88q8fd8ogjU3hw,94
|
|
47
47
|
pretext/plastex/url.jinja2s,sha256=DPZEIzrET-rjYVlf-1zH41ESjpifUxXT5lu8Bxu_FO8,184
|
|
48
48
|
pretext/plastex/wrapfig.jinja2s,sha256=3tDkMzNtuEfbAZy1MeHnlmGa4QXXVN1yhFbY3phrooc,96
|
|
49
|
-
pretext/project/__init__.py,sha256=
|
|
49
|
+
pretext/project/__init__.py,sha256=4VVE9EC3IwxT2NZGqDN6VX7iQWhP6mP-uJOPoBEd1RU,87640
|
|
50
50
|
pretext/project/generate.py,sha256=Qn79ap89dSHKYhFUw494nkMVCN4qJUQjZBnJOhAbyqQ,9158
|
|
51
51
|
pretext/project/xml.py,sha256=wtaXS2isRG6QlfyfNNccAbFt6Izwm7yxAledwd1Q6AA,3456
|
|
52
52
|
pretext/resources/__init__.py,sha256=1qPohIxCtL1_sUtlAoFrWzhl31l-oFj4RrBBsb3RzQQ,4081
|
|
53
|
-
pretext/resources/core.zip,sha256=
|
|
54
|
-
pretext/resources/pelican.zip,sha256=
|
|
55
|
-
pretext/resources/resource_hash_table.json,sha256=
|
|
56
|
-
pretext/resources/rs_cache.zip,sha256=
|
|
57
|
-
pretext/resources/templates.zip,sha256=
|
|
53
|
+
pretext/resources/core.zip,sha256=6R6Xan0TvGcBK6Amw3JAJc4AuNx-3u5ZHJOnkz7MSlo,1755857
|
|
54
|
+
pretext/resources/pelican.zip,sha256=nFxIefqpdIcxTcUxBmISh2NQhmY1X23iPm1gB5lmf_0,15974
|
|
55
|
+
pretext/resources/resource_hash_table.json,sha256=MMqp4mvFElUcY7IMlW7UEssNNZ8F68BjacblhwqcLV0,39067
|
|
56
|
+
pretext/resources/rs_cache.zip,sha256=ofrVSh_xABMk7vIi80SDkMe84HGXiNzhXixAhuUbFUA,14931427
|
|
57
|
+
pretext/resources/templates.zip,sha256=tX6DFeemj3tjTK4VHRBjPelHWJeK1WBvgvcXyuwzRbg,381764
|
|
58
58
|
pretext/server.py,sha256=B90NC6kevNeJNbwtUh3iVxF_BH5tiA4522XsjONsGSc,10800
|
|
59
59
|
pretext/types.py,sha256=Eyyu6xmmCYnKBfvzBZzZMWZMa3yNjZ8NnGmlFGj9p5I,168
|
|
60
|
-
pretext/utils.py,sha256=
|
|
61
|
-
pretext-2.33.2.dist-info/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
62
|
-
pretext-2.33.2.dist-info/METADATA,sha256=
|
|
63
|
-
pretext-2.33.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
64
|
-
pretext-2.33.2.dist-info/entry_points.txt,sha256=L-rrQFUIWZhdOdu-XBQ9iuFK3X1cMVOtC-0I7T87II8,44
|
|
65
|
-
pretext-2.33.2.dist-info/RECORD,,
|
|
60
|
+
pretext/utils.py,sha256=9fwXBJorCsvQOE4NY2riDbSllPHsEWNJ01F7y_GCKJE,44064
|
|
61
|
+
pretext-2.33.2.dev20251211064632.dist-info/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
62
|
+
pretext-2.33.2.dev20251211064632.dist-info/METADATA,sha256=K9v9TgER6GJYjl79BX5Am3tjLcpvTz8V-q-gexHio_I,11496
|
|
63
|
+
pretext-2.33.2.dev20251211064632.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
64
|
+
pretext-2.33.2.dev20251211064632.dist-info/entry_points.txt,sha256=L-rrQFUIWZhdOdu-XBQ9iuFK3X1cMVOtC-0I7T87II8,44
|
|
65
|
+
pretext-2.33.2.dev20251211064632.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|