Move pypi to dib-python
The latest Fedora/Ubuntu images don't ship python2 by default, so we need to use our dib-python wrapper for this so we work in python3 only environments. This change also correctly creates the pip.conf and .pydistutils.cfg files with trusted host extracted from the index-url. Related-bug: 1577105 Change-Id: Ibb5348af3e3bbe46b19affe90a8930a4b4ad4cad Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com>
This commit is contained in:
parent
928c6e61f0
commit
ea9ab89829
1
diskimage_builder/elements/pypi/element-deps
Normal file
1
diskimage_builder/elements/pypi/element-deps
Normal file
@ -0,0 +1 @@
|
||||
dib-python
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/local/bin/dib-python
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
@ -16,6 +16,11 @@ from __future__ import print_function
|
||||
|
||||
import os.path
|
||||
|
||||
try:
|
||||
from urllib.parse import urlparse
|
||||
except ImportError:
|
||||
from urlparse import urlparse
|
||||
|
||||
|
||||
def main():
|
||||
home = os.path.expanduser("~")
|
||||
@ -49,6 +54,7 @@ def main():
|
||||
output.write('[global]\n')
|
||||
output.write('log = %s/pip.log\n' % (home,))
|
||||
output.write('index-url = %s\n' % (indices[0],))
|
||||
output.write('trusted-host = %s\n' % (urlparse(indices[0]).hostname,))
|
||||
if retries is not None:
|
||||
output.write('retries = %s\n' % retries)
|
||||
for index in indices[1:]:
|
||||
@ -56,6 +62,7 @@ def main():
|
||||
with open(home + '/.pydistutils.cfg', 'wt') as output:
|
||||
output.write('[easy_install]\n')
|
||||
output.write('index_url = %s\n' % (easy_index,))
|
||||
output.write('allow_hosts = %s\n' % (urlparse(easy_index).netloc,))
|
||||
|
||||
|
||||
def backup_configs(home):
|
Loading…
Reference in New Issue
Block a user