windows fixes
This commit is contained in:
@@ -14,7 +14,7 @@ if (-not (Get-Command "python" -ErrorAction SilentlyContinue)) {
|
|||||||
|
|
||||||
if ($winget) {
|
if ($winget) {
|
||||||
Write-Host "Attempting to install python."
|
Write-Host "Attempting to install python."
|
||||||
winget install --id=Python.Python.3.11 -e
|
(winget install --id=Python.Python.3.11 -e) | Out-Null
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "Please install python to continue." -Foreground Red
|
Write-Host "Please install python to continue." -Foreground Red
|
||||||
@@ -23,12 +23,12 @@ if (-not (Get-Command "python" -ErrorAction SilentlyContinue)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Check that java is installed
|
# Check that java is installed
|
||||||
if (-not (Get-Command "java" -ErrorAction SilentlyContinue)) {
|
if (-not (Get-Command "C:\Program Files\AdoptOpenJDK\jdk-11.0.11.9-hotspot\bin\java" -ErrorAction SilentlyContinue)) {
|
||||||
Write-Host "Error: java is not installed." -Foreground Red
|
Write-Host "Error: java is not installed." -Foreground Red
|
||||||
|
|
||||||
if ($winget) {
|
if ($winget) {
|
||||||
Write-Host "Attempting to install java."
|
Write-Host "Attempting to install java."
|
||||||
winget install AdoptOpenJDK.OpenJDK.11
|
(winget install AdoptOpenJDK.OpenJDK.11) | Out-Null
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "Please install java to continue." -Foreground Red
|
Write-Host "Please install java to continue." -Foreground Red
|
||||||
@@ -39,7 +39,7 @@ if (-not (Get-Command "java" -ErrorAction SilentlyContinue)) {
|
|||||||
|
|
||||||
if (Test-Path ".venv") { } else { python -m venv .venv }
|
if (Test-Path ".venv") { } else { python -m venv .venv }
|
||||||
|
|
||||||
. ./.venv/bin/Activate.ps1
|
. .\.venv\Scripts\Activate.ps1
|
||||||
|
|
||||||
(python -m pip install --upgrade pip) | Out-Null
|
(python -m pip install --upgrade pip) | Out-Null
|
||||||
(python -m pip install -r requirements.txt) | Out-Null
|
(python -m pip install -r requirements.txt) | Out-Null
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ MODPACK_RELEASES_URL = "https://git.233hfd.com/api/v1/repos/joey/FishPogPixelmon
|
|||||||
MULTIMC_DOWNLOAD_URL_WINDOWS = "https://files.multimc.org/downloads/mmc-develop-win32.zip"
|
MULTIMC_DOWNLOAD_URL_WINDOWS = "https://files.multimc.org/downloads/mmc-develop-win32.zip"
|
||||||
MULTIMC_PARENT_DIR = ""
|
MULTIMC_PARENT_DIR = ""
|
||||||
MULTIMC_DIR = ""
|
MULTIMC_DIR = ""
|
||||||
|
INSTANCE_DIR = ""
|
||||||
|
|
||||||
if OS == "darwin":
|
if OS == "darwin":
|
||||||
cprint("no support for macos yet", "red")
|
cprint("no support for macos yet", "red")
|
||||||
@@ -21,12 +22,12 @@ if OS == "darwin":
|
|||||||
if OS == "linux":
|
if OS == "linux":
|
||||||
MULTIMC_PARENT_DIR = f"{os.getenv('HOME')}/.local/share"
|
MULTIMC_PARENT_DIR = f"{os.getenv('HOME')}/.local/share"
|
||||||
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}/multimc"
|
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}/multimc"
|
||||||
|
INSTANCE_DIR = f"{MULTIMC_DIR}/instances/FishPogPixelmon"
|
||||||
|
|
||||||
if OS == "windows":
|
if OS == "win32":
|
||||||
MULTIMC_PARENT_DIR = f"{os.getenv('APPDATA')}/FishPog"
|
MULTIMC_PARENT_DIR = f"{os.getenv('APPDATA')}\\FishPog"
|
||||||
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}/MultiMC"
|
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}\\MultiMC"
|
||||||
|
INSTANCE_DIR = f"{MULTIMC_DIR}\\instances\\FishPogPixelmon"
|
||||||
INSTANCE_DIR = f"{MULTIMC_DIR}/instances/FishPogPixelmon"
|
|
||||||
|
|
||||||
|
|
||||||
# main
|
# main
|
||||||
@@ -44,7 +45,7 @@ def run_mmc():
|
|||||||
cprint("ready to go! starting multimc!", "green")
|
cprint("ready to go! starting multimc!", "green")
|
||||||
os.chdir(MULTIMC_DIR)
|
os.chdir(MULTIMC_DIR)
|
||||||
|
|
||||||
if OS == "windows":
|
if OS == "win32":
|
||||||
subprocess.Popen(["MultiMC.exe"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.Popen(["MultiMC.exe"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
if OS == "linux":
|
if OS == "linux":
|
||||||
@@ -55,7 +56,7 @@ def run_mmc():
|
|||||||
def mods():
|
def mods():
|
||||||
os.chdir(INSTANCE_DIR)
|
os.chdir(INSTANCE_DIR)
|
||||||
|
|
||||||
if not os.path.exists(f"{INSTANCE_DIR}/downloader.zip"):
|
if not os.path.exists(os.path.join(INSTANCE_DIR, "downloader.zip")):
|
||||||
cprint("downloader.zip not found - downloading", "yellow")
|
cprint("downloader.zip not found - downloading", "yellow")
|
||||||
r = requests.get(MOD_DOWNLOADER_URL, allow_redirects=True)
|
r = requests.get(MOD_DOWNLOADER_URL, allow_redirects=True)
|
||||||
open("downloader.zip", "wb").write(r.content)
|
open("downloader.zip", "wb").write(r.content)
|
||||||
@@ -63,11 +64,15 @@ def mods():
|
|||||||
cprint("downloading mods. this may take a while, please wait.", "green")
|
cprint("downloading mods. this may take a while, please wait.", "green")
|
||||||
subprocess.run(["python", "downloader.zip", "manifest.json"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(["python", "downloader.zip", "manifest.json"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
for file in glob.glob(f"{INSTANCE_DIR}/mods/*"):
|
for file in glob.glob(os.path.join(INSTANCE_DIR, ".minecraft", "mods", "*")):
|
||||||
name = os.path.basename(file)
|
if os.path.basename(file) == "OptiFine_1.16.5_HD_U_G8.jar":
|
||||||
shutil.move(file, os.path.join(f"{INSTANCE_DIR}/.minecraft/mods", name))
|
continue
|
||||||
|
os.remove(file)
|
||||||
|
|
||||||
shutil.rmtree(f"{INSTANCE_DIR}/mods")
|
for file in glob.glob(os.path.join(INSTANCE_DIR, "mods", "*")):
|
||||||
|
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", "mods", os.path.basename(file)))
|
||||||
|
|
||||||
|
shutil.rmtree(os.path.join(INSTANCE_DIR, "mods"))
|
||||||
|
|
||||||
cprint("mods downloaded successfully", "green")
|
cprint("mods downloaded successfully", "green")
|
||||||
|
|
||||||
@@ -97,7 +102,7 @@ def instance():
|
|||||||
|
|
||||||
|
|
||||||
def download_instance(release: dict[str, Any]):
|
def download_instance(release: dict[str, Any]):
|
||||||
os.makedirs(f"{INSTANCE_DIR}/.minecraft", exist_ok=True)
|
os.makedirs(os.path.join(INSTANCE_DIR, ".minecraft"), exist_ok=True)
|
||||||
|
|
||||||
TMP = tempfile.mkdtemp()
|
TMP = tempfile.mkdtemp()
|
||||||
os.chdir(TMP)
|
os.chdir(TMP)
|
||||||
@@ -108,23 +113,34 @@ def download_instance(release: dict[str, Any]):
|
|||||||
shutil.unpack_archive("instance.zip", ".")
|
shutil.unpack_archive("instance.zip", ".")
|
||||||
os.remove("instance.zip")
|
os.remove("instance.zip")
|
||||||
|
|
||||||
for file in glob.glob(f"{TMP}/overrides/*"):
|
for file in glob.glob(os.path.join(TMP, "overrides", "*")):
|
||||||
if file == f"{TMP}/overrides/options.txt" and os.path.exists(f"{INSTANCE_DIR}/.minecraft/options.txt"):
|
if file == os.path.join(TMP, "overrides", "options.txt") and os.path.exists(
|
||||||
|
os.path.join(INSTANCE_DIR, ".minecraft", "options.txt")
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
name = os.path.basename(file)
|
if os.path.exists(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file))):
|
||||||
shutil.move(file, os.path.join(f"{INSTANCE_DIR}/.minecraft", name))
|
if os.path.isdir(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file))):
|
||||||
|
shutil.rmtree(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
|
||||||
|
else:
|
||||||
|
os.remove(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
|
||||||
|
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
|
||||||
|
|
||||||
shutil.rmtree(f"{TMP}/overrides")
|
shutil.rmtree(os.path.join(TMP, "overrides"))
|
||||||
|
|
||||||
for file in glob.glob(f"{TMP}/*"):
|
for file in glob.glob(os.path.join(TMP, "*")):
|
||||||
name = os.path.basename(file)
|
if os.path.exists(os.path.join(INSTANCE_DIR, os.path.basename(file))):
|
||||||
shutil.move(file, os.path.join(INSTANCE_DIR, name))
|
if os.path.isdir(os.path.join(INSTANCE_DIR, os.path.basename(file))):
|
||||||
|
shutil.rmtree(os.path.join(INSTANCE_DIR, os.path.basename(file)))
|
||||||
shutil.rmtree(TMP)
|
else:
|
||||||
|
os.remove(os.path.join(INSTANCE_DIR, os.path.basename(file)))
|
||||||
|
shutil.move(file, os.path.join(INSTANCE_DIR, os.path.basename(file)))
|
||||||
|
|
||||||
os.chdir(INSTANCE_DIR)
|
os.chdir(INSTANCE_DIR)
|
||||||
|
if not os.path.exists(os.path.join(MULTIMC_DIR, "icons", "fishpog_pixelmon.png")):
|
||||||
|
os.makedirs(os.path.join(MULTIMC_DIR, "icons"), exist_ok=True)
|
||||||
shutil.copy(
|
shutil.copy(
|
||||||
os.path.join(INSTANCE_DIR, "fishpog_pixelmon.png"), os.path.join(MULTIMC_DIR, "icons", "fishpog_pixelmon.png")
|
os.path.join(INSTANCE_DIR, "fishpog_pixelmon.png"),
|
||||||
|
os.path.join(MULTIMC_DIR, "icons", "fishpog_pixelmon.png"),
|
||||||
)
|
)
|
||||||
|
|
||||||
f = open(".version", "w")
|
f = open(".version", "w")
|
||||||
@@ -136,7 +152,7 @@ def multimc():
|
|||||||
if os.path.exists(MULTIMC_DIR):
|
if os.path.exists(MULTIMC_DIR):
|
||||||
return
|
return
|
||||||
|
|
||||||
if OS != "windows":
|
if OS != "win32":
|
||||||
cprint("multimc is not installed - please install it", "red")
|
cprint("multimc is not installed - please install it", "red")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|||||||
22
tooling.py
22
tooling.py
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os, sys, argparse, tempfile, subprocess, shutil, requests
|
import os, sys, argparse, tempfile, subprocess, shutil, requests, zipfile
|
||||||
from git.repo import Repo
|
from git.repo import Repo
|
||||||
from termcolor import cprint
|
from termcolor import cprint
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ parser = argparse.ArgumentParser(description="a helper script for liightninggod
|
|||||||
|
|
||||||
parser.add_argument("--export", "-e", help="export modpack zip", action="store_true")
|
parser.add_argument("--export", "-e", help="export modpack zip", action="store_true")
|
||||||
parser.add_argument("--release", "-r", help="release modpack version", action="store_true")
|
parser.add_argument("--release", "-r", help="release modpack version", action="store_true")
|
||||||
|
parser.add_argument("--client", "-c", help="export modpack client as a zip file", action="store_true")
|
||||||
parser.add_argument("--setup", "-s", help="setup project and install dependencies", action="store_true")
|
parser.add_argument("--setup", "-s", help="setup project and install dependencies", action="store_true")
|
||||||
parser.add_argument("--force", "-f", help="forces things when needed, like redoing setup", action="store_true")
|
parser.add_argument("--force", "-f", help="forces things when needed, like redoing setup", action="store_true")
|
||||||
parser.add_argument("--build-pax", help="builds pax from source, even if on a supported platform", action="store_true")
|
parser.add_argument("--build-pax", help="builds pax from source, even if on a supported platform", action="store_true")
|
||||||
@@ -39,12 +40,27 @@ def __main__():
|
|||||||
elif args.release:
|
elif args.release:
|
||||||
release()
|
release()
|
||||||
return
|
return
|
||||||
|
elif args.client:
|
||||||
|
print("exporting modpack client")
|
||||||
|
export_client()
|
||||||
|
return
|
||||||
|
|
||||||
print(
|
print(
|
||||||
"no command provided. pass the -h flag to see commands for tooling, or run ./pax to interact with the modpack's files"
|
"no command provided. pass the -h flag to see commands for tooling, or run ./pax to interact with the modpack's files"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# client
|
||||||
|
def export_client():
|
||||||
|
z = zipfile.ZipFile(".out/FishPogPixelmonClient.zip", "w", zipfile.ZIP_DEFLATED)
|
||||||
|
z.write("client/README.md", "README.md")
|
||||||
|
z.write("client/client.ps1", "client.ps1")
|
||||||
|
z.write("client/client.sh", "client.sh")
|
||||||
|
z.write("client/requirements.txt", "requirements.txt")
|
||||||
|
z.write("client/client.py", "client.py")
|
||||||
|
z.close()
|
||||||
|
|
||||||
|
|
||||||
# setup
|
# setup
|
||||||
def setup_pack():
|
def setup_pack():
|
||||||
pax()
|
pax()
|
||||||
@@ -108,7 +124,7 @@ def pax():
|
|||||||
os.chmod("pax", 0o755)
|
os.chmod("pax", 0o755)
|
||||||
return
|
return
|
||||||
|
|
||||||
if OS == "windows":
|
if OS == "win32":
|
||||||
print("downloading and extracting pax for windows...")
|
print("downloading and extracting pax for windows...")
|
||||||
r = requests.get(PAX_WINDOWS, allow_redirects=True)
|
r = requests.get(PAX_WINDOWS, allow_redirects=True)
|
||||||
open("pax-windows.zip", "wb").write(r.content)
|
open("pax-windows.zip", "wb").write(r.content)
|
||||||
@@ -118,7 +134,7 @@ def pax():
|
|||||||
|
|
||||||
|
|
||||||
def pax_from_source():
|
def pax_from_source():
|
||||||
if OS == "windows":
|
if OS == "win32":
|
||||||
cprint("building from source not supported on windows yet", "red")
|
cprint("building from source not supported on windows yet", "red")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user