Skip to content

Commit

Permalink
runplan suport pypi index_url
Browse files Browse the repository at this point in the history
  • Loading branch information
guyingzhao committed Aug 2, 2019
1 parent d260263 commit 569527d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions testbase/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,11 @@ class VirtuelEnv(object):

VENV_ENV_NAME = "QTAF_VENV"

def __init__(self, dist_pkg_path, path=None, recreate=False):
def __init__(self, dist_pkg_path, path=None, recreate=False, index_url=None):
self._dist_pkg_path = dist_pkg_path
self._venv = path
self._recreate_venv = recreate
self._index_url = index_url

def activate(self):
"""activate virtuelenv on current processs
Expand Down Expand Up @@ -284,10 +285,22 @@ def activate(self):
with open(activation_script) as fd:
exec(fd.read(), dict(__file__=activation_script))
if created:
subprocess.call(["pip", "install", self._dist_pkg_path], close_fds=True)
print("install requires")
if not self._index_url:
subprocess.call(["pip", "install", self._dist_pkg_path], close_fds=True)
else:
host = self._index_url.split("/")[2].split(":")[0]
cmdline = ["pip", "install", "-i", self._index_url,
"--trusted-host", host, self._dist_pkg_path]
print(cmdline)
subprocess.call(cmdline, close_fds=True)
else:
print("skipping requires")

os.environ[self.VENV_ENV_NAME] = "1"
argv = list(sys.argv)
path_list = "\n".join(os.environ["PATH"].split(":"))
print(path_list)
argv[0] = "qta-manage-venv"
subprocess.call(argv, close_fds=True)
sys.exit(0)
1 change: 1 addition & 0 deletions testbase/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ class RunPlanDistPackage(Command):

parser.add_argument("--disable-run-on-child", help="do not create child process to run", action="store_true")

parser.add_argument("--index-url", help="pypi index url for pip")
parser.add_argument("package", help="QTA sdist package")
parser.add_argument("plan", help="designate a test plan to run")

Expand Down

0 comments on commit 569527d

Please sign in to comment.