touilleMan / godot-python

Python support for Godot 🐍🐍🐍
Other
1.87k stars 140 forks source link

Using pip install on Mac - or alternative workaround for installing site packages? #273

Closed whogben closed 3 years ago

whogben commented 3 years ago

Hi, I am following up if anyone has a process for using pip install on Mac with the latest godot-python release.

155 mentions that it requires one workaround with adding an absolute path to a file, but doesn't describe the workaround in enough detail for me to understand it (which path, which file).

In a much earlier version of godot-python, I got around a pip issue by installing my site packages on my system python (of the same version), then copying them into the site packages within the godot-python addon. I tried to look for a similar workaroudn here, but there's no site-packages folder now - is there an alternative location that site packages could be manually installed to get around the pip issue in the near term?

Thanks for reading - this project is amazing!

touilleMan commented 3 years ago

Hi @whogben !

The idea behind Godot-Python is to ship a standalone Python interpreter along with a .so file (shared library) that will be loaded by Godot (through Godot's GDNative, NativeScript and PluginScript APIs, but you don't have to care about this if you're just a user :smile: ) and act as bridge between Godot and Python.

So if you want to do pip install, you need to find this Python interpreter from within the Godot-Python folder:

$ cd my_godot_project
$ cd addons/pythonscript  # For historical reasons, Godot-Python is called pythonscript
$ find . -name "python*"
[bunch of python related files]
./x11-64/bin/python3
./x11-64/bin/python3.8
[some other python related files]

Note this python interpreter works just like a regular one, so you can execute without arguments it to get a repl. Note that running it this way makes it totally separated from Godot (doing import godot may even lead to a segfault !)

So now we should call pip to do the install: ./x11-64/bin/python3.8 -m pip install flask (and as #155 said, you should not use ./x11-64/bin/pip)

Thanks for reading - this project is amazing!

Thanks :kissing_heart: