Merge branch 'DoorDevUnstable' into BombSwitchDevUnstable

This commit is contained in:
StructuralMike
2021-03-18 23:19:20 +01:00
18 changed files with 311 additions and 102 deletions

View File

@@ -27,15 +27,15 @@ jobs:
strategy: strategy:
matrix: matrix:
os-name: [ ubuntu-latest, ubuntu-18.04, macOS-latest, windows-latest ] os-name: [ ubuntu-latest, ubuntu-18.04, macOS-latest, windows-latest ]
python-version: [ 3.8 ] python-version: [ 3.9 ]
# needs: [ install-test ] # needs: [ install-test ]
steps: steps:
# checkout commit # checkout commit
- name: Checkout commit - name: Checkout commit
uses: actions/checkout@v1 uses: actions/checkout@v2
# install python # install python
- name: Install python - name: Install python
uses: actions/setup-python@v1 uses: actions/setup-python@v2
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
architecture: "x64" architecture: "x64"
@@ -48,6 +48,28 @@ jobs:
run: | run: |
python ./resources/ci/common/install.py python ./resources/ci/common/install.py
pip install pyinstaller pip install pyinstaller
# get parent directory
- name: Get Repo Name
uses: mad9000/actions-find-and-replace-string@1
id: repoName
with:
source: ${{ github.repository }}
find: '${{ github.repository_owner }}/'
replace: ''
- name: Get Parent Directory Path (!Windows)
uses: mad9000/actions-find-and-replace-string@1
id: parentDirNotWin
with:
source: ${{ github.workspace }}
find: '${{ steps.repoName.outputs.value }}/${{ steps.repoName.outputs.value }}'
replace: ${{ steps.repoName.outputs.value }}
- name: Get Parent Directory Path (Windows)
uses: mad9000/actions-find-and-replace-string@1
id: parentDir
with:
source: ${{ steps.parentDirNotWin.outputs.value }}
find: '${{ steps.repoName.outputs.value }}\${{ steps.repoName.outputs.value }}'
replace: ${{ steps.repoName.outputs.value }}
# try to get UPX # try to get UPX
- name: Get UPX - name: Get UPX
env: env:
@@ -70,10 +92,10 @@ jobs:
python ./resources/ci/common/prepare_binary.py python ./resources/ci/common/prepare_binary.py
# upload binary artifacts for later step # upload binary artifacts for later step
- name: Upload Binary Artifacts - name: Upload Binary Artifacts
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v2
with: with:
name: binaries-${{ matrix.os-name }} name: binaries-${{ matrix.os-name }}
path: ../artifact path: ${{ steps.parentDir.outputs.value }}/artifact
# Install & Preparing Release # Install & Preparing Release
# Set up environment # Set up environment
@@ -87,18 +109,18 @@ jobs:
# os & python versions # os & python versions
strategy: strategy:
matrix: matrix:
# install/release on not xenial # install/release on not bionic
os-name: [ ubuntu-latest, ubuntu-18.04, macOS-latest, windows-latest ] os-name: [ ubuntu-latest, ubuntu-18.04, macOS-latest, windows-latest ]
python-version: [ 3.8 ] python-version: [ 3.9 ]
needs: [ install-build ] needs: [ install-build ]
steps: steps:
# checkout commit # checkout commit
- name: Checkout commit - name: Checkout commit
uses: actions/checkout@v1 uses: actions/checkout@v2
# install python # install python
- name: Install Python - name: Install Python
uses: actions/setup-python@v1 uses: actions/setup-python@v2
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
architecture: "x64" architecture: "x64"
@@ -110,9 +132,31 @@ jobs:
OS_NAME: ${{ matrix.os-name }} OS_NAME: ${{ matrix.os-name }}
run: | run: |
python ./resources/ci/common/install.py python ./resources/ci/common/install.py
# get parent directory
- name: Get Repo Name
uses: mad9000/actions-find-and-replace-string@1
id: repoName
with:
source: ${{ github.repository }}
find: '${{ github.repository_owner }}/'
replace: ''
- name: Get Parent Directory Path (!Windows)
uses: mad9000/actions-find-and-replace-string@1
id: parentDirNotWin
with:
source: ${{ github.workspace }}
find: '${{ steps.repoName.outputs.value }}/${{ steps.repoName.outputs.value }}'
replace: ${{ steps.repoName.outputs.value }}
- name: Get Parent Directory Path (Windows)
uses: mad9000/actions-find-and-replace-string@1
id: parentDir
with:
source: ${{ steps.parentDirNotWin.outputs.value }}
find: '${{ steps.repoName.outputs.value }}\${{ steps.repoName.outputs.value }}'
replace: ${{ steps.repoName.outputs.value }}
# download binary artifact # download binary artifact
- name: Download Binary Artifact - name: Download Binary Artifact
uses: actions/download-artifact@v1 uses: actions/download-artifact@v2
with: with:
name: binaries-${{ matrix.os-name }} name: binaries-${{ matrix.os-name }}
path: ./ path: ./
@@ -126,22 +170,22 @@ jobs:
python ./resources/ci/common/prepare_release.py python ./resources/ci/common/prepare_release.py
# upload appversion artifact for later step # upload appversion artifact for later step
- name: Upload AppVersion Artifact - name: Upload AppVersion Artifact
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v2
with: with:
name: appversion-${{ matrix.os-name }} name: appversion-${{ matrix.os-name }}
path: ./resources/app/meta/manifests/app_version.txt path: ./resources/app/meta/manifests/app_version.txt
# upload archive artifact for later step # upload archive artifact for later step
- name: Upload Archive Artifact - name: Upload Archive Artifact
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v2
with: with:
name: archive-${{ matrix.os-name }} name: archive-${{ matrix.os-name }}
path: ../deploy path: ${{ steps.parentDir.outputs.value }}/deploy
# Deploy to GitHub Releases # Deploy to GitHub Releases
# Release Name: ALttPDoorRandomizer v${GITHUB_TAG} # Release Name: ALttPDoorRandomizer v${GITHUB_TAG}
# Release Body: Inline content of RELEASENOTES.md # Release Body: Inline content of RELEASENOTES.md
# Release Body: Fallback to URL to RELEASENOTES.md # Release Body: Fallback to URL to RELEASENOTES.md
# Release Files: ../deploy # Release Files: ${{ steps.parentDir.outputs.value }}/deploy
deploy-release: deploy-release:
name: Deploy GHReleases name: Deploy GHReleases
runs-on: ${{ matrix.os-name }} runs-on: ${{ matrix.os-name }}
@@ -150,42 +194,64 @@ jobs:
# os & python versions # os & python versions
strategy: strategy:
matrix: matrix:
# release only on focal/bionic # release only on focal
os-name: [ ubuntu-latest ] os-name: [ ubuntu-latest ]
python-version: [ 3.8 ] python-version: [ 3.9 ]
needs: [ install-prepare-release ] needs: [ install-prepare-release ]
steps: steps:
# checkout commit # checkout commit
- name: Checkout commit - name: Checkout commit
uses: actions/checkout@v1 uses: actions/checkout@v2
# get parent directory
- name: Get Repo Name
uses: mad9000/actions-find-and-replace-string@1
id: repoName
with:
source: ${{ github.repository }}
find: '${{ github.repository_owner }}/'
replace: ''
- name: Get Parent Directory Path (!Windows)
uses: mad9000/actions-find-and-replace-string@1
id: parentDirNotWin
with:
source: ${{ github.workspace }}
find: '${{ steps.repoName.outputs.value }}/${{ steps.repoName.outputs.value }}'
replace: ${{ steps.repoName.outputs.value }}
- name: Get Parent Directory Path (Windows)
uses: mad9000/actions-find-and-replace-string@1
id: parentDir
with:
source: ${{ steps.parentDirNotWin.outputs.value }}
find: '${{ steps.repoName.outputs.value }}\${{ steps.repoName.outputs.value }}'
replace: ${{ steps.repoName.outputs.value }}
- name: Install Dependencies via pip - name: Install Dependencies via pip
run: | run: |
python -m pip install pytz requests python -m pip install pytz requests
# download appversion artifact # download appversion artifact
- name: Download AppVersion Artifact - name: Download AppVersion Artifact
uses: actions/download-artifact@v1 uses: actions/download-artifact@v2
with: with:
name: appversion-${{ matrix.os-name }} name: appversion-${{ matrix.os-name }}
path: ../build path: ${{ steps.parentDir.outputs.value }}/build
# download ubuntu archive artifact # download ubuntu archive artifact
- name: Download Ubuntu Archive Artifact - name: Download Ubuntu Archive Artifact
uses: actions/download-artifact@v1 uses: actions/download-artifact@v2
with: with:
name: archive-ubuntu-latest name: archive-ubuntu-latest
path: ../deploy/linux path: ${{ steps.parentDir.outputs.value }}/deploy/linux
# download macos archive artifact # download macos archive artifact
- name: Download MacOS Archive Artifact - name: Download MacOS Archive Artifact
uses: actions/download-artifact@v1 uses: actions/download-artifact@v2
with: with:
name: archive-macOS-latest name: archive-macOS-latest
path: ../deploy/macos path: ${{ steps.parentDir.outputs.value }}/deploy/macos
# download windows archive artifact # download windows archive artifact
- name: Download Windows Archive Artifact - name: Download Windows Archive Artifact
uses: actions/download-artifact@v1 uses: actions/download-artifact@v2
with: with:
name: archive-windows-latest name: archive-windows-latest
path: ../deploy/windows path: ${{ steps.parentDir.outputs.value }}/deploy/windows
# debug info # debug info
- name: Debug Info - name: Debug Info
id: debug_info id: debug_info
@@ -199,44 +265,35 @@ jobs:
RELEASE_NAME="ALttPDoorRandomizer ${GITHUB_TAG}" RELEASE_NAME="ALttPDoorRandomizer ${GITHUB_TAG}"
echo "Release Name: ${RELEASE_NAME}" echo "Release Name: ${RELEASE_NAME}"
echo "Git Tag: ${GITHUB_TAG}" echo "Git Tag: ${GITHUB_TAG}"
# read releasenotes
- name: Read RELEASENOTES
id: release_notes
run: |
body="$(cat RELEASENOTES.md)"
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$body"
# create a pre/release # create a pre/release
- name: Create a Pre/Release - name: Create a Pre/Release
id: create_release id: create_release
uses: actions/create-release@master uses: actions/create-release@v1.1.4
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
tag_name: v${{ steps.debug_info.outputs.github_tag }} tag_name: v${{ steps.debug_info.outputs.github_tag }}
release_name: ALttPDoorRandomizer v${{ steps.debug_info.outputs.github_tag }} release_name: ALttPDoorRandomizer v${{ steps.debug_info.outputs.github_tag }}
body: ${{ steps.release_notes.outputs.body }} body_path: RELEASENOTES.md
draft: true draft: true
prerelease: true prerelease: true
if: contains(github.ref, 'master') || contains(github.ref, 'stable') || contains(github.ref, 'dev') || contains(github.ref, 'DoorRelease') if: contains(github.ref, 'master') || contains(github.ref, 'stable') || contains(github.ref, 'dev') || contains(github.ref, 'DoorRelease')
# upload linux archive asset # upload linux archive asset
- name: Upload Linux Archive Asset - name: Upload Linux Archive Asset
id: upload-linux-asset id: upload-linux-asset
uses: actions/upload-release-asset@v1.0.1 uses: actions/upload-release-asset@v1.0.2
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ steps.create_release.outputs.upload_url }} upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ../deploy/linux/ALttPDoorRandomizer.tar.gz asset_path: ../deploy/linux/ALttPDoorRandomizer.tar.gz
asset_name: ALttPDoorRandomizer-${{ steps.debug_info.outputs.github_tag }}-linux-bionic.tar.gz asset_name: ALttPDoorRandomizer-${{ steps.debug_info.outputs.github_tag }}-linux-focal.tar.gz
asset_content_type: application/gzip asset_content_type: application/gzip
if: contains(github.ref, 'master') || contains(github.ref, 'stable') || contains(github.ref, 'dev') || contains(github.ref, 'DoorRelease') if: contains(github.ref, 'master') || contains(github.ref, 'stable') || contains(github.ref, 'dev') || contains(github.ref, 'DoorRelease')
# upload macos archive asset # upload macos archive asset
- name: Upload MacOS Archive Asset - name: Upload MacOS Archive Asset
id: upload-macos-asset id: upload-macos-asset
uses: actions/upload-release-asset@v1.0.1 uses: actions/upload-release-asset@v1.0.2
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
@@ -248,7 +305,7 @@ jobs:
# upload windows archive asset # upload windows archive asset
- name: Upload Windows Archive Asset - name: Upload Windows Archive Asset
id: upload-windows-asset id: upload-windows-asset
uses: actions/upload-release-asset@v1.0.1 uses: actions/upload-release-asset@v1.0.2
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:

