Skip to content

Commit 23cd06c

Browse files
committed
Revise docker to allow PDF viewing and copy
New scripts dmathicsdoc and dmathicsdoccopy perform the new functions Document this in README.rst, and add these scripts in PyPI packaging. entrypoint.sh needs to multiplex dmathicsdoccpy and dmathicsdoc now. Revise Dockerfiles to build PDF now.
1 parent 9dfeb49 commit 23cd06c

File tree

8 files changed

+118
-41
lines changed

8 files changed

+118
-41
lines changed

README.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@ If you are just interested in the computational library, there is no need for ei
77

88
But what if you want both command-line interface, Web interface, all of the Pymathics libraries and whatever else there is to offer?
99

10-
That's what this repository is about. Here we have a PyPI installable package that pull in the various components and offer commands
10+
That's what this repository is about. Here we have a PyPI installable package that pull in the various components and offer commands:
1111

12-
* ``mathicsscript`` to run the command-line interface
13-
* ``mathicsserver`` to run the Django-Web server
14-
* ``dmathicsscript`` and ``dmathicsserver`` which run the docker version of these.
12+
* ``mathicsscript`` to run the command-line interface,
13+
* ``mathicsserver`` to run the Django-Web server,
14+
* ``dmathicsscript`` and ``dmathicsserver`` which runs the docker version of these,
15+
* ``dmathicssdoc`` which runs a PDF viewer, `evince <https://wiki.gnome.org/Apps/Evince>`_, which can view the generated reference manual in PDF.
16+
* ``dmathicssdoc`` which copies the the generated reference PDF manual out of the container and into the host filesystem.
1517

16-
This repository also contains the dockerfiile to create the `mathicsorg/mathics docker images <https://hub.docker.com/repository/docker/mathicsorg/mathics>`_.
18+
This repository also contains the Dockerfiles used to create the `mathicsorg/mathics docker images <https://hub.docker.com/repository/docker/mathicsorg/mathics>`_.
1719

1820
That image is a combination of:
1921

2022
* `Mathics-Scanner <https://github.com/Mathics3/mathics-scanner>`_
2123
* `mathicsscript <https://github.com/Mathics3/mathicsscript>`_
2224
* `mathics-pygments <https://github.com/Mathics3/mathics-pygments>`_
2325
* `Mathics-Django <https://github.com/Mathics3/Mathics-Django>`_
26+
* `mathics-threejs-backend <https://github.com/Mathics3/mathics-threejs-backend>`_
2427
* `pymathics-natlang <https://github.com/Mathics3/pymathics-natlang>`_
2528
* `pymathics-graph <https://github.com/Mathics3/pymathics-graph>`_
2629

