Skip to content

Commit 3a22234

Browse files
committed
Polish the various utility scripts
Use argparse for more friendly argument parsing, and rename script files so that they can be put on PATH. Add them as script files in setup.py, and install also sagetexparse.py module.
1 parent bf38e72 commit 3a22234

File tree

5 files changed

+199
-198
lines changed

5 files changed

+199
-198
lines changed

.gitignore

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,26 @@ E2.sobj
1414
auto/
1515
dist/
1616
example.synctex.gz
17-
extractsagecode.py
1817
makecmds.sty
19-
makestatic.py
20-
remote-sagetex.py
21-
run-sagetex-if-necessary.py
18+
sagetex-extract
19+
sagetex-extract.py
20+
sagetex-makestatic
21+
sagetex-makestatic.py
22+
sagetex-remote
23+
sagetex-remote.py
24+
sagetex-run
25+
sagetex-run.py
2226
sage-plots-for-*.tex/
2327
sagetex.glo
2428
sagetex.gls
2529
sagetex.idx
2630
sagetex.ilg
2731
sagetex.ind
2832
sagetex.py
29-
sagetex.pyc
3033
sagetex.sty
3134
sagetexparse.py
35+
*.pyc
36+
__pycache__
3237
.*.sage-history
3338
.*.sage-chat
3439
MANIFEST

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ pkg=sagetex
22
dtxs=$(wildcard *.dtx)
33
# the subdir stuff makes the tarball have the directory correct
44
srcs=example.tex README sagetex.ins
5+
pyscripts=sagetex-run sagetex-extract sagetex-makestatic sagetex-remote
56

67
.SUFFIXES:
78

8-
all: sagetex.sty sagetex.py example.pdf $(pkg).pdf
9+
all: sagetex.sty sagetex.py $(pyscripts) $(pkg).pdf example.pdf
910

1011
# just depend on the .ind file, since we'll make the .gls and .ind together;
1112
# TEXOPTS is used by spkg-install to specify nonstopmode when building docs
@@ -35,14 +36,18 @@ sagetex.sty: py-and-sty.dtx $(pkg).dtx
3536
sagetex.py: py-and-sty.dtx $(pkg).dtx
3637
yes | latex $(TEXOPTS) $(pkg).ins
3738

38-
remote-sagetex.py: remote-sagetex.dtx
39+
sagetex-remote.py: remote-sagetex.dtx
3940
yes | latex $(TEXOPTS) $(pkg).ins
4041

41-
run-sagetex-if-necessary.py makestatic.py extractsagecode.py sagetexparse.py: scripts.dtx
42+
sagetex-run.py sagetex-extract.py sagetex-makestatic.py sagetexparse.py: scripts.dtx
4243
yes | latex $(TEXOPTS) $(pkg).ins
4344

45+
%: %.py
46+
cp -f $< $@
47+
chmod +x $@
48+
4449
clean: auxclean
45-
rm -fr sage-plots-for-* E2.sobj *.pyc sagetex.tar.gz sagetex.py sagetex.pyc sagetex.sty makestatic.py sagetexparse.py extractsagecode.py dist MANIFEST remote-sagetex.py auto *_doctest.sage *_doctest.sage.py example-*.table run-sagetex-if-necessary.py __pycache__
50+
rm -fr sage-plots-for-* E2.sobj *.pyc sagetex.tar.gz sagetex.py sagetexparse.py $(pyscripts) $(addsuffix .py,$(pyscripts)) sagetex.sty dist MANIFEST remote-sagetex.py auto *_doctest.sage *_doctest.sage.py example-*.table __pycache__
4651

4752
auxclean:
4853
/bin/bash -c "rm -f {$(pkg),example}.{glo,gls,aux,out,toc,dvi,pdf,ps,log,ilg,ind,idx,fdb_latexmk,sagetex.*}"
@@ -54,5 +59,5 @@ test:
5459
./test
5560

5661
# make a source distribution, used for building the spkg
57-
dist: sagetex.sty
62+
dist: sagetex.sty $(pypkg) $(pyscripts)
5863
python setup.py sdist --formats=gztar

sagetex.ins

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,17 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
8484
\from{py-and-sty.dtx}{python}}}
8585
\generate{\file{sagetexparse.py}{\from{scripts.dtx}{parsermod}}}
8686

87-
8887
\usedir{scripts/sagetex}
8988

9089
% Now define a new preamble with the shebang line at the top.
9190

9291
\def\envpypreamble{\hash!/usr/bin/env python^^J\pypreamble}
9392
\usepreamble\envpypreamble
9493

95-
\generate{\file{run-sagetex-if-necessary.py}{\from{scripts.dtx}{ifnecessaryscript}}}
96-
\generate{\file{makestatic.py}{\from{scripts.dtx}{staticscript}}}
97-
\generate{\file{extractsagecode.py}{\from{scripts.dtx}{extractscript}}}
98-
\generate{\file{remote-sagetex.py}{\from{remote-sagetex.dtx}{remotesagetex}}}
94+
\generate{\file{sagetex-run.py}{\from{scripts.dtx}{ifnecessaryscript}}}
95+
\generate{\file{sagetex-makestatic.py}{\from{scripts.dtx}{staticscript}}}
96+
\generate{\file{sagetex-extract.py}{\from{scripts.dtx}{extractscript}}}
97+
\generate{\file{sagetex-remote.py}{\from{remote-sagetex.dtx}{remotesagetex}}}
9998

10099
\obeyspaces
101100
\Msg{******************************************************************}

0 commit comments

Comments
 (0)