PreTeXtBook / pretext-cli

Command line interface for quickly creating, authoring, and building PreTeXt documents.
https://pretextbook.org
GNU General Public License v3.0
17 stars 18 forks source link

Support using local Asymptote installation in addition to server-based solution #190

Closed asmwarrior closed 1 year ago

asmwarrior commented 2 years ago

As suggested by Bob, I just add a link here, as the details are in the Google group thread here:

Where is the configuration file? And How to config it?

I'm on Windows 7 64bit, currently, I have to add all the tools' path the to PATH env, which may cause the dll conflicts.

Thanks.

StevenClontz commented 2 years ago

PreTeXt-CLI users should edit the project.ptx file of their project to configure executables. You should never edit the files of a Python library installed via pip. While I don't think editing the pretext.cfg file of our package actually has any effect, I recommend you run python -m pip install --upgrade --force-reinstall pretextbook to undo any unintended edits.

Glancing at that thread, it seems you're able to successfully run PreTeXt-CLI after getting the pdf2svg command into your PATH, so you should be able to proceed in authoring for now. I'm not a Windows user, so I'm leaving this thread open so we can investigate if this requirement can be replaced by a pure Python solution that can be installed a prerequisite of this package.

asmwarrior commented 2 years ago

Hi, thanks for the quick response.

I just opened the project.ptx file, it shows such contents:

<?xml version="1.0" encoding="utf-8"?>
<!--
    This file provides the overall configuration for your PreTeXt
    project. To edit the content of your document, open `source/main.ptx`
    (default location).
-->
<project>
  <targets>
    <target name="html">
      <format>html</format>
      <source>source/main.ptx</source>
      <publication>publication/publication.ptx</publication>
      <output-dir>output/html</output-dir>
    </target>
    <target name="latex">
      <format>latex</format>
      <source>source/main.ptx</source>
      <publication>publication/publication.ptx</publication>
      <output-dir>output/latex</output-dir>
    </target>
    <target name="pdf">
      <format>pdf</format>
      <source>source/main.ptx</source>
      <publication>publication/publication.ptx</publication>
      <output-dir>output/pdf</output-dir>
    </target>
    <!-- To quickly build the html of a subset of your project, edit main-subset.ptx
        and run `pretext build subset` (or `view` with watch option) -->
    <target name="subset">
      <format>html</format>
      <source>source/main-subset.ptx</source>
      <publication>publication/publication.ptx</publication>
      <output-dir>output/subset</output-dir>
      <stringparam key="debug.skip-knowls" value="yes"/>
    </target>
  </targets>
  <executables>
      <tex>xelatex</tex>
      <pdfsvg>pdf2svg</pdfsvg>
      <asy>asy</asy>
      <sage>sage</sage>
      <pdfpng>convert</pdfpng>
      <pdfeps>pdftops</pdfeps>
      <pdfcrop>pdf-crop-margins</pdfcrop>
      <pageres>pageres</pageres>
      <node>node</node>
      <liblouis>file2brl</liblouis>
    </executables>
</project>

So, what is the correct grammar of setting the those tool values?

For example, it should be: Method1:

<tex>"E:\texlive\2021\bin\win32\xelatex.exe"</tex>

or Method2:

<tex>E:\texlive\2021\bin\win32\xelatex.exe</tex>

or Method3:

<tex>E:/texlive/2021/bin/win32/xelatex.exe</tex>

OK, I have tried Method3 first, and it works.

asmwarrior commented 2 years ago

Here is the setting in my project.ptx

  <executables>
      <tex>E:/texlive/2021/bin/win32/xelatex.exe</tex>
      <pdfsvg>E:/temp/pdf2svg-windows-master/dist-64bits/pdf2svg.exe</pdfsvg>
      <asy>C:/Program Files/Asymptote/asy.bat</asy>
      <sage>sage</sage>
      <pdfpng>convert</pdfpng>
      <pdfeps>pdftops</pdfeps>
      <pdfcrop>pdf-crop-margins</pdfcrop>
      <pageres>pageres</pageres>
      <node>node</node>
      <liblouis>file2brl</liblouis>
    </executables>

I try to test whether Asymptote image works, so I just open the web page:

9.3 Asymptote, 2D, and click the "view source" button, and I paste the content to the ch_empty.ptx, and here is the build log:

