Skip to content

Commit

Permalink
fix one frame pygame import
Browse files Browse the repository at this point in the history
  • Loading branch information
pmp-p committed Nov 23, 2023
1 parent 31faf3f commit 2a891a6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
11 changes: 8 additions & 3 deletions pygbag/support/cross/aio/pep0723.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
if sconf["platlib"] not in sys.path:
sys.path.append(sconf["platlib"])


PATCHLIST = []
HISTORY = []

Expand Down Expand Up @@ -298,9 +297,9 @@ async def pip_install(pkg, sysconf={}):
except:
print("212: INVALID", pkg, "from", wheel_url)


PYGAME=0
async def parse_code(code, env):
global PATCHLIST
global PATCHLIST, PYGAME

maybe_missing = []

Expand Down Expand Up @@ -332,6 +331,12 @@ async def parse_code(code, env):
if dep in platform.patches:
PATCHLIST.append(dep)

# special case of pygame code in pygbag site-packages
if dep == 'pygame.base' and not PYGAME:
PYGAME=1
still_missing.append(dep)
continue

if not importlib.util.find_spec(dep) and dep not in still_missing:
still_missing.append(dep)
else:
Expand Down
25 changes: 20 additions & 5 deletions pygbag/support/pythonrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ async def preload_code(cls, code, callback=None, hint=""):

DBG(f"654: aio.pep0723.check_list {aio.pep0723.env=}")
deps = await aio.pep0723.check_list(code)

DBG(f"656: aio.pep0723.pip_install {deps=}")

# auto import plumbing to avoid rely too much on import error
Expand Down Expand Up @@ -1239,9 +1240,10 @@ def import_one(cls, mod, lvl=0):
deps.reverse()
DBG(
f"""
1176: added {deps=} for {mod=}
{cls.missing_fence=}
1242:
added {deps=} for {mod=}
1243:
{cls.missing_fence=}
"""
)
Expand Down Expand Up @@ -1344,20 +1346,33 @@ def default_cb(pkg, error=None):

callback = callback or default_cb

print("1302: ============= ", wanted)
print("1302: unscheduled imports :", wanted)

wants = cls.imports(*wanted)
all = list(cls.missing_fence)
print("1305: PRE REQ ", cls.missing_fence)
print("1305: pre-required :", cls.missing_fence)
all.extend(wants)
print("1308: IMPORT FINAL ", all)

async def import_now(mod):
nonlocal all
if not mod in all:
return
print(f'1359: FIXME: re-ordering of {mod=} from {aio.pep0723.sconf["platlib"]=}')
all.remove(mod)
await cls.async_get_pkg(mod, None, None)

# anticipated wasm compilation
if not aio.cross.simulator:
import platform
#sconf = sysconfig.get_paths()
#platlib = sconf["platlib"]
#platform.explore(platlib)
platform.explore(aio.pep0723.sconf["platlib"])
await asyncio.sleep(0)
await asyncio.sleep(0)
await asyncio.sleep(0)

__import__(mod)

# always put numpy first
Expand Down
3 changes: 2 additions & 1 deletion scripts/vendoring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ if $CI
then
export PYGBAG_BUILD=0.0
else
export PYGBAG_BUILD=$($SYS_PYTHON -c "print(__import__('pygbag').__version__)"|tail -n 1|cut -f1-2 -d.)
# export PYGBAG_BUILD=$($SYS_PYTHON -c "print(__import__('pygbag').VERSION)"|tail -n 1|cut -f1-2 -d.)
export PYGBAG_BUILD=0.0
fi

export DIST_DIR=$(pwd)/build/web/archives/${PYGBAG_BUILD}
Expand Down

0 comments on commit 2a891a6

Please sign in to comment.