Compare commits

...
Author SHA1 Message Date
sisungo 633bf71cb1 feat: add package installer-py
Signed-off-by: sisungo <[email protected]>
2026-08-15 21:08:10 +08:00
sisungo 64c313003f Merge pull request 'feat: add python packaging lib' (#159) from sisungo/semios-packages:python-pkg into master
Reviewed-on: semios/semios-packages#159
2026-08-15 21:36:27 +08:00
sisungo d05fce73dc feat: add python packaging lib
Signed-off-by: sisungo <[email protected]>
2026-08-15 20:49:02 +08:00
3 changed files with 85 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
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)
+22
View File
@@ -0,0 +1,22 @@
from lib.make import *
from lib import python
python.version("1.0.1")
description("A library for installing Python wheels.")
maintainer("sisungo <[email protected]>")
source_url("https://files.pythonhosted.org/packages/06/fe/b9f481cf0cc867958a21338baa900357b7b7d86cac9b025948049d77923c/installer-1.0.1.tar.gz")
python.builddep("$shortcut")
def build():
python.build()
python.install()
on_build(build)
package("installer.py")
python.dep("python")
python.use_auto_pack()
+1
View File
@@ -118,6 +118,7 @@ def cmd_build_package(package: str):
"name": pkgname,
"version": pkgver,
"arch": pkgarch,
"description": pkginfo[lib.make._key_description],
"dependencies": pkginfo[lib.make._key_dependencies],
"provides": pkginfo[lib.make._key_provides],
"recommendations": pkginfo[lib.make._key_recommendations],