import system library from jupyter

35 views
Skip to first unread message

Doug Friedman

unread,
Apr 24, 2019, 12:38:49 AM4/24/19
to Swift for TensorFlow
Hi-

Is there currently a way to import a system library in swift-jupyter?  I'm trying to accomplish something as simple as the example from the swift docs.

I've tried both approaches described here but get an "unable to import" error.  For reference, I pushed up a repro example with a system lib only package, a swift package that can successfully import it, and a jupyter notebook that fails.  Hopefully I'm not missing something super obvious.

I'm running the docker container on an OSX host if that makes a difference.

Doug

Marc Rasi

unread,
Apr 24, 2019, 2:57:19 AM4/24/19
to Doug Friedman, Swift for TensorFlow
I think it's swift-jupyter's fault for handling modulemap files in an unprincipled way that seemed to work most of the time.

Until we find a more principled way to handle modulemap files that actually works in all cases, here's a workaround that works for me:
  1. In the directory containing the notebook, "mkdir -p swift-install/modules/modulemap-clibgit", "cp Clibgit/module.modulemap swift-install/modules/modulemap-clibgit/"
  2. Put "%install-location $cwd/swift-install" at the top of your installation cell in the notebook.

--
You received this message because you are subscribed to the Google Groups "Swift for TensorFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swift+un...@tensorflow.org.

Doug Friedman

unread,
Apr 25, 2019, 8:25:56 AM4/25/19
to Marc Rasi, Swift for TensorFlow
I think my original example was even a bit over complicated.  I'd just like to be able to create /notebooks/mymodule/module.modulemap and import it in my notebook.  Your workaround works for now, thanks for the help.

For the future, have you thought of any of the following:

- adding $cwd/ to the search path for .modulemap files? Not sure if that counts as principled though :D
- is there a way to pass -I$cwd (or $cwd/modules etc) to the swift repl?  Ultimately this is all I'm looking to do.
- Updating %include to support including a module, or even any directory in the sources
- Allowing the user to directly update/override the Package.swift template that is used behind the scenes?  This way the user would not have to learn an extra abstraction that manipulates the package manifest.  I could see myself wanting to create a /notebook/Sources folder and wanting to use targets[ .systemLibrary(name: "mymodule") ].  Perhaps that is too fancy though.
Reply all
Reply to author
Forward
0 new messages