gyli/PyWaffle

Request: ability to use system-packaged Fontawesome if found?

mattdm opened this issue · 3 comments

In Fedora, we have FontAwesome as an included package, and our packaging guidelines require bundled fonts to be ... debundled.

I've patched this in to my package build scripts (see https://mattdm.org/misc/fedora/pywaffle/python-pywaffle.spec), but it would be ideal if the library just noticed and used those. I guess this could be a "build time" thing, but I'm thinking maybe if

/usr/share/fonts/fontawesome5-free-fonts/Font Awesome 5 Free-Regular-400.otf
/usr/share/fonts/fontawesome5-free-fonts/Font Awesome 5 Free-Solid-900.otf
/usr/share/fonts/fontawesome5-brands-fonts/Font Awesome 5 Brands-Regular-400.otf

are installed, those could be automatically used -- with the mappings created at runtime from /usr/share/fontawesome5/metadata/icons.json.

That'd also benefit people who install via pip or whatever.

What do you think?

gyli commented

A major concern I have is the package is unlikely to be packaged and distributed for specific systems or system versions, in order to remain simple. So I don't see a way I can debundle the fonts for Fedora users only. If the package will ship with fonts anyways, it would be meaningless to use the system's fonts and generate mapping on it.

I am also thinking if it is feasible to create dedicated dependencies for Fedora. By checking PEP-508, I don't find an environment marker that can return Linux distro name.

Do you have any idea how it can be debundled for Fedora, or do you have any other Python packages as an example?

What I'm currently doing:

  1. Patch pywaffle/fontawesome/__init__.py to look at the system paths
  2. Patch pywaffle/scripts/get_fontawesome.py to load the JSON from the local file in its Fedora location rather than a web URL (also removing requests, as that's not needed)
  3. Run that script to regenerate pywaffle/fontawesome_mapping.py so it matches what's available in the local font.
  4. Package that up into an RPM.

This is fine, but it means people will get a different experience if they install from pypi. Let me check with our python packaging experts and see what they think we should do.

gyli commented

Yeah, please let me know if I can package it in a different way, and ideally we can make it smaller for Fedora users.

FYI, I moved pywaffle/scripts/get_fontawesome.py to scripts/get_fontawesome.py to avoid confusion, as it's not included in the package, but only for development.