Where is Glyphs python library located?

I am running Python 3.10.7 that’s installed through homebrew. But, somehow, it won’t recognize Glyphs:

f1 = Glyphs.fonts[0]

which prints an error:

Traceback (most recent call last):
  File "<internal>", line 4
  File "GlyphsApp/GlyphsApp/__init__.py", line 642
AttributeError: Cannot replace selector 'font' in 'GSApplication' by non-selector
Traceback (most recent call last):
  File "<macro panel>", line 19
NameError: name 'Glyphs' is not defined

I remember that Glyphs is somehow imported automatically without an explicit import Glyphs at the top. I am curious, how do I add Glyphs to site-packages in my interpreter and install it? or alternatively, where is it located so that I can sys.path.append the path?

Btw, which python on my terminal session returns:

>> which python
/Users/neil/.pyenv/shims/python

I am using pyenv to manage my python versions. I’d appreciate some help on finding Glyphs.__init__.py location on macOS. I tried searching around in Glyphs.app/Content/Resources with no luck.

The other thing I tried is to install python plugin from Plugins manager which installs 3.9.1 (Glyphs) version. I selected it, restarted Glyphs and it would somehow automatically import Glyphs, that works fine. But, I want to install other libraries in that 3.9.1 interpreter, particularly boto3 to interact with AWS.

So, to summarize, I have the following questions:

  1. What is the magic behind the scenes that imports Glyphs library? Where is it located in the system so that I can manually import it?

  2. Where is the 3.9.1 (Glyphs) interpreter located so that I can install my own libraries in that interpreter?

Either 1 or 2 would work, but I would prefer to understand the magic. Much prefer explicitness over implicitness :slight_smile:

Please have a look here: Scripts not working "Glyphs is not defined" - #5 by GeorgSeifert

I installed pip3 install pyobjc successfully, but still getting the error message with `3.10.7 (Homebrew).

I would like to understand the mechanism of import that Glyphs scripts window does and all the paths, instead of applying a fix and not understanding how it works.

Could you kindly elaborate on the paths of both 1) Glyphs python library and 2) Glyphs (3.9.1 Glyphs) interpreter. I just need the location of those. I will figure out the rest from there.