clj-python / libpython-clj

Python bindings for Clojure
Eclipse Public License 2.0
1.06k stars 69 forks source link

[macos] Upgrade from python 3.6 to 3.9, libpython-clj is still trying to load libpython3.6m.dylib #138

Closed vxe closed 3 years ago

vxe commented 3 years ago

Here's the interaction

libpython-clj

Its not clear to me why its trying to use 3.6 but I think the bug didn't surface before because the 3.6 dylib was still on disk, but homebrew decided it was time to delete it after the last run of brew update

Is there something cached that's I need to delete to get it to recognize my 3.9 install?

cnuernber commented 3 years ago

Nothing is cached but we have a bit of code that is meant to detect the python version that appears to be failing.

It appears detect-startup-info is not working for you. What happens when you call this from the REPL?

vxe commented 3 years ago

detect-startup-info seems to returning 3.6 as a default

user> (libpython-clj.python.interpreter/detect-startup-info {})
{:python-home "/Library/Frameworks/Python.framework/Versions/3.6",
 :lib-version "3.6",
 :libname "python3.6m",
 :java-library-path-addendum
 "/Library/Frameworks/Python.framework/Versions/3.6/lib"}

when called with :python-executable for 3.9, its seems to spit out the right path for the dylib

user> (libpython-clj.python.interpreter/detect-startup-info {:python-executable "/usr/local/Cellar/python@3.9/3.9.0_2/bin/python3.9"})
{:python-home
 "/usr/local/Cellar/python@3.9/3.9.0_2/Frameworks/Python.framework/Versions/3.9",
 :lib-version "3.9",
 :libname "python3.9m",
 :java-library-path-addendum
 "/usr/local/Cellar/python@3.9/3.9.0_2/Frameworks/Python.framework/Versions/3.9/lib"}
cnuernber commented 3 years ago

Well, the quick work around is to provide :python-executable to initialize! and be sure to be the first one to call initialize. What happens if you attempt to tell the system exactly were the python executable is that you want it to use to setup it's library paths?

vxe commented 3 years ago

Might be related to the calling of python3-config --prefix as mentioned here , which points to 3.6

╰─➛ python3-config --prefix                                                                                                                                    
/Library/Frameworks/Python.framework/Versions/3.6

there appears to be additional version specific commands now

╰─➛ python3.9-config --prefix                                                                                                                                  
/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9

similar story for the python3 executable

─➛ python3 --version && python3.9 --version                                                                                                                   
Python 3.6.8
Python 3.9.0
vxe commented 3 years ago

^^ fixed the above with brew cleanup && brew reinstall python@3.9, detect-startup-info now spits out the right values

user> (libpython-clj.python.interpreter/detect-startup-info {})
{:python-home
 "/usr/local/Cellar/python@3.9/3.9.0_2/Frameworks/Python.framework/Versions/3.9",
 :lib-version "3.9",
 :libname "python3.9m",
 :java-library-path-addendum
 "/usr/local/Cellar/python@3.9/3.9.0_2/Frameworks/Python.framework/Versions/3.9/lib"}

however importing require-python still fails on attempting to load version 3.6 like in earlier screenshot, I think because of this bare call to (py/initialize!)

I see there was issue with the pyregex creation in version 3.8 , I am seeing a different failure related to a potential platform key name issue

user> (libpython-clj.python.interpreter/python-library-regex (libpython-clj.python.interpreter/python-system-info "/usr/local/bin/python3"))
Execution error (IllegalArgumentException) at libpython-clj.python.interpreter/python-library-regex (interpreter.clj:91).
No matching clause: :darwin
cnuernber commented 3 years ago

Does your PR completely address this issue for you?

vxe commented 3 years ago

yeah my issue seems to be resolved, I can now load require-python without any exceptions

cnuernber commented 3 years ago

OK, great closing :-).

vxe commented 3 years ago

@cnuernber is a new version with the changes going to be pushed to be pushed soon? I'm using a local jar for testing but would more convenient to pull from clojars. thanks

cnuernber commented 3 years ago

For sure.

cnuernber commented 3 years ago

2.00-alpha-6 is up.