Can't import SwiftVips

(Marc Rasi (S4TF Team)) #21

SPM does use pkg-config to determine these extra install flags (https://github.com/apple/swift-package-manager/blob/d58d857c5049a6e0e27896fe9a21f00e42b16527/Sources/SPMUtility/PkgConfig.swift).

From my first glance, I don’t see any easy/obvious ways to extract the extra args from SPM. I’m sure it’s possible in the longer term, maybe by adding some features to SPM. But for a quick fix, I propose that we just run pkg-config ourselves.

There’s another obstacle that I do not know how to add extra include search paths after the kernel starts running. We can work around this by making symlinks from /tmp/xyzxyzxyz/swift-install/modules to all the necessary header files.

I propose combining all these workarounds into a swift-jupyter feature that you use like this:

%install-location ...
%install ...
%install-extra-include-command pkg-config --cflags-only-I vips

This feature will run the specified commands, extract the -I flags from them, and create links from the kernel’s “install location” to all the headers.

This is kinda nasty, but it should work for now.

PR incoming soon…

1 Like

(Marc Rasi (S4TF Team)) #22

Okay, here’s an initial PR that works for me: https://github.com/google/swift-jupyter/pull/60

Check out that branch and add %install-extra-include-command pkg-config --cflags vips to your install cell.

I’m going to test it out on a few more notebooks and systems and add some docs in the readme. Then I will merge it.

By the way, I had to do some extra things not included in the install instructions to get SwiftVips working:

  • sudo ldconfig
  • conda install harfbuzz pango. The versions of these libs that were on my Ubuntu system had missing symbols. I’m guessing that conda installs newer versions that have more symbols, though I haven’t looked closely and compared versions and understood what’s actually going on.
1 Like

(Marc Rasi (S4TF Team)) #23

I have merged it. I have also uploaded a commit to fastai_docs that makes dev_swift/c_interop_examples.ipynb use this new feature.

It Works For Me™ but I’m eager to hear if it works for anyone else.

Also, the conda install harfbuzz pango wasn’t necessary when I tried to redo everything on a clean machine. Maybe my old one was in a weird state.

3 Likes

(Chris Lattner) #24

huzzah, thank you marc!!

1 Like

(Jeremy Howard (Admin)) unpinned #25
0 Likes

(Thom M) #26

FYI, I think @marcrasi’s change has been splatted in all the merge madness. I had to add the extra %install-extra-include-command pkg-config --cflags vips line to the 1st cell, and also include an import TensorFlow in the 2nd cell, to get the nb to run.

0 Likes

(Jeremy Howard (Admin)) #27

Thanks @ThomM added back now.

0 Likes

#28

I had some issues making vips.

Every time running autogen.sh it got it’s panties in a twist and would not generate the deleted files on a remake. The files ltmain.sh and Makefile.in were missing ( not regenerated) by the libtoolize tool.

So my fix was once I had generated the configure file which autogen.sh thankfully did was to run individually from the command prompt :-

libtoolize --copy --force --automake
automake --add-missing --copy
./configure
make
sudo make install

The intuition I got for this was from a 2015 issue #305

baffling

The only other thing I had to make was a soft link from /usr/local/bin/vips to /usr/bin/vips perhaps because of some other silly stuff I had done.

Now the note books c_interop_examples and opencv_integration_example work fine.

0 Likes

(Brian Smith) #29

I got passed that error following these steps:

Added usrlocal.conf file with following line into /etc/ld.so.conf.d

/usr/local/lib

Then ran ldconfig -v as root upon save

Found here - https://github.com/lovell/sharp/issues/327

0 Likes