e:\temp\xml\new-pretext-project>pretext -v  DEBUG build html -d
PreTeXt project found in `e:\temp\xml\new-pretext-project`.
debug: XML syntax appears well formed.
debug: PreTeXt document did not pass schema validation; unexpected output may result. See .error_schema.log for hints.  Continuing with build.
Preparing to build into a temporary directory.
Now generating latex-images

PTX: converting latex-image pictures from e:\temp\xml\new-pretext-project\source\main.ptx to svg graphics for placement in e:\temp\xml\new-pretext-project\generated-assets\latex-im
age
PTX:DEBUG: temporary directory for latex-image conversion: C:\Users\zyh\AppData\Local\Temp\tmpgt81bj13
PTX: extracting latex-image pictures from e:\temp\xml\new-pretext-project\source\main.ptx
PTX: string parameters passed to extraction stylesheet: {'publisher': 'e:/temp/xml/new-pretext-project/publication/publication.ptx'}
PTX: discovering source file's directory name: e:\temp\xml\new-pretext-project\source
PTX: verifying and expanding input directory: e:\temp\xml\new-pretext-project\source\../generated-assets
PTX: input directory expanded to absolute path: e:\temp\xml\new-pretext-project\generated-assets
PTX: verifying and expanding input directory: e:\temp\xml\new-pretext-project\source\../assets
PTX: input directory expanded to absolute path: e:\temp\xml\new-pretext-project\assets
PTX: XSL conversion of e:\temp\xml\new-pretext-project\source\main.ptx by E:\download\sci\Winpython64-3.8.8.0\WPy64-3880\python-3.8.8.amd64\lib\site-packages\pretext\static\xsl\ext
ract-latex-image.xsl
PTX:DEBUG: XSL conversion via E:\download\sci\Winpython64-3.8.8.0\WPy64-3880\python-3.8.8.amd64\lib\site-packages\pretext\static\xsl\extract-latex-image.xsl of e:\temp\xml\new-pret
ext-project\source\main.ptx to None and/or into directory C:\Users\zyh\AppData\Local\Temp\tmpgt81bj13 with parameters {'publisher': 'e:/temp/xml/new-pretext-project/publication/pub
lication.ptx'}
PTX:DEBUG: locating "tex" in [executables] section of configuration file
PTX:DEBUG: tex executable: E:/texlive/2021/bin/win32/xelatex.exe, options:
PTX:DEBUG: tex executable: E:/texlive/2021/bin/win32/xelatex.exe
PTX: converting tikz-example-diagram.tex to tikz-example-diagram.pdf
PTX:DEBUG: locating "pdfcrop" in [executables] section of configuration file
PTX:DEBUG: pdfcrop executable: pdf-crop-margins, options:
PTX: cropping tikz-example-diagram.pdf to cropped-tikz-example-diagram.pdf
PTX: renaming cropped-tikz-example-diagram.pdf to tikz-example-diagram.pdf
PTX:DEBUG: locating "pdfsvg" in [executables] section of configuration file
PTX:DEBUG: pdfsvg executable: E:/temp/pdf2svg-windows-master/dist-64bits/pdf2svg.exe, options:
PTX:DEBUG: pdfsvg executable: E:/temp/pdf2svg-windows-master/dist-64bits/pdf2svg.exe
PTX: converting tikz-example-diagram.pdf to tikz-example-diagram.svg
Now generating asymptote images

PTX: converting Asymptote diagrams from e:\temp\xml\new-pretext-project\source\main.ptx to HTML graphics for placement in e:\temp\xml\new-pretext-project\generated-assets\asymptote
 with method "server"
PTX:DEBUG: temporary directory: C:\Users\zyh\AppData\Local\Temp\tmpi889f5gk
PTX: extracting Asymptote diagrams from e:\temp\xml\new-pretext-project\source\main.ptx
PTX: string parameters passed to extraction stylesheet: {'publisher': 'e:/temp/xml/new-pretext-project/publication/publication.ptx'}
PTX: XSL conversion of e:\temp\xml\new-pretext-project\source\main.ptx by E:\download\sci\Winpython64-3.8.8.0\WPy64-3880\python-3.8.8.amd64\lib\site-packages\pretext\static\xsl\ext
ract-asymptote.xsl
PTX:DEBUG: XSL conversion via E:\download\sci\Winpython64-3.8.8.0\WPy64-3880\python-3.8.8.amd64\lib\site-packages\pretext\static\xsl\extract-asymptote.xsl of e:\temp\xml\new-pretex
t-project\source\main.ptx to None and/or into directory C:\Users\zyh\AppData\Local\Temp\tmpi889f5gk with parameters {'publisher': 'e:/temp/xml/new-pretext-project/publication/publi
cation.ptx'}
PTX: converting asymptote-contour.asy to asymptote-contour.html
PTX:DEBUG: asymptote server query http://asymptote.ualberta.ca:10007?f=html
PTX: converting asymptote-lever-integral.asy to asymptote-lever-integral.html
PTX:DEBUG: asymptote server query http://asymptote.ualberta.ca:10007?f=html
PTX: converting asymptote-lever.asy to asymptote-lever.html
PTX:DEBUG: asymptote server query http://asymptote.ualberta.ca:10007?f=html

Now building HTML into C:\Users\zyh\AppData\Local\Temp\tmpyg6m9drb

PTX: discovering source file's directory name: e:\temp\xml\new-pretext-project\source
PTX: verifying and expanding input directory: e:\temp\xml\new-pretext-project\source\../generated-assets
PTX: input directory expanded to absolute path: e:\temp\xml\new-pretext-project\generated-assets
PTX: verifying and expanding input directory: e:\temp\xml\new-pretext-project\source\../assets
PTX: input directory expanded to absolute path: e:\temp\xml\new-pretext-project\assets
PTX: converting e:\temp\xml\new-pretext-project\source\main.ptx to HTML in C:\Users\zyh\AppData\Local\Temp\tmpyg6m9drb
PTX: XSL conversion of e:\temp\xml\new-pretext-project\source\main.ptx by E:\download\sci\Winpython64-3.8.8.0\WPy64-3880\python-3.8.8.amd64\lib\site-packages\pretext\static\xsl\pre
text-html.xsl
PTX:DEBUG: XSL conversion via E:\download\sci\Winpython64-3.8.8.0\WPy64-3880\python-3.8.8.amd64\lib\site-packages\pretext\static\xsl\pretext-html.xsl of e:\temp\xml\new-pretext-pro
ject\source\main.ptx to None and/or into directory C:\Users\zyh\AppData\Local\Temp\tmpyg6m9drb with parameters {'publisher': 'e:/temp/xml/new-pretext-project/publication/publicatio
n.ptx'}
PTX: Failed application of E:\download\sci\Winpython64-3.8.8.0\WPy64-3880\python-3.8.8.amd64\lib\site-packages\pretext\static\xsl\pretext-html.xsl, with messages:
    *  failed to load external entity "file:/e:/temp/xml/new-pretext-project/source/generated/asymptote/asymptote-lever.html"
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-lever.html" needs to be available relative to the primary source file, or if available it is pe
rhaps ill-formed and its width cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable.
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-lever.html" needs to be available relative to the primary source file, or if available it is pe
rhaps ill-formed and its height cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable.
    *  failed to load external entity "file:/e:/temp/xml/new-pretext-project/source/generated/asymptote/asymptote-contour.html"
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-contour.html" needs to be available relative to the primary source file, or if available it is
perhaps ill-formed and its width cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable.

    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-contour.html" needs to be available relative to the primary source file, or if available it is
perhaps ill-formed and its height cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable
.
    *  failed to load external entity "file:/e:/temp/xml/new-pretext-project/source/generated/asymptote/asymptote-lever-integral.html"
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-lever-integral.html" needs to be available relative to the primary source file, or if available
 it is perhaps ill-formed and its width cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredi
ctable.
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-lever-integral.html" needs to be available relative to the primary source file, or if available
 it is perhaps ill-formed and its height cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpred
ictable.
    *  failed to load external entity "file:/e:/temp/xml/new-pretext-project/source/generated/asymptote/asymptote-lever.html"
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-lever.html" needs to be available relative to the primary source file, or if available it is pe
rhaps ill-formed and its width cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable.
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-lever.html" needs to be available relative to the primary source file, or if available it is pe
rhaps ill-formed and its height cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable.
    *  failed to load external entity "file:/e:/temp/xml/new-pretext-project/source/generated/asymptote/asymptote-contour.html"
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-contour.html" needs to be available relative to the primary source file, or if available it is
perhaps ill-formed and its width cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable.

    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-contour.html" needs to be available relative to the primary source file, or if available it is
perhaps ill-formed and its height cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable
.
    *  failed to load external entity "file:/e:/temp/xml/new-pretext-project/source/generated/asymptote/asymptote-lever-integral.html"
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-lever-integral.html" needs to be available relative to the primary source file, or if available
 it is perhaps ill-formed and its width cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredi
ctable.
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/asymptote-lever-integral.html" needs to be available relative to the primary source file, or if available
 it is perhaps ill-formed and its height cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpred
ictable.

Copying successful build from C:\Users\zyh\AppData\Local\Temp\tmpyg6m9drb into e:\temp\xml\new-pretext-project\output\html.

Success! Run `pretext view html` to see the results.

Now, I just run the command pretext view html, and view the generated html in the firefox browser.

There are some error messages in the page, see image shot below:

image

So, anyone know how to fix the asymptote issue?

Thanks.

asmwarrior commented 2 years ago

In the log message, I see:

PTX: converting asymptote-contour.asy to asymptote-contour.html
PTX:DEBUG: asymptote server query http://asymptote.ualberta.ca:10007?f=html
PTX: converting asymptote-lever-integral.asy to asymptote-lever-integral.html
PTX:DEBUG: asymptote server query http://asymptote.ualberta.ca:10007?f=html
PTX: converting asymptote-lever.asy to asymptote-lever.html
PTX:DEBUG: asymptote server query http://asymptote.ualberta.ca:10007?f=html

It looks the pretext cli script try to access the remote asymptote server?

I think my local asy.exe(I'm using the latest 2.77 version of Asymptote) can build the html file, so why query the remote server?

rbeezer commented 2 years ago

I think my local asy.exe(I'm using the latest 2.77 version of Asymptote) can build the html file, so why query the remote server?

The server is more reliable, and many package managers are not providing a new enough version for the better HTML images. The Python code has a "method" switch that will use a local install instead. I'm not sure how (or if) the CLI is exposing that.

rbeezer commented 2 years ago

Strikes me that core PreTeXt finishing with:

*** Edit the configuration file and/or install the necessary program ***

Could be improved and would have avoided some of the confusion here (I mean the confusion from me, a non-user, providing support for the CLI!). Perhaps mentiong $PATH or similar for authors like @asmwarrior?

Should the message be amplified to distinguish the two cases: pretext/pretext v. PreTeXt-CLI?

rbeezer commented 2 years ago

So, anyone know how to fix the asymptote issue?

Can you get a decent HTML image directly with a version of

curl --data-binary @source.asy 'asymptote.ualberta.ca:10007?f=html' > output.html
asmwarrior commented 2 years ago

I think my local asy.exe(I'm using the latest 2.77 version of Asymptote) can build the html file, so why query the remote server?

The server is more reliable, and many package managers are not providing a new enough version for the better HTML images. The Python code has a "method" switch that will use a local install instead. I'm not sure how (or if) the CLI is exposing that.

I know the Asymptote server is more reliable, but the network connection is not reliable from my side.

asmwarrior commented 2 years ago

Here is the log:

# curl --data-binary @testsource.asy 'asymptote.ualberta.ca:10007?f=html' > output.html
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (7) Failed to connect to asymptote.ualberta.ca port 10007 after 6 ms: Bad access

So, as I said in my previous post, the connection is not stable from my side.

Updated:

It looks my firewall block the curl, and after enable it, it looks OK now:

# curl --data-binary @testsource.asy 'asymptote.ualberta.ca:10007?f=html' > output.html
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14372    0 13903  100   469   8690    293  0:00:01  0:00:01 --:--:--  8988

I see the output.html shows a generated image correctly.

asmwarrior commented 2 years ago

Strikes me that core PreTeXt finishing with:

*** Edit the configuration file and/or install the necessary program ***

Could be improved and would have avoided some of the confusion here (I mean the confusion from me, a non-user, providing support for the CLI!). Perhaps mentiong $PATH or similar for authors like @asmwarrior?

Should the message be amplified to distinguish the two cases: pretext/pretext v. PreTeXt-CLI?

What do you want me to try?

The main issue is that the message:

{"msg": "Asymptote error.", "reason": "latex: Not writing to .aux (openout_any = p).\n/usr/local/share/asymptote/plain_shipout.asy: 116.11: runtime: shipout failed"}

Is shown in the generated webpage, so, maybe it's a Asymptote error when building the asy code?

Because I remove the such content(which is the asymptote code for the third image):

<figure xml:id="figure-asymptote-latex-macro">
        <caption>Aymptote Lever, plus Integral</caption>
        <image xml:id="asymptote-lever-integral" width="80%">
<asymptote>
size(200,0);
pair z0=(0,0);
pair z1=(2,0);
pair z2=(5,0);
pair zf=z1+0.75*(z2-z1);
draw(z1--z2);
dot(z1,red+0.15cm);
dot(z2,darkgreen+0.3cm);
label("$m$",z1,1.2N,red);
label("$M$",z2,1.5N,darkgreen);
label("$\hat{\ }$",zf,0.2*S,fontsize(24pt)+blue);
pair s=-0.2*I;
draw("$x$",z0+s--z1+s,N,red,Arrows,Bars,PenMargins);
s=-0.5*I;
draw("$\bar{x}=\definiteintegral{0}{1}{x\delta(x)}{x}$",z0+s--zf+s,blue,Arrows,Bars,PenMargins);
s=-1.05*I;
draw("$X$",z0+s--z2+s,darkgreen,Arrows,Bars,PenMargins);
</asymptote>
        </image>
      </figure>

From my ch_empty.ptx, and the error message is gone now.

Now I understand that the [Asymptote 2D](example(https://pretextbook.org/examples/sample-article/annotated/graphics.html) has 3 images, and the last image generation get failed, which leads to the error message shown in the generated web.

asmwarrior commented 2 years ago

OK, I found why the asy failed to build.

texpreamble("\newcommand{\definiteintegral}[4]{\int_{#1}^{#2}\,#3\,d#4}");
size(200,0);
pair z0=(0,0);
pair z1=(2,0);
pair z2=(5,0);
pair zf=z1+0.75*(z2-z1);
draw(z1--z2);
dot(z1,red+0.15cm);
dot(z2,darkgreen+0.3cm);
label("$m$",z1,1.2N,red);
label("$M$",z2,1.5N,darkgreen);
label("$\hat{\ }$",zf,0.2*S,fontsize(24pt)+blue);
pair s=-0.2*I;
draw("$x$",z0+s--z1+s,N,red,Arrows,Bars,PenMargins);
s=-0.5*I;
draw("$\bar{x}=\definiteintegral{0}{1}{x\delta(x)}{x}$",z0+s--zf+s,blue,Arrows,Bars,PenMargins);
s=-1.05*I;
draw("$X$",z0+s--z2+s,darkgreen,Arrows,Bars,PenMargins);

The first line is needed to define the \definiteintegral command.

After that, it works OK now.

Now, one question remains, is there any option that I can use a local asymptote? Not the remote asymptote server. Thanks.

StevenClontz commented 2 years ago

Strikes me that core PreTeXt finishing with:

*** Edit the configuration file and/or install the necessary program ***

Could be improved and would have avoided some of the confusion here (I mean the confusion from me, a non-user, providing support for the CLI!). Perhaps mentiong $PATH or similar for authors like @asmwarrior?

Should the message be amplified to distinguish the two cases: pretext/pretext v. PreTeXt-CLI?

One possibility is to specify Edit the configuration file ('pretext.cfg' or 'project.ptx'). Although I sometimes whether configuration of executables really belongs in project.ptx which is intended to be tracked with Git and support reproducible builds (e.g. not be hardwired to a particular machine). So for now I think the message is fine, although maybe documentation should be updated to reflect where executables are currently configured for pretext/pretext VS PreTeXt-CLI users.

StevenClontz commented 2 years ago

Documentation is here: https://pretextbook.org/doc/guide/html/pretext-helpers.html Maybe that whole chapter needs a note saying "this is for folks who installed PreTeXt by git pulling, not the PreTeXT CLI"?

StevenClontz commented 2 years ago

Now, one question remains, is there any option that I can use a local asymptote? Not the remote asymptote server. Thanks.

Currently, no. We've hard-coded those builds to use the server here https://github.com/PreTeXtBook/pretext-cli/blob/main/pretext/build.py#L79 Of course, that means https://github.com/PreTeXtBook/pretext-cli/blob/main/templates/project.ptx#L40 does absolutely nothing, which isn't great.

@oscarlevin thoughts? I want to think carefully about the "right" way to express in project.ptx and the CLI the desire to build diagrams using a local Asymptote rather than server.

As a stopgap @asmwarrior, you could try adapting this script. Maybe create it as asymptote.py in your project root (next to project.ptx) and run it using python asymptote.py. (It may have bugs to fix as I don't have a project with aysmptote images to test it with.)

import os
from pretext import core, utils, project
project = project.Project() #uses project.ptx when this is run from its directory
target = project.target("html") #or another target from project.ptx
core.asymptote_conversion(
    xml_source=target.source(), pub_file=utils.linux_path(target.publication()), stringparams=target.stringparams(),
    xmlid_root=target.xmlid_root(), dest_dir=os.path.join(target.generated_dir(),'asymptote'), 
    outformat='html', method='local',
)
StevenClontz commented 2 years ago

note that the above should use whatever you set as the <asy/> executable in your project.ptx.

rbeezer commented 2 years ago

Thanks, @StevenClontz, for the reply. I enhanced the script error message, and edited the Guide a few places to "distinguish" the script from the CLI.

rbeezer commented 2 years ago

I want to think carefully about the "right" way to express

I'd mimic the -m, --method with an attribute:

<asy method="local">/path/to/asy</asy>
<asy method="server"/>

(I'd love to get <sageplot> from the Sage Cell Server, similarly.)

StevenClontz commented 2 years ago

This makes sense if this project should only ever use the server OR the executable (e.g. you cannot have one target that builds Asymptote with the server and another target that uses a local installation). I guess that's no worse than a project only ever using /path/to/asy and never using /path/to/another/asy. @oscarlevin what do you think?

oscarlevin commented 2 years ago

Sorry I'm late to the party. I like Rob's @method suggestion. I agree that eventually we want to allow individual targets to have different executables, but this is a larger issue that includes <tex>. Maybe we implement this as is now and eventually allow any of the executable tags inside individual targets overriding the project defaults.

rbeezer commented 2 years ago

larger issue that includes <tex>

I think I want pretext.cfg to have latex, pdflatex, xelatex executables.

We (currently) need DVI files for the braille work on tactile images, thus latex.

BUT, there is always a but, there are good reasons for an author/publisher to prefer pdflatex over xelatex, or vice versa. [E.g., there are better options for micro-managed typography with pdflatex, while xelatex has better Unicode support.]

Now, thinking as I write - maybe another place for a method option: we can default to what we think is best, but allow overrides as needed.

A novel idea: we coordinate and release simultaneously. Well, nearly so. ;-)

rbeezer commented 2 years ago

I think I want pretext.cfg to have latex, pdflatex, xelatex executables.

Capturing first-pass ideas here:

https://github.com/rbeezer/mathbook/issues/1658

StevenClontz commented 1 year ago

We need to update our milestones. :-) Cross-linking this issue to discussion at https://groups.google.com/g/pretext-dev/c/Abnlk8jUkLI/m/bUMrRGluBgAJ - the time is right to implement this now that Codespaces makes installing Asymptote less of a burden.

sean-fitzpatrick commented 1 year ago

I posted this in pretext-dev yesterday, but cross-posting here: John Bowman's Asymptote server was down again yesterday (or rather, was not responding to the pretext script).

So far, the process has been for me to send John an email to let him know that something's wrong, and then he troubleshoots for us. But this is clearly not a sustainable procedure moving forward.

The original motivation for the server method was that John's server was always running the most recent version of Asymptote, and two/three years ago, the WebGL output for HTML was bleeding edge. (And it was somewhat later that the asy binary became smart enough that with the -f html format switch, it would process all 3D Asymptote to WebGL HTML files, and 2D to SVG.)

But the features we need are now a stable part of the Asymptote version included in any recent version of TeXLive, so I think it's safe to assume that most authors, including Codespaces users, can run Asymptote locally.

Another option: there is documentation and source code available if someone wanted to run a dedicated Asymptote server as part of the PreTeXt-Runestone OSE, and be responsible for ensuring that it was functioning for anyone wanting to use the server method.

But my vote would be to default to local, with server as an option if desired.

oscarlevin commented 1 year ago

In the 2.0 release, you will be able to have an attribute @asy-method in either the project element or individual targets, with allowed values local or server.

For now, we are keeping server the default: I was not able to get an asymptote install working in codespaces that worked.