View File

@@ -26,7 +26,7 @@ from Fill import sell_potions, sell_keys, balance_multiworld_progression, balanc
from ItemList import generate_itempool, difficulties, fill_prizes, customize_shops from ItemList import generate_itempool, difficulties, fill_prizes, customize_shops
from Utils import output_path, parse_player_names from Utils import output_path, parse_player_names
__version__ = '0.3.1.6-u' __version__ = '0.3.1.7-u'
class EnemizerError(RuntimeError): class EnemizerError(RuntimeError):

View File

@@ -144,6 +144,11 @@ New item counter modified to show total
# Bug Fixes and Notes. # Bug Fixes and Notes.
* 0.3.1.7-u
* TFH counter off in modes where it should be off
* Fixed Big Bomb logic for inverted (bad merge)
* Updated pip requirements for MultiClient
* Updated local_install.py and instructions (Thanks MikeTrethewey)
* 0.3.1.6-u * 0.3.1.6-u
* Fix for inverted. AT or GT vanilla lobby in intensity 3 should not softlock on exit in non-ER modes. * Fix for inverted. AT or GT vanilla lobby in intensity 3 should not softlock on exit in non-ER modes.
* Backward compatibility for "chaos" enemizer flags. (Thanks krebel) * Backward compatibility for "chaos" enemizer flags. (Thanks krebel)

