Skip to content

Commit 79cb1f7

Browse files
committed
3.13 git pgce test
1 parent 8703fb0 commit 79cb1f7

File tree

7 files changed

+78
-55
lines changed

7 files changed

+78
-55
lines changed

packages.d/pygame/pygame.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@ then
105105
# new cython (git)
106106
wget -O- https://patch-diff.githubusercontent.com/raw/pmp-p/pygame-ce-wasm/pull/8.diff | patch -p1
107107

108-
# added Vector2.from_polar and Vector3.from_spherical classmethods
109-
# breaks, left a review !
110-
# wget -O- https://patch-diff.githubusercontent.com/raw/pygame-community/pygame-ce/pull/2141.diff | patch -p1
111-
108+
# fix 3.13 build
109+
wget -O- https://patch-diff.githubusercontent.com/raw/pmp-p/pygame-ce-wasm/pull/9.diff | patch -p1
112110

113111
# cython3 / merged
114112
# wget -O- https://patch-diff.githubusercontent.com/raw/pygame-community/pygame-ce/pull/2395.diff | patch -p1
@@ -227,6 +225,7 @@ fi
227225
rm -rf build Setup
228226
# ===================
229227

228+
230229
if ${CI:-false}
231230
then
232231
touch $(find | grep pxd$)
@@ -239,6 +238,9 @@ then
239238
fi
240239
else
241240
echo "skipping cython regen"
241+
touch $(find | grep pxd$)
242+
$HPY setup.py cython_only
243+
242244
fi
243245

244246
#$HPY ${WORKSPACE}/src/replacer.py --go "Py_GIL_DISABLED'\): raise ImportError" "Py_GIL_DISABLED'): print(__name__)"
@@ -247,7 +249,7 @@ fi
247249
#SDL_IMAGE="-s USE_SDL=2 -lfreetype -lwebp"
248250
SDL_IMAGE="-lSDL2 -lfreetype -lwebp"
249251

250-
export CFLAGS="-DSDL_NO_COMPAT $SDL_IMAGE"
252+
export CFLAGS="-DBUILD_STATIC -DSDL_NO_COMPAT $SDL_IMAGE"
251253
EMCC_CFLAGS="-I${SDKROOT}/emsdk/upstream/emscripten/cache/sysroot/include/freetype2"
252254
EMCC_CFLAGS="$EMCC_CFLAGS -I$PREFIX/include/SDL2"
253255
EMCC_CFLAGS="$EMCC_CFLAGS -Wno-unused-command-line-argument"
@@ -262,8 +264,8 @@ EMCC_CFLAGS="$EMCC_CFLAGS -Wno-deprecated-declarations"
262264

263265

264266

265-
export EMCC_CFLAGS="$EMCC_CFLAGS -DHAVE_STDARG_PROTOTYPES -DBUILD_STATIC -ferror-limit=1 -fpic"
266-
267+
export EMCC_CFLAGS="$EMCC_CFLAGS -DHAVE_STDARG_PROTOTYPES -ferror-limit=1 -fpic -DBUILD_STATIC"
268+
export COPTS="-O2 -g3 -DBUILD_STATIC"
267269
export CC=emcc
268270

269271
# remove SDL1 for good
@@ -334,7 +336,7 @@ then
334336

335337
[ -f ${TARGET_FILE} ] && rm ${TARGET_FILE} ${TARGET_FILE}.map
336338

337-
COPTS="-Os -g0" emcc -shared -fpic -o ${TARGET_FILE} $SDKROOT/prebuilt/emsdk/libpygame${PYMAJOR}.${PYMINOR}.a $SDL2
339+
COPTS="-O2 -g3" emcc -shared -fpic -o ${TARGET_FILE} $SDKROOT/prebuilt/emsdk/libpygame${PYMAJOR}.${PYMINOR}.a $SDL2
338340

339341
# github CI does not build wheel for now.
340342
echo ${WHEEL_DIR}

scripts/build-rootfs.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ import platform
6868
# for pyodide runPython emulation
6969
from textwrap import dedent
7070
71+
# requests/urllib3 pyodide workaround
72+
import http.cookiejar
73+
from http.cookies import Morsel
74+
import encodings.idna
75+
7176
# FIXME: because _sqlite3 is builtins anyway ?
7277
import sqlite3
7378

