diff --git a/.gitignore b/.gitignore index a78ae461..4dafb764 100644 --- a/.gitignore +++ b/.gitignore @@ -30,5 +30,7 @@ resources/user/* *.exe +get-pip.py + venv test diff --git a/docs/BUILDING.md b/docs/BUILDING.md new file mode 100644 index 00000000..fd0233f0 --- /dev/null +++ b/docs/BUILDING.md @@ -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` diff --git a/resources/ci/common/get_get_pip.py b/resources/ci/common/get_get_pip.py new file mode 100644 index 00000000..9b69930d --- /dev/null +++ b/resources/ci/common/get_get_pip.py @@ -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() diff --git a/resources/ci/common/install.py b/resources/ci/common/install.py index 8cd40df2..70d10202 100644 --- a/resources/ci/common/install.py +++ b/resources/ci/common/install.py @@ -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() diff --git a/resources/ci/common/local_install.py b/resources/ci/common/local_install.py new file mode 100644 index 00000000..8cde8348 --- /dev/null +++ b/resources/ci/common/local_install.py @@ -0,0 +1,8 @@ +import install +import get_get_pip + +# get & install pip +get_get_pip.get_get_pip() + +# run installer +install.run_install()