Skip to content

Commit

Permalink
try to fix freetype init for full dynamic wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
pmp-p committed Sep 19, 2023
1 parent ad11989 commit da363fc
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 155 deletions.
24 changes: 24 additions & 0 deletions packages.d/pygame/pygame.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,30 @@ then
#unsure
wget -O- https://patch-diff.githubusercontent.com/raw/pmp-p/pygame-ce-wasm/pull/3.diff | patch -p1

patch -p1 << END
diff --git a/src_c/static.c b/src_c/static.c
index 03cc7c61..a00a51a7 100644
--- a/src_c/static.c
+++ b/src_c/static.c
@@ -255,9 +255,17 @@ static struct PyModuleDef mod_pygame_static = {PyModuleDef_HEAD_INIT,
"pygame_static", NULL, -1,
mod_pygame_static_methods};
+#include <SDL2/SDL_ttf.h>
+
PyMODINIT_FUNC
PyInit_pygame_static()
{
+ {
+ if (TTF_Init())
+ fprintf(stderr, "ERROR: TTF_Init error");
+ SDL_SetHint("SDL_EMSCRIPTEN_KEYBOARD_ELEMENT", "1");
+ }
+
load_submodule("pygame", PyInit_base(), "base");
load_submodule("pygame", PyInit_constants(), "constants");
load_submodule("pygame", PyInit_surflock(), "surflock");
END

# cython3 / merged
# wget -O- https://patch-diff.githubusercontent.com/raw/pygame-community/pygame-ce/pull/2395.diff | patch -p1
Expand Down
2 changes: 1 addition & 1 deletion pygbag/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ async def async_imports(cls, callback, *wanted, **kw):
...

@classmethod
def list_imports(cls, code=None, file=None):
def list_imports(cls, code=None, file=None, hint=""):
return []

def eval(self, source):
Expand Down
50 changes: 28 additions & 22 deletions pygbag/support/cross/aio/pep0723.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,30 +204,9 @@ async def pip_install(pkg, sconf={}):
print("ERROR", wheel_url)



async def check_list(code=None, filename=None):
print()
print("-" * 11, "computing required packages", "-" * 10)

# store installed wheel somewhere
env = Path(os.getcwd()) / "build" / "env"
env.mkdir(parents=True, exist_ok=True)

# we want host to load wasm packages too
# so make pure/bin folder first for imports
sys.path.insert(0, env.as_posix())

sconf = __import__("sysconfig").get_paths()
sconf["purelib"] = sconf["platlib"] = env.as_posix()

# mandatory
importlib.invalidate_caches()

async def parse_code(code, env):
maybe_missing = []

if code is None:
code = open(filename, "r").read()

if Config.READ_722:
for req in read_dependency_block_722(code):
pkg = str(req)
Expand Down Expand Up @@ -256,6 +235,33 @@ async def check_list(code=None, filename=None):
else:
print("found in path :", dep)

return still_missing


async def check_list(code=None, filename=None):
print()
print("-" * 11, "computing required packages", "-" * 10)

# store installed wheel somewhere
env = Path(os.getcwd()) / "build" / "env"
env.mkdir(parents=True, exist_ok=True)

# we want host to load wasm packages too
# so make pure/bin folder first for imports
sys.path.insert(0, env.as_posix())

sconf = __import__("sysconfig").get_paths()
sconf["purelib"] = sconf["platlib"] = env.as_posix()

# mandatory
importlib.invalidate_caches()


if code is None:
code = open(filename, "r").read()

still_missing = await parse_code(code, env)

# nothing to do
if not len(still_missing):
return
Expand Down
Loading

0 comments on commit da363fc

Please sign in to comment.