import os import shutil import subprocess from . import make, arch PY3_VERSION = "3.14" def build(): subprocess.run(["python3", "-m", "build", "."], check=True) def install(): if os.path.exists("../pyinstall"): shutil.rmtree("../pyinstall") for i in os.listdir("dist"): if not i.endswith(".whl"): continue subprocess.run(["python3", "-m", "installer", f"--destdir=../pyinstall", f"dist/{i}"], check=True) os.chdir("../pyinstall") while len(os.listdir(".")) == 1: os.chdir(os.listdir(".")[0]) def version(s: str): make.version(f"{s}+python{PY3_VERSION}") def _depcommon(s: str): if s == "python": return f"python (~{PY3_VERSION}.0) @{arch.get_target()}" elif ".py" in s: if ")" in s: return s.replace(")", f", +python{PY3_VERSION})") else: return s.replace(".py", f" (+python{PY3_VERSION})") else: return None def builddep(s: str): if s == "$shortcut": builddep("python") builddep("build.py") builddep("installer.py") elif _depcommon(s): make.builddep(_depcommon(s)) else: raise RuntimeError("unrecognized python dep") def dep(s: str): if _depcommon(s): make.dep(_depcommon(s)) else: raise RuntimeError("unrecognized python dep") def _auto_pack(composer): base = f"lib/python{PY3_VERSION}/site-packages" composer.makedirs(base) for i in os.listdir("."): composer.add_dir(i, f"{base}/{i}") def use_auto_pack(): make.on_pack(_auto_pack)