From 787841cb15db57c6136452aa86580bd68efeb272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xavier=20dupr=C3=A9?= Date: Thu, 3 Jan 2019 11:51:32 +0100 Subject: [PATCH] Update install_custom_python.py --- .../installcustom/install_custom_python.py | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/pymyinstall/installcustom/install_custom_python.py b/src/pymyinstall/installcustom/install_custom_python.py index 502bd139..33a1c301 100644 --- a/src/pymyinstall/installcustom/install_custom_python.py +++ b/src/pymyinstall/installcustom/install_custom_python.py @@ -277,21 +277,34 @@ def clean_err(err): raise RuntimeError( "Issue with running '{0}'\n--OUT--\n{1}\n--ERR--\n{2}\n--IN--\n{3}".format(cmd, out, err, pyinstall)) + # has pip? + if sys.platform.startswith("win"): + pyexe = os.path.join(temp_folder, "python.exe") + else: + pyexe = os.path.join(temp_folder, "bin", "python") + cmd = "{0} -m pip --help" + try: + _, err = run_cmd(cmd, wait=True) + has_pip = not err + except Exception: + has_pip = False + # get-pip - if not custom: + if not has_pip: get_pip = "https://bootstrap.pypa.io/get-pip.py" outfile_pip = os.path.join(temp_folder, "get-pip.py") download_file(get_pip, outfile_pip, fLOG=fLOG) # following issue https://github.com/pypa/get-pip/issues/7 - vers = "%d%d" % sys.version_info[:2] - if vers in ("36", "37"): - pth = os.path.join(temp_folder, "python%s._pth" % vers) - with open(pth, "r") as f: - content = f.read() - content = content.replace("#import site", "import site") - with open(pth, "w") as f: - f.write(content) + if sys.platform.startswith("win"): + vers = "%d%d" % sys.version_info[:2] + if vers in ("36", "37"): + pth = os.path.join(temp_folder, "python%s._pth" % vers) + with open(pth, "r") as f: + content = f.read() + content = content.replace("#import site", "import site") + with open(pth, "w") as f: + f.write(content) # run get-pip.py if sys.platform.startswith("win"):