digikar99 / py4cl2-cffi

CFFI based alternative to py4cl2
43 stars 10 forks source link

wrong libraries being loaded #5

Closed atgreen closed 1 year ago

atgreen commented 1 year ago

I use Fedora,...

[green@fedora tmp]$ python3-config --embed --ldflags -L/usr/lib64 -lpython3.11 -ldl -lm

Your code is expecting different output. libpython is being set to dl

digikar99 commented 1 year ago
  1. Could you check if libpython.so is present in /usr/lib64/ itself?
  2. Could you confirm if this happens for other instances of python on fedora, say, a python installed using anaconda, or downloaded from the main site?
atgreen commented 1 year ago
[green@fedora` py]$ ls -l /usr/lib64/libpython*.so*
lrwxrwxrwx. 1 root root      19 May 24 20:00 /usr/lib64/libpython2.7.so -> libpython2.7.so.1.0
-rwxr-xr-x. 1 root root 1904776 May 24 20:00 /usr/lib64/libpython2.7.so.1.0
lrwxrwxrwx. 1 root root      20 Jun  6 20:00 /usr/lib64/libpython3.11.so -> libpython3.11.so.1.0
-rwxr-xr-x. 1 root root 5387176 Jun  6 20:00 /usr/lib64/libpython3.11.so.1.0
-rwxr-xr-x. 1 root root   15224 Jun  6 20:00 /usr/lib64/libpython3.so

With anaconda python, I get:

* (py4cl2-cffi:raw-pyexec "def foo(): return str(1)")

debugger invoked on a CFFI:LOAD-FOREIGN-LIBRARY-ERROR in thread
#<THREAD tid=363868 "main thread" RUNNING {10044981B3}>:
  Unable to load foreign library (LIBPYTHON3.11.SO-180).
  Error opening shared object "/home/green/anaconda3/lib/python3.11/config-3.11-x86_64-linux-gnu/libpython3.11.so":
  /home/green/anaconda3/lib/python3.11/config-3.11-x86_64-linux-gnu/libpython3.11.so: cannot open shared object file: No such file or directory.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY    ] Try loading the foreign library again.
  1: [USE-VALUE] Use another library instead.
  2: [ABORT    ] Exit debugger, returning to top level.

(CFFI::FL-ERROR "Unable to load foreign library (~A).~%  ~A" #:LIBPYTHON3.11.SO-180 #<(SIMPLE-BASE-STRING 258) Error opening shared object "/home/green/anaconda3/lib/python3.11/config-3.11-x86_64-linux-gnu/libpython3.11.so":
  /home/green/anaconda3/lib/python3.11/config-3.11-x86_64-linux-gnu/libpython3.11.so: ... {100223BA7F}>)
   source: (ERROR 'LOAD-FOREIGN-LIBRARY-ERROR :FORMAT-CONTROL CONTROL
                  :FORMAT-ARGUMENTS ARGUMENTS)
0] 
digikar99 commented 1 year ago

I have set up a Fedora VM now. With https://github.com/digikar99/py4cl2-cffi/pull/6 merged into the latest master, I am able to get py4cl2-cffi loaded on Fedora 38.

Let me check with anaconda and get back.

digikar99 commented 1 year ago

The fix works with miniconda on fedora too.

So, with a fresh install, and after merging the origin/config branch, I'm able to load and use py4cl2-cffi:

git clone https://github.com/digikar99/py4cl2-cffi.git
cd py4cl2-cffi
git merge origin/config

I do run into a SBCL-wide freezing behavior on fedora 38 though. But the freeze occurs with dnf provided sbcl, and not with the latest sbcl-2.3.7.

atgreen commented 1 year ago

That's great. When do you think you'll be able to merge #6?

digikar99 commented 1 year ago

If you'd prefer to have it merged immediately, I can do that. Later, someone with access to Mac OS / Darwin can check if any fix is required and issue a PR.

digikar99 commented 1 year ago

Okay, I've merged the PR. Let me know if there's an issue!

atgreen commented 1 year ago

It works! Thanks!