38 lines
1.3 KiB
Python
Executable file
38 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
# Copyright (C) 2017 Andrew Hamilton. All rights reserved.
|
|
# Licensed under the Artistic License 2.0.
|
|
|
|
|
|
import distro
|
|
import subprocess
|
|
import tools
|
|
|
|
|
|
dist_id = distro.id()
|
|
pip_deps, pip3_deps, dist_deps = set(), set(), set()
|
|
for dependency in tools.dependencies(dist_id):
|
|
if "/" in dependency:
|
|
pip_version, pip_dependency = dependency.split("/")
|
|
(pip_deps if pip_version == "pip" else pip3_deps).add(pip_dependency)
|
|
else:
|
|
dist_deps.add(dependency)
|
|
cmd_for_dist = {"ubuntu": ["apt-get", "-y", "install"],
|
|
"debian": ["apt-get", "-y", "install"],
|
|
"fedora": ["dnf", "-y", "install"],
|
|
"arch": ["pacman", "-S", "--noconfirm", "--needed"],
|
|
"opensuse": ["zypper", "-n", "install"],
|
|
"gentoo": ["emerge", "--noreplace"]}
|
|
if dist_id == "gentoo":
|
|
dist_deps.add("pip")
|
|
else:
|
|
if pip_deps:
|
|
dist_deps.add("python2-pip" if dist_id == "arch" else "python-pip")
|
|
if pip3_deps:
|
|
dist_deps.add("python-pip" if dist_id == "arch" else "python3-pip")
|
|
if dist_deps:
|
|
subprocess.check_call(["sudo"] + cmd_for_dist[dist_id] + list(dist_deps))
|
|
if pip_deps:
|
|
subprocess.check_call(["sudo", "pip", "install"] + list(pip_deps))
|
|
if pip3_deps:
|
|
subprocess.check_call(["sudo", "pip3", "install"] + list(pip3_deps))
|