7
Rom.py
View File

@@ -1142,10 +1142,11 @@ def patch_rom(world, rom, player, team, enemized, is_mystery=False):
# set up goals for treasure hunt # set up goals for treasure hunt
rom.write_bytes(0x180165, [0x0E, 0x28] if world.treasure_hunt_icon[player] == 'Triforce Piece' else [0x0D, 0x28]) rom.write_bytes(0x180165, [0x0E, 0x28] if world.treasure_hunt_icon[player] == 'Triforce Piece' else [0x0D, 0x28])
rom.write_byte(0x180167, int(world.treasure_hunt_count[player]) % 256) if world.goal[player] == 'triforcehunt':
rom.write_byte(0x180194, 1) # Must turn in triforced pieces (instant win not enabled) rom.write_byte(0x180167, int(world.treasure_hunt_count[player]) % 256)
rom.write_byte(0x180194, 1) # Must turn in triforced pieces (instant win not enabled)
rom.write_bytes(0x180213, [0x00, 0x01]) # Not a Tournament Seed rom.write_bytes(0x180213, [0x00, 0x01]) # Not a Tournament Seed
gametype = 0x04 # item gametype = 0x04 # item
if world.shuffle[player] != 'vanilla' or world.doorShuffle[player] != 'vanilla' or world.keydropshuffle[player]: if world.shuffle[player] != 'vanilla' or world.doorShuffle[player] != 'vanilla' or world.keydropshuffle[player]:

View File

@@ -1507,21 +1507,15 @@ def set_inverted_big_bomb_rules(world, player):
'Hookshot Cave', 'Hookshot Cave',
'Turtle Rock Isolated Ledge Entrance', 'Turtle Rock Isolated Ledge Entrance',
'Hookshot Cave Back Entrance', 'Hookshot Cave Back Entrance',
'Inverted Agahnims Tower', 'Inverted Agahnims Tower',]
'Dark Lake Hylia Ledge Fairy',
'Dark Lake Hylia Ledge Spike Cave',
'Dark Lake Hylia Ledge Hint',
'Mire Shed',
'Dark Desert Hint',
'Dark Desert Fairy',
'Misery Mire']
LW_walkable_entrances = ['Dark Lake Hylia Ledge Fairy', LW_walkable_entrances = ['Dark Lake Hylia Ledge Fairy',
'Dark Lake Hylia Ledge Spike Cave', 'Dark Lake Hylia Ledge Spike Cave',
'Dark Lake Hylia Ledge Hint', 'Dark Lake Hylia Ledge Hint',
'Mire Shed', 'Mire Shed',
'Dark Desert Hint', 'Dark Desert Hint',
'Dark Desert Fairy', 'Dark Desert Fairy',
'Desert Palace Entrance (East)'] 'Misery Mire',
'Red Shield Shop']
LW_bush_entrances = ['Bush Covered House', LW_bush_entrances = ['Bush Covered House',
'Light World Bomb Hut', 'Light World Bomb Hut',
'Graveyard Cave'] 'Graveyard Cave']