src/pygbag/support/cpythonrc.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,8 @@ async def preload_code(cls, code, callback=None, loaderhome=".", hint=""):
719719

720720
# auto import plumbing to avoid rely too much on import error
721721
maybe_wanted = list(TopLevel_async_handler.list_imports(code, file=None, hint=hint))
722-
DBG(f"635: {maybe_wanted=} known failed {aio.pep0723.hint_failed=}")
722+
723+
DBG(f"723: {maybe_wanted=} known failed {aio.pep0723.hint_failed=} {aio.pep0723.HISTORY=}")
723724

724725
# FIXME use an hybrid wheel
725726
if "pyodide" in aio.pep0723.hint_failed:
@@ -1197,6 +1198,8 @@ def scan_imports(cls, code, filename, load_try=False, hint=""):
11971198
mod = n.name.split(".")[0]
11981199

11991200
mod = aio.pep0723.Config.mapping.get(mod, mod)
1201+
if mod in aio.pep0723.HISTORY:
1202+
continue
12001203

12011204
if mod in cls.ignore:
12021205
continue
@@ -1249,7 +1252,7 @@ def list_imports(cls, code=None, file=None, hint=""):
12491252
file = file or "<stdin>"
12501253

12511254
for want in cls.scan_imports(code, file, hint=hint):
1252-
# DBG(f"1114: requesting module {want=} for {file=} ")
1255+
DBG(f"1265: requesting module {want=} for {file=} ")
12531256
repo = None
12541257
for repo in aio.pep0723.Config.pkg_repolist:
12551258
if want in cls.may_need:
@@ -1291,9 +1294,13 @@ def import_one(cls, mod, lvl=0):
12911294

12921295
if mod in cls.missing_fence:
12931296
return []
1294-
from aio.pep0723 import Config
1297+
1298+
from aio.pep0723 import Config, HISTORY
12951299

12961300
for dep in Config.repos[0]["packages"].get(mod, {}).get("depends", []):
1301+
if dep in HISTORY:
1302+
continue
1303+
12971304
if dep in cls.ignore:
12981305
continue
12991306

src/pygbag/support/cross/aio/pep0723.py

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@
5656

5757

5858
class Config:
59-
# READ_722 = False
6059
READ_723 = True
61-
# BLOCK_RE_722 = r"(?i)^#\s+script\s+dependencies:\s*$"
6260
BLOCK_RE_723 = r"(?m)^# /// (?P<type>[a-zA-Z0-9-]+)$\s(?P<content>(^#(| .*)$\s)+)^# ///$"
6361
PKG_BASE_DEFAULT = "https://pygame-web.github.io/archives/repo/"
6462
PKG_INDEXES = []
@@ -75,41 +73,16 @@ class Config:
7573
mapping = {
7674
"pygame": "pygame.base",
7775
"pygame_ce": "pygame.base",
76+
"pygame_static": "pygame.base",
7877
"python_i18n": "i18n",
7978
"pillow": "PIL",
8079
"pyglm": "glm",
8180
"opencv_python": "cv2",
8281
"pysdl3": "sdl3",
8382
}
8483

85-
86-
def read_dependency_block_722(code):
87-
# Skip lines until we reach a dependency block (OR EOF).
88-
has_block = False
89-
# Read dependency lines until we hit a line that doesn't
90-
# start with #, or we are at EOF.
91-
for line in code.split("\n"):
92-
if not has_block:
93-
if re.match(Config.BLOCK_RE_722, line):
94-
has_block = True
95-
continue
96-
97-
if not line.startswith("#"):
98-
break
99-
# Remove comments. An inline comment is introduced by
100-
# a hash, which must be preceded and followed by a
101-
# space.
102-
line = line[1:].split(" # ", maxsplit=1)[0]
103-
line = line.strip()
104-
# Ignore empty lines
105-
if not line:
106-
continue
107-
# Try to convert to a requirement. This will raise
108-
# an error if the line is not a PEP 508 requirement
109-
yield Requirement(line)
110-
111-
11284
def read_dependency_block_723(code):
85+
global HISTORY, hint_failed
11386
# Skip lines until we reach a dependency block (OR EOF).
11487
has_block = False
11588

