Skip to content

Commit

Permalink
now using newer pycommons and explained virtual environments
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasWeise committed Sep 20, 2024
1 parent 7411d3e commit 4c528a6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 28 deletions.
29 changes: 27 additions & 2 deletions latexgit.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
\ProvidesFile{latexgit.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]%
%<package>\ProvidesPackage{latexgit}[2024/08/07 0.8.5 Improved Examples.]%
%<package>\ProvidesPackage{latexgit}[2024/09/20 0.8.6 Documentation for the Case of Virtual Environments.]%
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{latexgit}[2024/08/01]
\usepackage{latexgit}[2024/09/20]
%
\usepackage{xcolor}%
\usepackage[%
Expand Down Expand Up @@ -110,6 +110,7 @@ backgroundcolor=\color{black!10!yellow!5!white}%
% \changes{0.8.3}{2024/08/01}{supporting arbitrary commands via the new latexgit\_py version}
% \changes{0.8.4}{2024/08/02}{improved build process}
% \changes{0.8.5}{2024/08/07}{improved examples: added an example with multiple git command results}
% \changes{0.8.6}{2024/09/20}{the use case of virtual environments in conjunction with the latexgit Python package of version 0.8.17 or greater is documented}
%
% \GetFileInfo{latexgit.dtx}
%
Expand Down Expand Up @@ -401,6 +402,30 @@ backgroundcolor=\color{black!10!yellow!5!white}%
% After this, in the next pass of |pdflatex|, |\gitFile| and |\gitUrl| will
% contain the right paths and URLs.
%
% \subsection{A Note on Virtual Environments}%
% The following only applies if you have installed this package inside a virtual
% environment. It also only applies in conjunction with version
% \href{https://pypi.org/project/latexgit/0.8.17/}{0.8.17} or newer of the latexgit
% Python package.
%
% If you are running this package inside a virtual environment, it is important
% that you create this environment using the |--copies| setting and \emph{not} using
% the (default) |--symlinks| parameter.
% In other words, you should have created the virtual environment as follows,
% where |venvDir| is the directory inside of which the virtual environment is
% created.
%
% \begin{center}
% |python3 -m venv --copies venvDir|
% \end{center}
%
% If you create the environment like this (and activated), then our package will
% automatically pick it up and use its Python interpreter for any invocation of
% |python3| or |python3.x| (where |x| is the minor version of the interpreter).
% If you use the |--symlinks| parameter to create the environment, then invocations
% of the Python interpreter from our package may instead result in the system's
% Python interpreter.
%
% \section{Provided Macros}\label{sec:providedMacros}%
%
% Here we discuss the macros that can directly be accessed by the user to
Expand Down
48 changes: 25 additions & 23 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rm -rf website || true
rm latexgit.aux || true
rm latexgit.glo || true
rm latexgit.gls || true
rm latexgit.hd || true
rm latexgit.idx || true
rm latexgit.ilg || true
rm latexgit.ind || true
Expand All @@ -37,18 +38,18 @@ echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Done deleting all temporary, intermediate,
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We setup a virtual environment in a temp directory."
venvDir="$(mktemp -d)"
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Got temp dir '$venvDir', now creating environment in it."
python3 -m venv --system-site-packages "$venvDir"
python3 -m venv --system-site-packages --copies "$venvDir"
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Activating virtual environment in '$venvDir'."
. "$venvDir/bin/activate"
source "$venvDir/bin/activate"
export PYTHON_INTERPRETER="$venvDir/bin/python3"
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Setting python interpreter to '$PYTHON_INTERPRETER'."

echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Initialization: first install required packages from requirements.txt."
pip install --no-input --timeout 360 --retries 100 -r requirements.txt
"$PYTHON_INTERPRETER" -m pip install --no-input --timeout 360 --retries 100 -r requirements.txt
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Finished installing required packages from requirements.txt, now installing packages required for development from requirements-dev.txt."
pip install --no-input --timeout 360 --retries 100 -r requirements-dev.txt
"$PYTHON_INTERPRETER" -m pip install --no-input --timeout 360 --retries 100 -r requirements-dev.txt
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Finished installing requirements from requirements-dev.txt, now printing all installed packages."
pip freeze
"$PYTHON_INTERPRETER" -m pip freeze
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Finished printing all installed packages."

echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Now extracting the package."
Expand All @@ -60,48 +61,48 @@ echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Now building the examples."
cp latexgit.sty examples
cd examples
pdflatex example_1.tex
python3 -m latexgit.aux example_1
"$PYTHON_INTERPRETER" -m latexgit.aux example_1
pdflatex example_1.tex
rm example_1.log
rm example_1.aux
rm example_1.latexgit.dummy
pdflatex example_2.tex
python3 -m latexgit.aux example_2
"$PYTHON_INTERPRETER" -m latexgit.aux example_2
pdflatex example_2.tex
rm example_2.log
rm example_2.aux
rm example_2.latexgit.dummy
rm example_2.out
pdflatex example_3.tex
python3 -m latexgit.aux example_3
"$PYTHON_INTERPRETER" -m latexgit.aux example_3
pdflatex example_3.tex
rm example_3.log
rm example_3.aux
rm example_3.latexgit.dummy
rm example_3.out
pdflatex example_4.tex
python3 -m latexgit.aux example_4
"$PYTHON_INTERPRETER" -m latexgit.aux example_4
pdflatex example_4.tex
rm example_4.log
rm example_4.aux
rm example_4.latexgit.dummy
rm example_4.out
pdflatex example_5.tex
python3 -m latexgit.aux example_5
"$PYTHON_INTERPRETER" -m latexgit.aux example_5
pdflatex example_5.tex
rm example_5.log
rm example_5.aux
rm example_5.latexgit.dummy
rm example_5.out
pdflatex example_6.tex
python3 -m latexgit.aux example_6
"$PYTHON_INTERPRETER" -m latexgit.aux example_6
pdflatex example_6.tex
rm example_6.log
rm example_6.aux
rm example_6.latexgit.dummy
rm example_6.out
pdflatex example_7.tex
python3 -m latexgit.aux example_7
"$PYTHON_INTERPRETER" -m latexgit.aux example_7
pdflatex example_7.tex
rm example_7.log
rm example_7.aux
Expand Down Expand Up @@ -134,13 +135,13 @@ PART_A='<!DOCTYPE html><html><title>'
PART_B='</title><style>code {background-color:rgb(204 210 95 / 0.3);white-space:nowrap;border-radius:3px}</style><body style="margin-left:5%;margin-right:5%">'
PART_C='</body></html>'
BASE_URL='https\:\/\/thomasweise\.github\.io\/latexgit_tex\/'
echo "${PART_A}latexgit ${version}${PART_B}$(python3 -m markdown -o html ./README.md)$PART_C" > ./website/index.html
echo "${PART_A}latexgit ${version}${PART_B}$("$PYTHON_INTERPRETER" -m markdown -o html ./README.md)$PART_C" > ./website/index.html
sed -i "s/\"$BASE_URL/\".\//g" ./website/index.html
sed -i "s/=$BASE_URL/=.\//g" ./website/index.html
sed -i "s/<\/h1>/<\/h1><h2>version\&nbsp;${version} build on\&nbsp;$(date +'%0Y-%0m-%0d %0R:%0S')<\/h2>/g" ./website/index.html
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Finished copying README.md to index.html, now minifying all files."
cd "website/"
find -type f -name "*.html" -exec python3 -c "print('{}');import minify_html;f=open('{}','r');s=f.read();f.close();s=minify_html.minify(s,do_not_minify_doctype=True,ensure_spec_compliant_unquoted_attribute_values=True,keep_html_and_head_opening_tags=False,minify_css=True,minify_js=True,remove_bangs=True,remove_processing_instructions=True);f=open('{}','w');f.write(s);f.close()" \;
find -type f -name "*.html" -exec "$PYTHON_INTERPRETER" -c "print('{}');import minify_html;f=open('{}','r');s=f.read();f.close();s=minify_html.minify(s,do_not_minify_doctype=True,ensure_spec_compliant_unquoted_attribute_values=True,keep_html_and_head_opening_tags=False,minify_css=True,minify_js=True,remove_bangs=True,remove_processing_instructions=True);f=open('{}','w');f.write(s);f.close()" \;
cd "../"
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Finished minifying all files, now copying or moving remaining files."
mv latexgit.sty website
Expand Down Expand Up @@ -180,16 +181,17 @@ cd "$currentDir"
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Done building latexgit.tds.zip."

echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Deleting all temporary and intermediate files after the build."
rm latexgit.aux
rm latexgit.glo
rm latexgit.gls
rm latexgit.idx
rm latexgit.ilg
rm latexgit.ind
rm latexgit.aux || true
rm latexgit.glo || true
rm latexgit.gls || true
rm latexgit.hd || true
rm latexgit.idx || true
rm latexgit.ilg || true
rm latexgit.ind || true
rm latexgit.latexgit.dummy || true
rm latexgit.log
rm latexgit.out
rm latexgit.toc
rm latexgit.log || true
rm latexgit.out || true
rm latexgit.toc || true
rm -rf examples/*.log
rm -rf examples/*.aux
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Done deleting all temporary and intermediate files after the build."
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
minify_html == 0.15.0

# for converting the additional markdown files to HTML
markdown == 3.6
markdown == 3.7

# for converting files to HTML
Pygments==2.18.0
Pygments == 2.18.0
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# You can find it at https://thomasweise.github.io/latexgit_py,
# https://github.com/thomasWeise/latexgit_py, or at
# https://pypi.org/project/latexgit.
latexgit == 0.8.14
latexgit == 0.8.17

0 comments on commit 4c528a6

Please sign in to comment.