Make a simpler installer script

This commit is contained in:
Mike A. Trethewey
2020-11-11 00:08:42 -08:00
parent d3cde6c901
commit 5f2b4041f9
5 changed files with 85 additions and 20 deletions

2
.gitignore vendored
View File

@@ -30,5 +30,7 @@ resources/user/*
*.exe
get-pip.py
venv
test

13
docs/BUILDING.md Normal file
View File

@@ -0,0 +1,13 @@
# Running from source
1. Get [python](http://python.org/downloads)
1. Get the [Door Randomizer Unstable source code](https://github.com/Aerinon/ALttPDoorRandomizer/archive/DoorDevUnstable.zip)
1. Install Platform-specific dependencies
1. Run `DoorRandomizer.py` for command-line script
1. Run `Gui.py` for user interface
## Platform-specific dependencies
### Windows
* Run `resources/ci/common/local_install.py`

View File

@@ -0,0 +1,39 @@
import common
import urllib.request, ssl
import subprocess # do stuff at the shell level
env = common.prepare_env()
def get_get_pip():
print("Getting pip getter!")
#make the request!
url = "https://bootstrap.pypa.io/get-pip.py"
context = ssl._create_unverified_context()
req = urllib.request.urlopen(url, context=context)
got_pip = req.read().decode("utf-8")
with open("get-pip.py", "w") as g:
req = urllib.request.Request(
url,
data=None,
headers={
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
}
)
req = urllib.request.urlopen(req, context=context)
data = req.read().decode("utf-8")
g.write(data)
# get executables
# python
# linux/windows: python
# macosx: python3
PYTHON_EXECUTABLE = "python3" if "osx" in env["OS_NAME"] else "python"
print("Getting pip!")
subprocess.check_call([PYTHON_EXECUTABLE,"get-pip.py"])
if __name__ == "__main__":
try:
import pip
except ImportError:
get_get_pip()

View File

@@ -1,27 +1,30 @@
import common
import os # for env vars
import subprocess # do stuff at the shell level
env = common.prepare_env()
# get executables
# python
# linux/windows: python
# macosx: python3
# pip
# linux/macosx: pip3
# windows: pip
PYTHON_EXECUTABLE = "python3" if "osx" in env["OS_NAME"] else "python"
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
def run_install():
# get executables
# python
# linux/windows: python
# macosx: python3
# pip
# linux/macosx: pip3
# windows: pip
PYTHON_EXECUTABLE = "python3" if "osx" in env["OS_NAME"] else "python"
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
# upgrade pip
subprocess.check_call([PYTHON_EXECUTABLE,"-m","pip","install","--upgrade","pip"])
# upgrade pip
subprocess.check_call([PYTHON_EXECUTABLE,"-m","pip","install","--upgrade","pip"])
# pip version
subprocess.check_call([PIP_EXECUTABLE,"--version"])
# if pip3, install wheel
if PIP_EXECUTABLE == "pip3":
subprocess.check_call([PIP_EXECUTABLE,"install","-U","wheel"])
# install listed dependencies
subprocess.check_call([PIP_EXECUTABLE,"install","-r","./resources/app/meta/manifests/pip_requirements.txt"])
# pip version
subprocess.check_call([PIP_EXECUTABLE,"--version"])
# if pip3, install wheel
if PIP_EXECUTABLE == "pip3":
subprocess.check_call([PIP_EXECUTABLE,"install","-U","wheel"])
# install listed dependencies
subprocess.check_call([PIP_EXECUTABLE,"install","-r","./resources/app/meta/manifests/pip_requirements.txt"])
if __name__ == "__main__":
run_install()

View File

@@ -0,0 +1,8 @@
import install
import get_get_pip
# get & install pip
get_get_pip.get_get_pip()
# run installer
install.run_install()