@@ -143,7 +116,7 @@ def install(pkg_file, sconf=None):
143116
from installer.destinations import SchemeDictionaryDestination
144117
from installer.sources import WheelFile
145118
if pkg_file in HISTORY:
146-
print(f"# 144: install: {pkg_file} already installed")
119+
print(f"# 144: install: {pkg_file} already installed or skipped")
147120
return
148121

149122
# Handler for installation directories and writing into them.
@@ -374,34 +347,34 @@ async def pip_install(pkg, sysconf={}):
374347

375348

376349
async def parse_code(code, env):
377-
global PATCHLIST, PYGAME
350+
global PATCHLIST, PYGAME, HISTORY, hint_failed
378351

379352
maybe_missing = []
380353

381-
# if Config.READ_722:
382-
# for req in read_dependency_block_722(code):
383-
# pkg = str(req)
384-
# if (env / pkg).is_dir():
385-
# print("found in env :", pkg)
386-
# continue
387-
# elif pkg not in maybe_missing:
388-
# # do not change case ( eg PIL )
389-
# maybe_missing.append(pkg.lower().replace("-", "_"))
354+
import platform
390355

391356
if Config.READ_723:
392357
for req in read_dependency_block_723(code):
393358
pkg = str(req)
394359
if (env / pkg).is_dir():
395360
print("found in env :", pkg)
396361
continue
362+
elif pkg and pkg[0]=='!':
363+
skip = pkg[1:]
364+
if not skip in HISTORY:
365+
HISTORY.append(skip)
366+
if not skip in hint_failed:
367+
hint_failed.append(skip)
368+
if skip in platform.patches:
369+
if not skip in PATCHLIST:
370+
PATCHLIST.append(skip)
371+
continue
397372
elif pkg not in maybe_missing:
398373
# do not change case ( eg PIL )
399374
maybe_missing.append(pkg.lower().replace("-", "_"))
400375

401376
still_missing = []
402377

403-
import platform
404-
405378
for dep in maybe_missing:
406379
if dep in platform.patches:
407380
PATCHLIST.append(dep)

src/pygbag/support/pyodide.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,27 @@
1010
import js
1111

1212

13+
def jsa(*argv):
14+
return platform.window.JSON.parse(json.dumps(argv))
15+
16+
def jso(**kw):
17+
return platform.window.JSON.parse(json.dumps(kw))
18+
1319
class ffi:
1420
def create_proxy(self, fn):
1521
print(fn)
1622
return fn
1723

24+
def JsArray(self, *it):
25+
return jsa(*it)
26+
def JsException(self, *argv, **kw):
27+
pass
28+
def JsProxy(self, *argv, **kw):
29+
pass
30+
31+
def to_js(self, *argv, **kw):
32+
pass
33+
1834

1935
ffi = ffi()
2036

src/pygbag/support/readline.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,28 @@ def add_history(line: str):
666666
readline.history.append(line)
667667

668668

669-
def get_history_item(index: int): ...
669+
def get_history_item(index: int):
670+
pass
671+
670672

671673

672674
def get_current_history_length():
673675
return len(readline.history)
676+
677+
# == TODO ==
678+
679+
def set_completer(todo):
680+
pass
681+
682+
def parse_and_bind(todo):
683+
#'tab: complete'
684+
pass
685+
686+
def read_init_file(*todo):
687+
pass
688+
689+
def read_history_file(*todo):
690+
pass
691+
692+
def write_history_file(*todo):
693+
pass

support/__EMSCRIPTEN__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ main(int argc, char **argv)
10711071
setenv("HOME", "/home/web_user", 1);
10721072
setenv("APPDATA", "/home/web_user", 1);
10731073

1074-
setenv("PYGLET_HEADLESS", "1", 1);
1074+
// setenv("PYGLET_HEADLESS", "1", 1);
10751075
setenv("PSYCOPG_WAIT_FUNC", "wait_select", 1);
10761076

10771077
// rich

0 commit comments

Comments
 (0)