Skip to content

Instantly share code, notes, and snippets.

@briandk
Created July 20, 2016 20:55
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save briandk/924d101f28dbf309758206fa3eff32b4 to your computer and use it in GitHub Desktop.
Save briandk/924d101f28dbf309758206fa3eff32b4 to your computer and use it in GitHub Desktop.
Instal a full latex texlive on Ubuntu Xenial without any of the docs
import subprocess
get_line_by_line_texlive_dependencies = subprocess.run(
[
"apt-cache",
"depends",
"texlive-full"
],
universal_newlines=True,
stdout=subprocess.PIPE
)
dependency_pattern = "Depends: "
def extract_dependency(dependency_text, pattern):
dependency = dependency_text.strip().replace(pattern, "")
return(dependency)
dependencies = [
extract_dependency(line, dependency_pattern)
for line in get_line_by_line_texlive_dependencies.stdout.splitlines()
if line.strip().startswith(dependency_pattern) and not line.strip().endswith("-doc")]
arguments = [
"apt-get",
"install",
"--assume-yes",
"--no-install-recommends"
]
arguments.extend(dependencies)
# execute apt-get install with all the package names
subprocess.run(arguments)
@fgolemo
Copy link

fgolemo commented Aug 31, 2017

Thank you so much! This is excellent! 👍

@zsunberg
Copy link

Very helpful! Thanks!

@sangramsingha
Copy link

Thank you so much!

@leftaroundabout
Copy link

Nice, but the same thing can be done as a shell one-liner:

apt-cache depends texlive-full | sed -n 's/^ *Depends..\(.*\)$/\1/p' | grep -v 'doc$' | sudo xargs apt-get install --no-install-recommends --assume-yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment