Multiline Run scripts, and going pretty far for python 3.8

This commit is contained in:
jpic
2020-01-26 19:54:59 +01:00
parent c88aea9ba9
commit 895f0e164b
3 changed files with 26 additions and 13 deletions
+14 -10
View File
@@ -1,17 +1,21 @@
class Pip:
def __init__(self, *pip_packages):
def __init__(self, *pip_packages, pip=None):
self.pip_packages = pip_packages
self.pip = pip
def build(self, script):
script.append(f'''
if {script._run("bash -c 'type pip3'")}; then
_pip=pip3
elif {script._run("bash -c 'type pip'")}; then
_pip=pip
elif {script._run("bash -c 'type pip2'")}; then
_pip=pip2
fi
''')
if self.pip:
script.append('_pip=' + self.pip)
else:
script.append(f'''
if {script._run("bash -c 'type pip3'")}; then
_pip=pip3
elif {script._run("bash -c 'type pip'")}; then
_pip=pip
elif {script._run("bash -c 'type pip2'")}; then
_pip=pip2
fi
''')
script.mount('.cache/pip', '/root/.cache/pip')
script.run('sudo $_pip install --upgrade pip')
source = [p for p in self.pip_packages if p.startswith('/')]
+3 -1
View File
@@ -4,4 +4,6 @@ class Run:
def build(self, script):
for command in self.commands:
script.run(command)
for line in command.split('\n'):
if line.strip():
script.run(line.strip())