This commit is contained in:
ahmadbilalkhalid 2019-09-12 13:20:28 +05:00
parent b5256d1931
commit b6da0e3c93
7 changed files with 28 additions and 6 deletions

View file

@ -53,7 +53,7 @@ def setup(path, auth_name, auth_seed, auth_realm,
dst=os.path.join(repo_name, "ucloud_common", "etcd3_wrapper"), dst=os.path.join(repo_name, "ucloud_common", "etcd3_wrapper"),
) )
install_available(os.path.join(repo_name, "Pipfile")) install_available(repo_name)
# Create virtualenv with site-packages enabled and install all dependencies # Create virtualenv with site-packages enabled and install all dependencies
sp.check_output(['pipenv','--site-packages', '--python', '3'], cwd=repo_name) sp.check_output(['pipenv','--site-packages', '--python', '3'], cwd=repo_name)

View file

@ -35,7 +35,7 @@ def setup(path, base_dir, file_prefix, etcd_url):
# Clone etcd wrapper # Clone etcd wrapper
clone_etcd_wrapper(path=repo_name) clone_etcd_wrapper(path=repo_name)
install_available(os.path.join(repo_name, "Pipfile")) install_available(repo_name)
# Create virtualenv with site-packages enabled and install all dependencies # Create virtualenv with site-packages enabled and install all dependencies
sp.check_output(['pipenv','--site-packages', '--python', '3'], cwd=repo_name) sp.check_output(['pipenv','--site-packages', '--python', '3'], cwd=repo_name)

View file

@ -2,10 +2,11 @@ import subprocess as sp
import subprocess as sp import subprocess as sp
import requests import requests
import json import json
import os
from decouple import config from decouple import config
def install_available(pipfile): # def install_available(pipfile):
""" Install Python packages or their dependencies mentioned in """ Install Python packages or their dependencies mentioned in
pipfile if they are available in System repos pipfile if they are available in System repos
""" """
@ -55,6 +56,20 @@ def install_available(pipfile):
except: except:
print(f"Could not install {package}") print(f"Could not install {package}")
def install_available(project_path):
if get_distro_name() == "alpine":
sp.check_output(['pipenv', 'lock'])
with open(os.path.join(project_path, "Pipfile.lock")) as f:
content = json.load(f)
for package in content["default"].keys():
try:
sp.check_output(["apk", "add", f"py3-{package}"])
except Exception:
pass
def clone_common(path='.'): def clone_common(path='.'):
sp.check_output(['git', 'clone', sp.check_output(['git', 'clone',
f'https://code.ungleich.ch/ungleich-public/ucloud_common'], cwd=path) f'https://code.ungleich.ch/ungleich-public/ucloud_common'], cwd=path)

View file

@ -49,7 +49,7 @@ def setup(path, ssh_username, ssh_key_path, ssh_key_pass, etcd_url, without_ceph
dst=os.path.join(repo_name, "ucloud_common", "etcd3_wrapper"), dst=os.path.join(repo_name, "ucloud_common", "etcd3_wrapper"),
) )
install_available(os.path.join(repo_name, "Pipfile")) install_available(repo_name)
# Create virtualenv with site-packages enabled and install all dependencies # Create virtualenv with site-packages enabled and install all dependencies
sp.check_output(['pipenv','--site-packages', '--python', '3'], cwd=repo_name) sp.check_output(['pipenv','--site-packages', '--python', '3'], cwd=repo_name)

View file

@ -35,7 +35,7 @@ def setup(path, base_dir, etcd_url, without_ceph):
clone_etcd_wrapper(path=repo_name) clone_etcd_wrapper(path=repo_name)
install_available(os.path.join(repo_name, "Pipfile")) install_available(repo_name)
# Create virtualenv with site-packages enabled and install all dependencies # Create virtualenv with site-packages enabled and install all dependencies
sp.check_output(['pipenv','--site-packages', '--python', '3'], cwd=repo_name) sp.check_output(['pipenv','--site-packages', '--python', '3'], cwd=repo_name)

View file

@ -47,7 +47,7 @@ def setup(path, vm_prefix, host_prefix, request_prefix, etcd_url):
dst=os.path.join(repo_name, "ucloud_common", "etcd3_wrapper"), dst=os.path.join(repo_name, "ucloud_common", "etcd3_wrapper"),
) )
install_available(os.path.join(repo_name, "Pipfile")) install_available(repo_name)
# Create virtualenv with site-packages enabled and install all dependencies # Create virtualenv with site-packages enabled and install all dependencies
sp.check_output(['pipenv','--site-packages', '--python', '3'], cwd=repo_name) sp.check_output(['pipenv','--site-packages', '--python', '3'], cwd=repo_name)

7
test.py Normal file
View file

@ -0,0 +1,7 @@
import json
import os
with open(os.path.expanduser("~/Desktop/code/ucloud-vm/Pipfile.lock")) as f:
# content = f.read()
content = json.load(f)
print(content["default"].keys())