Giter Club home page Giter Club logo

Comments (11)

anthrotype avatar anthrotype commented on June 16, 2024

i'm not even sure that loading dynamic libraries via cytpes is supported with emscripten python..
googling around I found this pyodide/pyodide#728

from freetype-py.

anthrotype avatar anthrotype commented on June 16, 2024

since pyodide/pyodide#1656 was merged, ctypes is supposedly supported in pyodide.
Maybe you simply don't have the libfreetype.so installed, or your linker can't find it in the default library search paths (try setting LD_LIBRARY_PATH or DYLD_LIBRARY_PATH).

I also found pyodide/pyodide#2338 while searching for "synchronous loading of external files is not available" error.

I've never used emscripten python, maybe other maintainers know more.

from freetype-py.

HinTak avatar HinTak commented on June 16, 2024

from freetype-py.

jansindl3r avatar jansindl3r commented on June 16, 2024

I am on MacOs, but that shouldn't influence Pyodide, right? Thanks for pointing out the issue on Pyodide. Sorry, I am not that knowledgeable. I think my comment has nothing to do with this library, but rather with Pyodide.

This wrapper relies on the FreeType installed by the OS, like via brew, right? I guess the browser won't be able to access it anyway, even after the fix. Then I need to compile FreeType to .so and put it somewhere so freetype/raw.py can find it and then generate wheel out of this package, I believe 🙈

from freetype-py.

anthrotype avatar anthrotype commented on June 16, 2024

we do provide precompiled wheels for most platforms/py-versions already, they are published on the Python Packaging Index (PyPI), it's what gets normally installed when you do pip install freetype-py

from freetype-py.

anthrotype avatar anthrotype commented on June 16, 2024

ok you're on mac so you should find the library under the name "libfreetype.dylib".. but instead of "Darwin" you get "Emscripten" from platform.system() so it falls back to the (implicit) "Linux" else branch of the if statement.
Not sure what's the best way to detect this situation.

from freetype-py.

anthrotype avatar anthrotype commented on June 16, 2024

how did you install freetype-py in pyodide? Using micropip.install?

not sure, but maybe we need to build a custom Pyodide package where the freetype library itself is converted to webassembly?

https://pyodide.org/en/stable/development/new-packages.html#c-library-dependencies

from freetype-py.

HinTak avatar HinTak commented on June 16, 2024

from freetype-py.

anthrotype avatar anthrotype commented on June 16, 2024

pyodide is cpython compiled to webassembly, it runs in a special vm inside the browser, it doesn't have access to external libraries. We need to make a pyodide package as explained in the pyodide docs link I posted above. We're lucky in that there's already an emscripten port for the freetype library itself, so it's a matter of doing something similar to what they do for the pyodide package for "matplotlib" module (which also depends on the freetype library):
https://github.com/pyodide/pyodide/blob/38fae6e9cbcdd8e932a53bf1c763279dc55729d5/packages/matplotlib/meta.yaml#L24-L26

from freetype-py.

HinTak avatar HinTak commented on June 16, 2024

from freetype-py.

anthrotype avatar anthrotype commented on June 16, 2024

The emscripten port of freetype is really old though

yeah, 2.6 is quite old. Some user of the emscripten port reported success in building freetype with the emcmake tool

I discovered that the latest FreeType builds fine using emcmake cmake with their latest CMakeLists.txt file, so I switched to using that in my workflow.

emscripten-ports/FreeType#4 (comment)

So it's technically feasible, only need someone to take the time to understand how to build a pyodide package and make a PR upstream to include in pyodide's own built-in packages.

from freetype-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.