Skip to content

Commit

Permalink
Merge branch 'pygame-web:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
pmp-p authored Mar 7, 2024
2 parents 57b966c + c99518b commit 6ade9fe
Show file tree
Hide file tree
Showing 19 changed files with 225 additions and 126 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ jobs:
build:
runs-on: ubuntu-22.04
env:
SDK_VERSION: 3.1.54.1bi
SDK_VERSION: 3.1.56.0bi
SYS_PYTHON: /usr/bin/python3
PACKAGES: emsdk hpy pygame
BUILD_STATIC: emsdk hpy
STATIC: false
BUILDS: 3.11 3.12 3.13
BUILDS: 3.12 3.13
CYTHON: Cython-3.0.8-py2.py3-none-any.whl
LD_VENDOR: -sUSE_GLFW=3

Expand All @@ -36,17 +36,17 @@ jobs:
sudo apt-get update 2>&1 >/dev/null
sudo apt-get install -y bash git curl wget lz4 pv 2>&1 >/dev/null
- name: build 3.11 packages
run: |
cd $GITHUB_WORKSPACE
PYBUILD=3.11 PACKAGES="emsdk hpy _ctypes pygame" BUILD_STATIC="emsdk _ctypes hpy" bash ./scripts/build-pkg.sh
- name: build 3.11 loader
run: |
cd $GITHUB_WORKSPACE
PYBUILD=3.11 PACKAGES="emsdk hpy _ctypes pygame" BUILD_STATIC="emsdk _ctypes hpy" bash ./scripts/build-loader.sh
#
# - name: build 3.11 packages
# run: |
# cd $GITHUB_WORKSPACE
# PYBUILD=3.11 PACKAGES="emsdk hpy _ctypes pygame" BUILD_STATIC="emsdk _ctypes hpy" bash ./scripts/build-pkg.sh
#
# - name: build 3.11 loader
# run: |
# cd $GITHUB_WORKSPACE
# PYBUILD=3.11 PACKAGES="emsdk hpy _ctypes pygame" BUILD_STATIC="emsdk _ctypes hpy" bash ./scripts/build-loader.sh
#

- name: build 3.12 packages
run: |
Expand Down
85 changes: 46 additions & 39 deletions packages.d/hpy/hpy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,52 +57,59 @@ popd

pushd external/hpy

# build for host simulator
# build and install for host simulator
${HPY} setup.py install

# build for wasm
${SDKROOT}/python3-wasm setup.py install

# ${SDKROOT}/python3-wasm setup.py install
${SDKROOT}/python3-wasm setup.py build

# link static
. ${SDKROOT}/emsdk/emsdk_env.sh

$SDKROOT/emsdk/upstream/emscripten/emar rcs /opt/python-wasm-sdk/prebuilt/emsdk/libhpy${PYMAJOR}.${PYMINOR}.a \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/debug/src/_debugmod.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/debug/src/autogen_debug_wrappers.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/debug/src/debug_ctx.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/debug/src/debug_ctx_cpython.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/debug/src/debug_handles.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/debug/src/dhqueue.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/debug/src/memprotect.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/debug/src/stacktrace.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/argparse.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/buildvalue.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_bytes.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_call.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_capsule.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_contextvar.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_err.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_eval.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_listbuilder.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_long.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_module.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_object.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_tracker.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_tuple.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_tuplebuilder.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/ctx_type.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/format.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/helpers.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/devel/src/runtime/structseq.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/trace/src/_tracemod.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/trace/src/autogen_trace_func_table.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/trace/src/autogen_trace_wrappers.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/trace/src/trace_ctx.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/universal/src/ctx.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/universal/src/ctx_meth.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/universal/src/ctx_misc.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-311/hpy/universal/src/hpymodule.o
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/debug/src/_debugmod.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/debug/src/autogen_debug_wrappers.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/debug/src/debug_ctx.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/debug/src/debug_ctx_cpython.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/debug/src/debug_handles.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/debug/src/dhqueue.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/debug/src/memprotect.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/debug/src/stacktrace.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/argparse.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/buildvalue.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_bytes.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_call.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_capsule.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_contextvar.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_err.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_eval.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_listbuilder.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_long.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_module.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_object.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_tracker.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_tuple.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_tuplebuilder.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/ctx_type.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/format.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/helpers.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/devel/src/runtime/structseq.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/trace/src/_tracemod.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/trace/src/autogen_trace_func_table.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/trace/src/autogen_trace_wrappers.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/trace/src/trace_ctx.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/universal/src/ctx.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/universal/src/ctx_meth.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/universal/src/ctx_misc.o \
build/temp.wasm32-${WASM_FLAVOUR}-emscripten-cpython-${PYMAJOR}${PYMINOR}/hpy/universal/src/hpymodule.o

if [ -f /pp ]
then
# build wheel for wasm
${SDKROOT}/python3-wasm -m build --no-isolation .

