Add pathing intelligence

This commit is contained in:
Mike A. Trethewey
2021-03-17 17:50:51 -07:00
parent ed2813c85e
commit d6a433e467
4 changed files with 99 additions and 47 deletions

View File

@@ -1,5 +1,7 @@
import common
import argparse
import os
import platform
import subprocess # do stuff at the shell level
env = common.prepare_env()
@@ -12,7 +14,9 @@ def run_install(PY_VERSION,USER):
# pip
# linux/macosx: pip3
# windows: pip
PYTHON_PATH = env["PYTHON_EXE_PATH"]
PYTHON_EXECUTABLE = "python3" if "osx" in env["OS_NAME"] else "python"
PIP_PATH = env["PIP_EXE_PATH"]
PIP_EXECUTABLE = "pip" if "windows" in env["OS_NAME"] else "pip3"
PIP_EXECUTABLE = "pip" if "osx" in env["OS_NAME"] and "actions" in env["CI_SYSTEM"] else PIP_EXECUTABLE
@@ -23,13 +27,17 @@ def run_install(PY_VERSION,USER):
if float(PY_VERSION) > 0:
PYTHON_EXECUTABLE = "py"
print("Installing to Python %.1f" % float(PY_VERSION))
if USER:
print("Installing packages at User level")
PYTHON_PATH = env["PY_EXE_PATH"]
print("Installing to Python %.1f via Py Launcher" % float(PY_VERSION))
else:
print("Installing to Python %s" % platform.python_version())
print("Installing packages at %s level" % ("User" if USER else "Global"))
print()
print("Upgrading pip-")
# upgrade pip
args = [
PYTHON_EXECUTABLE,
PYTHON_PATH + PYTHON_EXECUTABLE,
'-' + str(PY_VERSION),
"-m",
"pip",
@@ -44,12 +52,11 @@ def run_install(PY_VERSION,USER):
del args[1]
subprocess.check_call(args)
# pip version
subprocess.check_call([PIP_EXECUTABLE,"--version"])
# if pip3, install wheel
if PIP_EXECUTABLE == "pip3":
print("Installing Wheel!")
args = [
PIP_EXECUTABLE,
PIP_PATH + PIP_EXECUTABLE,
"install",
"--user",
"-U",
@@ -58,9 +65,13 @@ def run_install(PY_VERSION,USER):
if not USER:
args.remove("--user")
subprocess.check_call(args)
print()
# install listed dependencies
print("Installing dependencies")
print("-----------------------")
args = [
PIP_EXECUTABLE,
PIP_PATH + PIP_EXECUTABLE,
"install",
"--user",
"-r",