xpdf probs.pdf &
xpdf sols.pdf &
-%.pdf : %.tex $(SOURCE_FILES) problemlist.tex
+%.pdf : %.tex $(SOURCE_FILES) problemlist.tex python-images
pdflatex $(patsubst %.tex,%,$<)
find . -name '*.asy' -execdir asy -noprc -render=0 {} \;
pdflatex $(patsubst %.tex,%,$<)
problemlist.tex : write_problemlist.py
./$<
+python-images: problemlist.tex
+ for SCRIPT in *.py; do \
+ if [ -L "$${SCRIPT}" ]; then \
+ TARGET="$$(echo "$${SCRIPT}" | awk -F. '{print $$(NF-1)}').png"; \
+ "./$${SCRIPT}" "$${TARGET}"; \
+ fi \
+ done
+
semi-clean :
rm -f *.log *.aux *.out *.thm *.toc *.pre *-*[0-9].tex *.js *.prc *.asy
clean : semi-clean
rm -f *.pdf $(DIST_FILE) $(DIST_DIR) install*
- rm -f problemlist.tex $(shell find . -type l)
+ rm -f problemlist.tex *.png $(shell find . -type l)
$(DIST_FILE) : $(DIST_FILES)
mkdir $(DIST_DIR)
#!/usr/bin/env python
+import hashlib
import os
import os.path
_this_dir = os.path.dirname(__file__)
-def write_problemlist(problem_dir=None, blacklist=()):
+def write_problemlist(problem_dir=None, blacklist=(), symlink=False):
# remove evidence from previous runs
for name in os.listdir(_this_dir):
if os.path.islink(name):
# generate new symlinks and problemlist.tex
f = open(os.path.join(_this_dir, 'problemlist.tex'), 'w')
- i = 1
+ if symlink:
+ i = 1
for source in sorted(os.listdir(problem_dir)):
if source in blacklist:
continue
for problem in sorted(os.listdir(source_dir)):
path = os.path.join(source_dir, problem)
if os.path.isfile(path):
+ force_link = False
relpath = os.path.relpath(path, _this_dir)
if path.endswith('.tex'):
- pname = 'problem%d.tex' % i
- i += 1
+ if symlink:
+ pname = 'problem%d.tex' % i
+ i += 1
+ else:
+ pname = relpath
f.write('\\input{%s}\n' % pname)
else: # utility file (e.g. image)
- pname = problem
- os.symlink(relpath, pname)
+ pname = '.'.join(problem.split('.')[-2:])
+ if not symlink:
+ force_link = True
+ if symlink or force_link:
+ if os.path.islink(pname):
+ ha = hashlib.sha1(open(relpath, 'r').read()).digest()
+ hb = hashlib.sha1(open(pname, 'r').read()).digest()
+ assert ha == hb, (relpath, pname)
+ else:
+ os.symlink(relpath, pname)
f.close()
write_problemlist(
problem_dir=os.path.join(_this_dir, '..', 'problems'),
blacklist=[
- 'Giancoli_6',
+# 'Giancoli_6',
'Serway_and_Jewett_4',
- 'Serway_and_Jewett_4_venkat',
- 'Serway_and_Jewett_4_wking',
+# 'Serway_and_Jewett_4_venkat',
+# 'Serway_and_Jewett_4_wking',
# 'Serway_and_Jewett_8',
- 'Thornton_and_Rex_3',
- 'Thornton_and_Rex_3_wking',
- 'Young_and_Freedman_12',
- 'wking',
+# 'Thornton_and_Rex_3_wking',
+# 'Young_and_Freedman_12',
+# 'wking',
]
)