mv dist/*wasm*whl /data/git/archives/repo/pkg/
fi

popd

Expand Down
18 changes: 16 additions & 2 deletions scripts/build-loader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@

. ${CONFIG:-$SDKROOT/config}

#
if [ -f vendor/vendor.sh ]
then
echo " vendor build"
if ${ABI3:-false}
then
echo " vendor build (abi3) $PYBUILD"
if echo $PYBUILD|grep -v -q 3.12$
then
echo "abi3 vendor build only, skipping $PYBUILD"
exit 0
fi
fi
fi

ln -s $(pwd)/src/pygbag $(pwd)/pygbag

Expand Down Expand Up @@ -236,7 +248,9 @@ then

# TODO: test -sWEBGL2_BACKWARDS_COMPATIBILITY_EMULATION

LDFLAGS="-sUSE_GLFW=3 -sUSE_WEBGL2 -sMIN_WEBGL_VERSION=2 -sOFFSCREENCANVAS_SUPPORT=1 -sFULL_ES2 -sFULL_ES3"
#

LDFLAGS="-sUSE_GLFW=3 -sUSE_WEBGL2 -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sOFFSCREENCANVAS_SUPPORT=1 -sFULL_ES2 -sFULL_ES3"

LDFLAGS="$LDFLAGS -lsqlite3"

Expand Down
14 changes: 14 additions & 0 deletions scripts/build-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

. scripts/vendoring.sh

if [ -f vendor/vendor.sh ]
then
echo " vendor build"
if ${ABI3:-false}
then
echo " vendor build (abi3) $PYBUILD"
if echo $PYBUILD|grep -v -q 3.12$
then
echo "abi3 vendor build only, skipping $PYBUILD"
exit 0
fi
fi
fi

export PYMAJOR=$(echo -n $PYBUILD|cut -d. -f1)
export PYMINOR=$(echo -n $PYBUILD|cut -d. -f2)

Expand Down
7 changes: 7 additions & 0 deletions scripts/build-pkpy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/bash

if [ -f vendor/vendor.sh ]
then
echo "vendor build, skipping"
exit 0
fi

reset

PW=$(realpath patchwork/pykpocket)
Expand Down
4 changes: 3 additions & 1 deletion src/pygbag/aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
if aio.pep0723.Config.dev_mode:
aio.pep0723.Config.PKG_INDEXES.extend(["http://localhost:8000/archives/repo/"])
else:
aio.pep0723.Config.PKG_INDEXES.extend(["https://pygame-web.github.io/archives/repo/"])
aio.pep0723.Config.PKG_INDEXES.extend([
os.environ.get('PYGPY', "https://pygame-web.github.io/archives/repo/"),
])

import pygbag.__main__

Expand Down
25 changes: 15 additions & 10 deletions src/pygbag/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
DEFAULT_CONSOLE = 25
DEFAULT_LINES = 57
DEFAULT_COLUMNS = 132
DEFAULT_PYBUILD = "3.12"

CACHE_ROOT = Path("build")
CACHE_PATH = CACHE_ROOT / "web-cache"
Expand Down Expand Up @@ -161,17 +162,21 @@ def make_cache_dirs():

if clear_cache:
win32 = sys.platform == "win32"
if shutil.rmtree.avoids_symlink_attacks or win32:
if cache_dir.is_dir():
if cache_dir.is_dir():
if shutil.rmtree.avoids_symlink_attacks or win32:
if win32:
warnings.warn("clear cache : rmtree is not safe on that system (win32)")
shutil.rmtree(cache_dir.as_posix())
else:
print(
"115: cannot clear cache : rmtree is not safe on that system",
file=sys.stderr,
)
raise SystemExit(115)
else:
print(
"171: cannot clear cache : rmtree is not safe on that system",
file=sys.stderr,
)
print(
"175: Please remove build folder manually",
file=sys.stderr,
)
raise SystemExit(115)

# rebuild
make_cache_dirs()
Expand Down Expand Up @@ -210,8 +215,8 @@ async def main_run(app_folder, mainscript, cdn=DEFAULT_CDN):

parser.add_argument(
"--PYBUILD",
default="3.11",
help="Specify python version [default:%s]" % "3.11",
default=DEFAULT_PYBUILD,
help="Specify python version [default:%s]" % DEFAULT_PYBUILD,
)

parser.add_argument(
Expand Down
3 changes: 2 additions & 1 deletion src/pygbag/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/.github
/.vscode
/.idea
/.DS_Store
/dist
/build
/venv
Expand All @@ -26,7 +27,7 @@
"\n"
)

SKIP_EXT = ["pyc", "pyx", "pyd", "pyi", "exe", "log", "blend", "DS_Store"]
SKIP_EXT = ["pyc", "pyx", "pyd", "pyi", "exe", "bak", "log", "blend", "DS_Store"]


def filter(walked):
Expand Down
14 changes: 10 additions & 4 deletions src/pygbag/optimizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def optimize(folder, filenames, **kw):

def optimize(folder, filenames, **kw):
global BAD
print("optimizing", folder)
if "--no_opt" in sys.argv:
print("NOT optimizing", folder)
else:
print("optimizing", folder)
png_quality = 50

done_list = []
Expand All @@ -57,10 +60,13 @@ def optimize(folder, filenames, **kw):
except ImportError:
warnings.warn(f"Black not found for processing {folder=}")

if os.popen("pngquant 2>&1").read().count("pngfile"):
print(f" -> with pngquant --quality {png_quality}", folder)
if "--no_opt" in sys.argv:
pass
else:
png_quality = -1
if os.popen("pngquant 2>&1").read().count("pngfile"):
print(f" -> with pngquant --quality {png_quality}", folder)
else:
png_quality = -1

has_ffmpeg = os.popen("ffmpeg -version").read().count("version")

Expand Down
Loading

0 comments on commit 6ade9fe

Please sign in to comment.