__pkginfo__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
author_email = "[email protected]"
55
scripts = [
66
"script/dmathics",
7+
"script/dmathicsdoc",
8+
"script/dmathicsdoccopy",
79
"script/dmathicsserver",
810
"script/dmathicsscript",
911
"script/term-background.sh",

docker/Dockerfile

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,57 @@ RUN chmod +x /entrypoint.sh
1313
COPY requirements.txt ./
1414
RUN apt-get update
1515
RUN apt-get install -qq apt-utils
16+
1617
# we need libsqlite3-dev now if ubuntu doesn't come with that, we'll need
1718
# to build our own Python
18-
RUN DEBIAN_FRONTEND="noninteractive" TZ="US/Eastern" apt-get install -qq liblapack-dev llvm-10 llvm-10-dev gfortran maria libmysqlclient-dev sqlite3 python3-pip python3-setuptools git python3-matplotlib python-matplotlib-data x11-apps asymptote w3m latexmk texlive-xetex lmodern inkscape texlive-latex-extra texlive-fonts-recommended nodejs
19+
# Leave out inkscape for now.
20+
21+
# inxi and mesa-utils might be optional
22+
# npm puls in nodejs, but we'll be explicit.
23+
# llvm-11 and llvm-11-dev might work?
24+
25+
# Install lots of packages
26+
RUN DEBIAN_FRONTEND="noninteractive" TZ="US/Eastern" apt-get install -qq liblapack-dev llvm-10 llvm-10-dev gfortran maria libmysqlclient-dev sqlite3 python3-pip python3-setuptools git python3-numpy python3-matplotlib python-matplotlib-data x11-apps asymptote w3m latexmk texlive-xetex lmodern texlive-latex-extra texlive-fonts-recommended nodejs npm xserver-xorg-video-all libgl1-mesa-glx libgl1-mesa-dri mesa-utils evince
27+
1928
RUN pip install --no-cache-dir -r requirements.txt
2029
COPY requirements-mathicsscript.txt ./
2130
RUN pip install --no-cache-dir -r requirements-mathicsscript.txt
2231

32+
################
33+
# Mathics core #
34+
################
2335
RUN pip install "Mathics3[full]>=3.1.0"
24-
# RUN pip install git+git://github.com/mathics/Mathics.git#egg=Mathics3[full]
2536

26-
# Some time later, build mathics.pdf
27-
# We need to work around inkscape crashing due to a lack of an X11 connection.
28-
# RUN git clone https://github.com/mathics/Mathics.git
29-
# RUN (cd Mathics && ${PYTHON} ./setup.py develop && make doc)
30-
31-
# RUN DEBIAN_FRONTEND="noninteractive" TZ="US/Eastern" apt-get install -qq texlive-font-utils latexmk texlive-xetex lmodern inkscape texlive-latex-extra texlive-fonts-recommended asymptote
32-
# RUN SANDBOX=t ${PYTHON} /usr/local/lib/python3.8/dist-packages/mathics/docpipeline.py -ot
33-
# ... run latex
34-
RUN ${PYTHON} -m pip install -e git://github.com/Mathics3/mathics-django#egg=Mathics-Django[full]
37+
#####################
38+
# Mathics Pymathics #
39+
#####################
3540

3641
RUN pip install pymathics-natlang
3742
RUN pip install pymathics-graph
38-
RUN (cd src/mathics-django && ${PYTHON} mathics_django/docpipeline.py -o)
39-
RUN mkdir -p /usr/src/app/.local/var/mathics && cp -v /root/.local/var/mathics/doc_data.pcl /usr/src/app/.local/var/mathics/doc_data.pcl
4043

41-
RUN ${PYTHON} -m pip install -e git://github.com/Mathics3/mathicsscript#egg=mathicsscript[full]
42-
RUN (cd src/mathicsscript && make)
44+
##################
45+
# Mathicsscript #
46+
##################
47+
48+
RUN ${PYTHON} -m pip install -e mathicsscript[full]
4349

4450
RUN ${PYTHON} -m nltk.downloader wordnet omw
4551
RUN ${PYTHON} -m spacy download en
4652

47-
# debug stuff
53+
##################
54+
# Mathics Django #
55+
##################
56+
RUN ${PYTHON} -m pip install Mathics-Django[full]
57+
58+
##################
59+
# debug stuff #
60+
##################
4861
# RUN apt-get install -qq emacs
4962
# RUN pip install trepan3k
5063

64+
##################
65+
# Finish up #
66+
##################
5167
EXPOSE 8000
5268

5369
RUN groupadd mathics && \

docker/Dockerfile-dev

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,70 @@ RUN chmod +x /entrypoint.sh
1313
COPY requirements.txt ./
1414
RUN apt-get update
1515
RUN apt-get install -qq apt-utils
16+
1617
# we need libsqlite3-dev now if ubuntu doesn't come with that, we'll need
1718
# to build our own Python
1819
# Leave out inkscape for now.
19-
RUN DEBIAN_FRONTEND="noninteractive" TZ="US/Eastern" apt-get install -qq liblapack-dev llvm-10 llvm-10-dev gfortran maria libmysqlclient-dev sqlite3 python3-pip python3-setuptools git python3-matplotlib python-matplotlib-data x11-apps asymptote w3m latexmk texlive-xetex lmodern texlive-latex-extra texlive-fonts-recommended nodejs
20+
21+
# inxi and mesa-utils might be optional
22+
# npm puls in nodejs, but we'll be explicit.
23+
# llvm-11 and llvm-11-dev might work?
24+
25+
# Install lots of packages
26+
RUN DEBIAN_FRONTEND="noninteractive" TZ="US/Eastern" apt-get install -qq liblapack-dev llvm-10 llvm-10-dev gfortran maria libmysqlclient-dev sqlite3 python3-pip python3-setuptools git python3-numpy python3-matplotlib python-matplotlib-data x11-apps asymptote w3m latexmk texlive-xetex lmodern texlive-latex-extra texlive-fonts-recommended nodejs npm xserver-xorg-video-all libgl1-mesa-glx libgl1-mesa-dri mesa-utils evince
27+
2028
RUN pip install --no-cache-dir -r requirements.txt
2129
COPY requirements-mathicsscript.txt ./
2230
RUN pip install --no-cache-dir -r requirements-mathicsscript.txt
2331

32+
################
33+
# Mathics core #
34+
################
35+
# RUN pip install "Mathics3[full]>=3.1.0"
2436
RUN pip install git+git://github.com/mathics/Mathics.git#egg=Mathics3[full]
2537

26-
# Some time later, build mathics.pdf
27-
# We need to work around inkscape crashing due to a lack of an X11 connection.
28-
# RUN git clone https://github.com/mathics/Mathics.git
29-
# RUN (cd Mathics && ${PYTHON} ./setup.py develop && make doc)
38+
RUN git clone https://github.com/mathics/Mathics.git
39+
COPY tex-images/*.pdf Mathics/mathics/doc/tex/
40+
ENV DOC_LATEX_FILE=/usr/src/app/Mathics/mathics/doc/tex/documentation.tex
41+
RUN (cd Mathics && ${PYTHON} ./setup.py develop)
42+
RUN (cd Mathics && make texdoc || /bin/true)
3043

31-
# RUN DEBIAN_FRONTEND="noninteractive" TZ="US/Eastern" apt-get install -qq texlive-font-utils latexmk texlive-xetex lmodern inkscape texlive-latex-extra texlive-fonts-recommended asymptote
32-
# RUN SANDBOX=t ${PYTHON} /usr/local/lib/python3.8/dist-packages/mathics/docpipeline.py -ot
33-
# ... run latex
34-
RUN ${PYTHON} -m pip install -e git://github.com/Mathics3/mathics-django#egg=Mathics-Django[full]
44+
#####################
45+
# Mathics Pymathics #
46+
#####################
3547

36-
RUN pip install pymathics-natlang
3748
RUN pip install pymathics-graph
38-
RUN (cd src/mathics-django && npm install && make)
39-
RUN (cd src/mathics-django && ${PYTHON} mathics_django/docpipeline.py -o)
40-
RUN mkdir -p /usr/src/app/.local/var/mathics && cp -v /root/.local/var/mathics/doc_data.pcl /usr/src/app/.local/var/mathics/doc_data.pcl
49+
50+
# natlang installs spacy so this should come first
51+
RUN pip install pymathics-natlang
52+
RUN ${PYTHON} -m spacy download en
53+
RUN ${PYTHON} -m nltk.downloader wordnet omw
54+
55+
##################
56+
# Mathicsscript #
57+
##################
4158

4259
RUN ${PYTHON} -m pip install -e git://github.com/Mathics3/mathicsscript#egg=mathicsscript[full]
4360
RUN (cd src/mathicsscript && make)
4461

45-
RUN ${PYTHON} -m nltk.downloader wordnet omw
46-
RUN ${PYTHON} -m spacy download en
62+
##################
63+
# Mathics Django #
64+
##################
65+
RUN ${PYTHON} -m pip install -e git://github.com/Mathics3/mathics-django#egg=Mathics-Django[full]
66+
67+
RUN (cd src/mathics-django && npm install && make)
68+
RUN (cd src/mathics-django && ${PYTHON} mathics_django/docpipeline.py -o)
69+
RUN mkdir -p /usr/src/app/.local/var/mathics && cp -v /root/.local/var/mathics/doc_data.pcl /usr/src/app/.local/var/mathics/doc_data.pcl
4770

48-
# debug stuff
71+
##################
72+
# debug stuff #
73+
##################
4974
# RUN apt-get install -qq emacs
5075
# RUN pip install trepan3k
5176

77+
##################
78+
# Finish up #
79+
##################
5280
EXPOSE 8000
5381

5482
RUN groupadd mathics && \

docker/Dockerfile-dev+debug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vFROM ubuntu:focal
1+
FROM ubuntu:focal
22

33
ENV TZ=US/Eastern
44
ENV MATHICS_HOME=/usr/src/app

docker/entrypoint.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ Arg:
1919
mathics src = /usr/src/app/mathics
2020
--pythonpath /usr/src/app
2121
22-
-m | --mode {cli|ui|gui|minimal|pdf}
22+
-m | --mode {cli|ui|gui|minimal|pdf|copy}
2323
Start mathics in either:
2424
* web-ui mode (ui or gui),
2525
* cli mode (cli) or minimal.
2626
* viewing manual (pdf) or document
27+
* copy the manual mathics.pdf to the host computer
2728
Default is cli.
2829
See: https://github.com/mathics/Mathics/wiki/Installing#running-mathics
2930
@@ -35,11 +36,15 @@ EOF
3536
}
3637

3738
mathics_mode=cli
39+
COPY_DOC=0
3840

3941
while (( $# )) ; do
4042
case "$1" in
4143
-h | --help) help ; exit ;;
42-
-m | --mode) mathics_mode="$2" ; shift 2 ;;
44+
-m | --mode)
45+
mathics_mode="$2"
46+
shift 2
47+
;;
4348
--pythonpath) export PYTHONPATH="$2":$PYTHONPATH ; shift 2 ;;
4449
--) shift ; break ;;
4550
*) echo "Can't parse '$@'. See '$0 --help'" ; exit 1 ;;
@@ -55,6 +60,10 @@ case $mathics_mode in
5560
document|pdf)
5661
evince /usr/src/app/Mathics/mathics/doc/tex/mathics.pdf
5762
;;
63+
copy)
64+
echo "Copying mathics.pdf to host-attached filesystem."
65+
cp /usr/src/app/Mathics/mathics/doc/tex/mathics.pdf /usr/src/app/data/mathics.pdf
66+
;;
5867
ui|gui)
5968
echo
6069
echo "~~~~ app/data has been mounted to $MATHICS_HOME/data ~~~~"

script/dmathicsdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TAG=${TAG:-latest}
1010
MATHICS_IMAGE=${MATHICS_IMAGE:-mathicsorg/mathics:${TAG}}
1111

1212
$DOCKER run -it \
13-
--name mathics-web \
13+
--name mathics-doc \
1414
--rm \
1515
--env="DISPLAY" \
1616
--workdir=/app \

script/dmathicsdoccopy

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
if [ -n "$DEBUG" ]; then
3+
set -x
4+
fi
5+
6+
# Allow customization using POSIX environment variables:
7+
DOCKER=${DOCKER:-docker}
8+
9+
TAG=${TAG:-latest}
10+
MATHICS_IMAGE=${MATHICS_IMAGE:-mathicsorg/mathics:${TAG}}
11+
12+
$DOCKER run -it \
13+
--name mathics-copy \
14+
--rm \
15+
--workdir=/app \
16+
--volume="$PWD":/app \
17+
--volume="/tmp:/usr/src/app/data" \
18+
$MATHICS_IMAGE \
19+
--mode copy -- $@

0 commit comments

Comments
 (0)