I use a Docker container to build SymPy cat <<EOF >> Dockerfile FROM phusion/baseimage:0.11 RUN apt-get update && \ apt-get install -y \ vim \ python3 python3-pip python3-dev \ wget \ default-jre \ && rm -rf /var/lib/apt/lists/* WORKDIR /usr/local/lib RUN curl -O https://www.antlr.org/download/antlr-4.7.2-complete.jar COPY sympy/ /opt/ RUN echo "alias python=python3" > /root/.bashrc RUN ln -s /usr/bin/python3.6 /usr/bin/python # import the pip package for integration of grammar with Python RUN pip3 install antlr4-python3-runtime mpmath # build antlr grammar WORKDIR /opt/sympy/parsing/latex ENV CLASSPATH=".:/usr/local/lib/antlr-4.7.2-complete.jar:$CLASSPATH" RUN java -jar /usr/local/lib/antlr-4.7.2-complete.jar LaTeX.g4 -no-visitor -no-listener -o _antlr # from msgoff COPY rename.py /opt/sympy/parsing/latex RUN python3 rename.py # set up Sympy WORKDIR /opt/ RUN python3 setup.py install EOF
A second file, created by msgoff, is used for the Antlr build process cat <<EOF >> rename.py import glob import os output_dir = "_antlr" for path in glob.glob(os.path.join(output_dir, "LaTeX*.*")) + glob.glob( os.path.join(output_dir, "latex*.*")): offset = 0 new_path = os.path.join(output_dir, os.path.basename(path).lower()) with open(path, "r") as f: lines = [line.rstrip() + "\n" for line in f.readlines()] os.unlink(path) with open(new_path, "w") as out_file: if path.endswith(".py"): offset = 2 out_file.write(header) out_file.writelines(lines[offset:]) EOF
Inside the container,
cd /scratch/sympy/sympy/parsing/latex java -jar /usr/local/lib/antlr-4.7.2-complete.jar LaTeX.g4 -no-visitor -no-listener -o _antlr python rename.py Now rebuild sympy cd /scratch/sympy/ python setup.py install leave the container exit On the host, add the build artifacts for Antlr cd sympy/ git status git add sympy/parsing/latex/_antlr/latexlexer.py sympy/parsing/latex/_antlr/latexparser.py