View File

@@ -1,13 +1,19 @@
# Running from source # Running from source
1. Get [python](http://python.org/downloads) |Instruction|Image|
1. Get the [Door Randomizer Unstable source code](https://github.com/Aerinon/ALttPDoorRandomizer/archive/DoorDevUnstable.zip) |-----------|-----|
1. Install Platform-specific dependencies |Get [python](http://python.org/downloads)|![Get python](https://raw.githubusercontent.com/miketrethewey/ALttPDoorRandomizer/DoorDevUnstable/docs/images/python.png)
1. Run `DoorRandomizer.py` for command-line script |Get the [Door Randomizer Unstable source code](https://github.com/Aerinon/ALttPDoorRandomizer/archive/DoorDevUnstable.zip)|![Get source code](https://raw.githubusercontent.com/miketrethewey/ALttPDoorRandomizer/DoorDevUnstable/docs/images/sourcecode.png)
1. Run `Gui.py` for user interface |Install Platform-specific dependencies (see below)|![Command line](https://raw.githubusercontent.com/miketrethewey/ALttPDoorRandomizer/DoorDevUnstable/docs/images/cmd.png)
|Run `DungeonRandomizer.py` for command-line script|![DungeonRandomizer.py](https://raw.githubusercontent.com/miketrethewey/ALttPDoorRandomizer/DoorDevUnstable/docs/images/py-dungeonrandomizer.png)
|Run `Gui.py` for user interface|![Gui.py](https://raw.githubusercontent.com/miketrethewey/ALttPDoorRandomizer/DoorDevUnstable/docs/images/py-gui.png)
## Platform-specific dependencies ## Platform-specific dependencies
### Windows |Platform|Command line|Image|
| :----: |------------|-----|
* Run `resources/ci/common/local_install.py` |Windows |`resources/ci/common/local_install.py`|![Windows](https://raw.githubusercontent.com/miketrethewey/ALttPDoorRandomizer/DoorDevUnstable/docs/images/cli-windows.png)
|`py` Launcher: 3.9 |`resources/ci/common/local_install.py --py 3.9`|
|`py` Launcher: 3.8 |`resources/ci/common/local_install.py --py 3.8`|
|`py` Launcher: 3.7 |`resources/ci/common/local_install.py --py 3.7`|
|`py` Launcher: 3.6 |`resources/ci/common/local_install.py --py 3.6`|

BIN
docs/images/cli-windows.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
docs/images/cmd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
docs/images/py-gui.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
docs/images/python.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
docs/images/sourcecode.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@@ -1,3 +1,6 @@
aenum aenum
fast-enum fast-enum
python-bps-continued python-bps-continued
colorama
aioconsole
websockets

View File

@@ -1,5 +1,7 @@
import os # for env vars import os # for env vars
import stat # file statistics import stat # file statistics
import sys # default system info
from my_path import get_py_path
global UBUNTU_VERSIONS global UBUNTU_VERSIONS
global DEFAULT_EVENT global DEFAULT_EVENT
@@ -44,6 +46,8 @@ def prepare_env():
APP_VERSION = f.readlines()[0].strip() APP_VERSION = f.readlines()[0].strip()
# ci data # ci data
env["CI_SYSTEM"] = os.getenv("CI_SYSTEM","") env["CI_SYSTEM"] = os.getenv("CI_SYSTEM","")
# py data
(env["PYTHON_EXE_PATH"],env["PY_EXE_PATH"],env["PIP_EXE_PATH"]) = get_py_path()
# git data # git data
env["BRANCH"] = os.getenv("TRAVIS_BRANCH","") env["BRANCH"] = os.getenv("TRAVIS_BRANCH","")
env["GITHUB_ACTOR"] = os.getenv("GITHUB_ACTOR","MegaMan.EXE") env["GITHUB_ACTOR"] = os.getenv("GITHUB_ACTOR","MegaMan.EXE")
@@ -75,10 +79,19 @@ def prepare_env():
env["BUILD_NUMBER"] = os.getenv("TRAVIS_BUILD_NUMBER",env["GITHUB_RUN_NUMBER"]) env["BUILD_NUMBER"] = os.getenv("TRAVIS_BUILD_NUMBER",env["GITHUB_RUN_NUMBER"])
GITHUB_TAG = os.getenv("TRAVIS_TAG",os.getenv("GITHUB_TAG","")) GITHUB_TAG = os.getenv("TRAVIS_TAG",os.getenv("GITHUB_TAG",""))
OS_NAME = os.getenv("TRAVIS_OS_NAME",os.getenv("OS_NAME","")).replace("macOS","osx") OS_NAME = os.getenv("TRAVIS_OS_NAME",os.getenv("OS_NAME",sys.platform)).replace("macOS","osx")
OS_DIST = os.getenv("TRAVIS_DIST","notset") OS_DIST = os.getenv("TRAVIS_DIST","notset")
OS_VERSION = "" OS_VERSION = ""
if "win32" in OS_NAME or \
"cygwin" in OS_NAME or \
"msys" in OS_NAME:
OS_NAME = "windows"
elif "darwin" in OS_NAME:
OS_NAME = "osx"
elif "linux2" in OS_NAME:
OS_NAME = "linux"
if '-' in OS_NAME: if '-' in OS_NAME:
OS_VERSION = OS_NAME[OS_NAME.find('-')+1:] OS_VERSION = OS_NAME[OS_NAME.find('-')+1:]
OS_NAME = OS_NAME[:OS_NAME.find('-')] OS_NAME = OS_NAME[:OS_NAME.find('-')]

View File

@@ -1,39 +1,63 @@
import common import common
import argparse
import os
import urllib.request, ssl import urllib.request, ssl
import subprocess # do stuff at the shell level import subprocess # do stuff at the shell level
env = common.prepare_env() env = common.prepare_env()
def get_get_pip(): def get_get_pip(PY_VERSION):
print("Getting pip getter!") try:
#make the request! import pip
url = "https://bootstrap.pypa.io/get-pip.py" except ImportError:
context = ssl._create_unverified_context() print("Getting pip getter!")
req = urllib.request.urlopen(url, context=context) #make the request!
got_pip = req.read().decode("utf-8") 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: with open("get-pip.py", "w") as g:
req = urllib.request.Request( req = urllib.request.Request(
url, url,
data=None, data=None,
headers={ 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" "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) req = urllib.request.urlopen(req, context=context)
data = req.read().decode("utf-8") data = req.read().decode("utf-8")
g.write(data) g.write(data)
# get executables # get executables
# python # python
# linux/windows: python # linux/windows: python
# macosx: python3 # macosx: python3
PYTHON_EXECUTABLE = "python3" if "osx" in env["OS_NAME"] else "python" PYTHON_EXECUTABLE = "python3" if "osx" in env["OS_NAME"] else "python"
print("Getting pip!") if PY_VERSION == None:
subprocess.check_call([PYTHON_EXECUTABLE,"get-pip.py"]) PY_VERSION = 0
if float(PY_VERSION) > 0:
PYTHON_EXECUTABLE = "py"
print("Getting pip!")
args = [
env["PYTHON_EXE_PATH"] + PYTHON_EXECUTABLE,
'-' + str(PY_VERSION),
"get-pip.py"
]
if PY_VERSION == 0:
del args[1]
subprocess.check_call(args)
if __name__ == "__main__": if __name__ == "__main__":
try: parser = argparse.ArgumentParser(add_help=False)
import pip parser.add_argument('--py', default=0)
except ImportError: command_line_args = parser.parse_args()
get_get_pip() PY_VERSION = vars(command_line_args)["py"]
try:
import pip
print("pip is installed")
except ImportError:
get_get_pip(PY_VERSION)

View File

@@ -1,9 +1,14 @@
import common import common
import argparse
import os
import platform
import subprocess # do stuff at the shell level import subprocess # do stuff at the shell level
env = common.prepare_env() env = common.prepare_env()
def run_install(): pip_requirements = os.path.join(".","resources","app","meta","manifests","pip_requirements.txt")
def run_install(PY_VERSION,USER):
# get executables # get executables
# python # python
# linux/windows: python # linux/windows: python
@@ -11,20 +16,79 @@ def run_install():
# pip # pip
# linux/macosx: pip3 # linux/macosx: pip3
# windows: pip # windows: pip
PYTHON_PATH = env["PYTHON_EXE_PATH"]
PYTHON_EXECUTABLE = "python3" if "osx" in env["OS_NAME"] else "python" 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 "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 PIP_EXECUTABLE = "pip" if "osx" in env["OS_NAME"] and "actions" in env["CI_SYSTEM"] else PIP_EXECUTABLE
# upgrade pip if PY_VERSION == None:
subprocess.check_call([PYTHON_EXECUTABLE,"-m","pip","install","--upgrade","pip"]) PY_VERSION = 0
if USER == None:
USER = False
if float(PY_VERSION) > 0:
PYTHON_EXECUTABLE = "py"
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_PATH + PYTHON_EXECUTABLE,
'-' + str(PY_VERSION),
"-m",
"pip",
"install",
"--upgrade",
"--user",
"pip"
]
if not USER:
args.remove("--user")
if PY_VERSION == 0:
del args[1]
subprocess.check_call(args)
# pip version
subprocess.check_call([PIP_EXECUTABLE,"--version"])
# if pip3, install wheel # if pip3, install wheel
if PIP_EXECUTABLE == "pip3": if PIP_EXECUTABLE == "pip3":
subprocess.check_call([PIP_EXECUTABLE,"install","-U","wheel"]) print("Installing Wheel!")
args = [
PIP_PATH + PIP_EXECUTABLE,
"install",
"--user",
"-U",
"wheel"
]
if not USER:
args.remove("--user")
subprocess.check_call(args)
print()
# install listed dependencies # install listed dependencies
subprocess.check_call([PIP_EXECUTABLE,"install","-r","./resources/app/meta/manifests/pip_requirements.txt"]) print("Installing dependencies")
print("-----------------------")
args = [
PIP_PATH + PIP_EXECUTABLE,
"install",
"--user",
"-r",
pip_requirements
]
if not USER:
args.remove("--user")
subprocess.check_call(args)
if __name__ == "__main__": if __name__ == "__main__":
run_install() parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--py', default=0)
parser.add_argument('--user', default=False, action="store_true")
command_line_args = parser.parse_args()
PY_VERSION = vars(command_line_args)["py"]
USER = vars(command_line_args)["user"]
run_install(PY_VERSION,USER)

View File

@@ -1,8 +1,17 @@
import install import install
import get_get_pip import get_get_pip
import argparse
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--py', default=0)
parser.add_argument('--user', default=False, action="store_true")
command_line_args = parser.parse_args()
PY_VERSION = vars(command_line_args)["py"]
USER = vars(command_line_args)["user"]
# get & install pip # get & install pip
get_get_pip.get_get_pip() get_get_pip.get_get_pip(PY_VERSION)
# run installer # run installer
install.run_install() install.run_install(PY_VERSION,USER)

View File

@@ -0,0 +1,33 @@
import os
import sys
def get_py_path():
user_paths = os.environ["PATH"].split(os.pathsep)
(python,py) = ("","")
for path in user_paths:
parts = path.split(os.sep)
part = parts[len(parts) - 1].lower()
if ("python" in part) and ('.' not in part):
path.replace(os.sep,os.sep + os.sep)
if path not in user_paths:
py = path
for path in sys.path:
parts = path.split(os.sep)
part = parts[len(parts) - 1].lower()
if ("python" in part) and ('.' not in part):
path.replace(os.sep,os.sep + os.sep)
if path not in user_paths:
python = path
paths = (
os.path.join(python,"") if python != "" else "",
os.path.join(py,"") if py != "" else "",
os.path.join(python,"Scripts","") if python != "" else ""
)
# print(paths)
return paths
if __name__ == "__main__":
get_py_path()