Skip to content

Commit

Permalink
maybe solve #156
Browse files Browse the repository at this point in the history
  • Loading branch information
pmp-p committed Sep 4, 2024
1 parent 1d8cdc6 commit c00835b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 21 deletions.
9 changes: 5 additions & 4 deletions scripts/build-loader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ echo CPY_CFLAGS=$CPY_CFLAGS



if [ -f /data/git/pygbag/integration/${INTEGRATION}.h ]
if [ -f ${WORKSPACE}/integration/${INTEGRATION}.h ]
then
LNK_TEST=/data/git/pygbag/integration/${INTEGRATION}
LNK_TEST=${WORKSPACE}/integration/${INTEGRATION}
else
LNK_TEST=/tmp/pygbag_integration_test
fi
Expand All @@ -242,7 +242,7 @@ INC_TEST="${LNK_TEST}.h"
MAIN_TEST="${LNK_TEST}.c"


touch ${INT_TEST} ${INC_TEST} ${MAIN_TEST}
touch ${INT_TEST} ${INC_TEST} ${LNK_TEST} ${MAIN_TEST}

# -L${SDKROOT}/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic only !

Expand Down Expand Up @@ -294,6 +294,8 @@ then
if [ -f $cpylib ]
then
LDFLAGS="$LDFLAGS $cpylib"
else
echo " Not found : $cpylib"
fi
done

Expand All @@ -318,7 +320,6 @@ then
# EXTRA_EXPORTED_RUNTIME_METHODS => EXPORTED_RUNTIME_METHODS after 3.1.52



PG=/pgdata
cat > final_link.sh <<END
#!/bin/bash
Expand Down
2 changes: 1 addition & 1 deletion src/pygbag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from pathlib import Path

VERSION = "0.9.3"
VERSION = "0.9.2"

# hack to test git cdn build without upgrading pygbag
# beware can have side effects when file packager behaviour must change !
Expand Down
74 changes: 59 additions & 15 deletions src/pygbag/support/cross/aio/pep0723.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import re

print(sys.path)
import tomllib

import json
Expand All @@ -27,6 +26,7 @@
import platform
import platform_wasm.todo

from zipfile import ZipFile

# TODO: maybe control wheel cache with $XDG_CACHE_HOME/pip

Expand Down Expand Up @@ -67,6 +67,10 @@ class Config:
pkg_repolist = []
dev_mode = ".-X.dev." in ".".join([""] + sys.orig_argv + [""])

Requires_Dist = []
Requires_Processing = []
Requires_Failures = []

mapping = {
"pygame": "pygame.base",
"pygame_ce": "pygame.base",
Expand Down Expand Up @@ -131,18 +135,6 @@ def read_dependency_block_723(code):
yield dep


def read_dependency_block_723x(script):
name = "pyproject"
matches = list(filter(lambda m: m.group("type") == name, re.finditer(Config.BLOCK_RE_723, script)))
if len(matches) > 1:
raise ValueError(f"Multiple {name} blocks found")
elif len(matches) == 1:
print(tomllib.loads(matches[0]))
yield "none"
else:
return None


def install(pkg_file, sconf=None):
global HISTORY
from installer import install
Expand Down Expand Up @@ -238,12 +230,57 @@ async def async_repos():
for idx, repo in enumerate(Config.pkg_repolist):
repo["-CDN-"] = rewritecdn

def processing(dep):
if dep in HISTORY:
return True
if dep in Config.Requires_Processing:
return True
if dep in Config.Requires_Failures:
return True
return False


async def install_pkg(sysconf, wheel_url, wheel_pkg):
target_filename = f"/tmp/{wheel_pkg}"
async with fopen(wheel_url, "rb") as pkg:
with open(target_filename, "wb") as target:
target.write(pkg.read())
pkg.seek(0)
with ZipFile(pkg) as archive:
for name in archive.namelist():
if name.endswith(".dist-info/METADATA"):
for line in archive.open(name).read().decode().splitlines():
if line.startswith('Requires-Dist: '):
if line.find('; extra ')>0:
continue
req = Requirement(line[15:])
if req.extras:
continue
if processing(req.name):
continue
if not req.name in Config.Requires_Dist:
Config.Requires_Dist.insert(0,req.name)
while len(Config.Requires_Dist):
elem = None
for elem in Config.Requires_Dist:
if not processing(elem):
break
else:
break
Config.Requires_Processing.append(elem)
print(f"# 265: {elem=}")
if not await pip_install(elem, sysconf):
print(f"install: {wheel_pkg} is missing {elem}")
else:
try:
Config.Requires_Processing.remove(elem)
except:
pass
try:
Config.Requires_Dist.remove(elem)
except:
pass

install(target_filename, sysconf)


Expand All @@ -264,6 +301,8 @@ def do_patches():
# FIXME: HISTORY and invalidate caches
async def pip_install(pkg, sysconf={}):
global sconf
if pkg in Config.Requires_Failures:
return
if pkg in HISTORY:
return

Expand Down Expand Up @@ -314,11 +353,16 @@ async def pip_install(pkg, sysconf={}):
await install_pkg(sysconf, wheel_url, wheel_pkg)
if pkg not in HISTORY:
HISTORY.append(pkg)
except:
print("324: INVALID", pkg, "from", wheel_url)
return True
except Exception as e:
print("324: INVALID", pkg, "from", wheel_url, e)
#sys.print_exception(e)
else:
print(f"309: no provider found for {pkg}")

if not pkg in Config.Requires_Failures:
Config.Requires_Failures.append(pkg)


PYGAME = 0

Expand Down
3 changes: 2 additions & 1 deletion wasm-build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ reset

export CI=${CI:-false}

export WORKSPACE=${GITHUB_WORKSPACE:-$(pwd)}

BUILDS=${BUILDS:-3.12 3.11}
export BUILDS=${BUILDS:-3.12 3.11}

export STATIC=${STATIC:-true}

Expand Down

0 comments on commit c00835b

Please sign in to comment.