Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Update install_custom_python.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Jan 3, 2019
1 parent f77771b commit 787841c
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/pymyinstall/installcustom/install_custom_python.py
Expand Up @@ -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"):
Expand Down

0 comments on commit 787841c

Please sign in to comment.