windows fixes
This commit is contained in:
@@ -14,7 +14,7 @@ if (-not (Get-Command "python" -ErrorAction SilentlyContinue)) {
|
||||
|
||||
if ($winget) {
|
||||
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 {
|
||||
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
|
||||
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
|
||||
|
||||
if ($winget) {
|
||||
Write-Host "Attempting to install java."
|
||||
winget install AdoptOpenJDK.OpenJDK.11
|
||||
(winget install AdoptOpenJDK.OpenJDK.11) | Out-Null
|
||||
}
|
||||
else {
|
||||
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 }
|
||||
|
||||
. ./.venv/bin/Activate.ps1
|
||||
. .\.venv\Scripts\Activate.ps1
|
||||
|
||||
(python -m pip install --upgrade pip) | 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_PARENT_DIR = ""
|
||||
MULTIMC_DIR = ""
|
||||
INSTANCE_DIR = ""
|
||||
|
||||
if OS == "darwin":
|
||||
cprint("no support for macos yet", "red")
|
||||
@@ -21,12 +22,12 @@ if OS == "darwin":
|
||||
if OS == "linux":
|
||||
MULTIMC_PARENT_DIR = f"{os.getenv('HOME')}/.local/share"
|
||||
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}/multimc"
|
||||
INSTANCE_DIR = f"{MULTIMC_DIR}/instances/FishPogPixelmon"
|
||||
|
||||
if OS == "windows":
|
||||
MULTIMC_PARENT_DIR = f"{os.getenv('APPDATA')}/FishPog"
|
||||
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}/MultiMC"
|
||||
|
||||
INSTANCE_DIR = f"{MULTIMC_DIR}/instances/FishPogPixelmon"
|
||||
if OS == "win32":
|
||||
MULTIMC_PARENT_DIR = f"{os.getenv('APPDATA')}\\FishPog"
|
||||
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}\\MultiMC"
|
||||
INSTANCE_DIR = f"{MULTIMC_DIR}\\instances\\FishPogPixelmon"
|
||||
|
||||
|
||||
# main
|
||||
@@ -44,7 +45,7 @@ def run_mmc():
|
||||
cprint("ready to go! starting multimc!", "green")
|
||||
os.chdir(MULTIMC_DIR)
|
||||
|
||||
if OS == "windows":
|
||||
if OS == "win32":
|
||||
subprocess.Popen(["MultiMC.exe"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
if OS == "linux":
|
||||
@@ -55,7 +56,7 @@ def run_mmc():
|
||||
def mods():
|
||||
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")
|
||||
r = requests.get(MOD_DOWNLOADER_URL, allow_redirects=True)
|
||||
open("downloader.zip", "wb").write(r.content)
|
||||
@@ -63,11 +64,15 @@ def mods():
|
||||
cprint("downloading mods. this may take a while, please wait.", "green")
|
||||
subprocess.run(["python", "downloader.zip", "manifest.json"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
for file in glob.glob(f"{INSTANCE_DIR}/mods/*"):
|
||||
name = os.path.basename(file)
|
||||
shutil.move(file, os.path.join(f"{INSTANCE_DIR}/.minecraft/mods", name))
|
||||
for file in glob.glob(os.path.join(INSTANCE_DIR, ".minecraft", "mods", "*")):
|
||||
if os.path.basename(file) == "OptiFine_1.16.5_HD_U_G8.jar":
|
||||
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")
|
||||
|
||||
@@ -97,7 +102,7 @@ def instance():
|
||||
|
||||
|
||||
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()
|
||||
os.chdir(TMP)
|
||||
@@ -108,24 +113,35 @@ def download_instance(release: dict[str, Any]):
|
||||
shutil.unpack_archive("instance.zip", ".")
|
||||
os.remove("instance.zip")
|
||||
|
||||
for file in glob.glob(f"{TMP}/overrides/*"):
|
||||
if file == f"{TMP}/overrides/options.txt" and os.path.exists(f"{INSTANCE_DIR}/.minecraft/options.txt"):
|
||||
for file in glob.glob(os.path.join(TMP, "overrides", "*")):
|
||||
if file == os.path.join(TMP, "overrides", "options.txt") and os.path.exists(
|
||||
os.path.join(INSTANCE_DIR, ".minecraft", "options.txt")
|
||||
):
|
||||
continue
|
||||
name = os.path.basename(file)
|
||||
shutil.move(file, os.path.join(f"{INSTANCE_DIR}/.minecraft", name))
|
||||
if os.path.exists(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file))):
|
||||
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}/*"):
|
||||
name = os.path.basename(file)
|
||||
shutil.move(file, os.path.join(INSTANCE_DIR, name))
|
||||
|
||||
shutil.rmtree(TMP)
|
||||
for file in glob.glob(os.path.join(TMP, "*")):
|
||||
if os.path.exists(os.path.join(INSTANCE_DIR, os.path.basename(file))):
|
||||
if os.path.isdir(os.path.join(INSTANCE_DIR, os.path.basename(file))):
|
||||
shutil.rmtree(os.path.join(INSTANCE_DIR, os.path.basename(file)))
|
||||
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)
|
||||
shutil.copy(
|
||||
os.path.join(INSTANCE_DIR, "fishpog_pixelmon.png"), os.path.join(MULTIMC_DIR, "icons", "fishpog_pixelmon.png")
|
||||
)
|
||||
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(
|
||||
os.path.join(INSTANCE_DIR, "fishpog_pixelmon.png"),
|
||||
os.path.join(MULTIMC_DIR, "icons", "fishpog_pixelmon.png"),
|
||||
)
|
||||
|
||||
f = open(".version", "w")
|
||||
f.write(release["tag_name"])
|
||||
@@ -136,7 +152,7 @@ def multimc():
|
||||
if os.path.exists(MULTIMC_DIR):
|
||||
return
|
||||
|
||||
if OS != "windows":
|
||||
if OS != "win32":
|
||||
cprint("multimc is not installed - please install it", "red")
|
||||
exit(1)
|
||||
|
||||
|
||||
22
tooling.py
22
tooling.py
@@ -1,6 +1,6 @@
|
||||
#!/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 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("--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("--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")
|
||||
@@ -39,12 +40,27 @@ def __main__():
|
||||
elif args.release:
|
||||
release()
|
||||
return
|
||||
elif args.client:
|
||||
print("exporting modpack client")
|
||||
export_client()
|
||||
return
|
||||
|
||||
print(
|
||||
"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
|
||||
def setup_pack():
|
||||
pax()
|
||||
@@ -108,7 +124,7 @@ def pax():
|
||||
os.chmod("pax", 0o755)
|
||||
return
|
||||
|
||||
if OS == "windows":
|
||||
if OS == "win32":
|
||||
print("downloading and extracting pax for windows...")
|
||||
r = requests.get(PAX_WINDOWS, allow_redirects=True)
|
||||
open("pax-windows.zip", "wb").write(r.content)
|
||||
@@ -118,7 +134,7 @@ def pax():
|
||||
|
||||
|
||||
def pax_from_source():
|
||||
if OS == "windows":
|
||||
if OS == "win32":
|
||||
cprint("building from source not supported on windows yet", "red")
|
||||
exit(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user