Closed rgbkrk closed 8 years ago
FML
Note: This is due to my system python and Jupyter's python being different.
We're going to have a problem here. sys.prefix
as reported by shelling out to python
is based on your current python
version. For jupyter
, it's based on which python installed jupyter_core
.
Cool, tested and partially specced against jupyter console
.
On 21/01/16 01:14, Kyle Kelley wrote:
We're going to have a problem here. |sys.prefix| as reported by shelling out to |python| is based on your current |python| version. For |jupyter|, it's based on which python installed |jupyter_core|.
What I had in mind is that, in the absence of jupyter_core
and python
, sys-prefix-promise
would return a safe default, so that it would be possible to install a kernel on a location, that later on, Hydrogen could find (even if jupyter_core
and python
are not present).
We can always install to the non sys prefixed directories and have it picked up. The way this module works right now is that you have to explicitly ask to include the sys prefixed path.
That sounds good to me.
Finally came back to this. In v1.0.0
, you get a promise back when setting withSysPrefix
to true
in opts.
> jp.dataDirs({ withSysPrefix: true })
Promise { <pending> }
> jp.dataDirs({ withSysPrefix: true }).then(console.log)
Promise { <pending> }
> [ '/Users/rgbkrk/Library/Jupyter',
'/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/share/jupyter',
'/usr/share/jupyter',
'/usr/local/share/jupyter' ]
If someone doesn't want to rely on sys prefix, they get an immediate return:
> jp.dataDirs()
[ '/Users/rgbkrk/Library/Jupyter',
'/usr/share/jupyter',
'/usr/local/share/jupyter' ]
If what you want is to call python only once, how about use execSync() and store the result in a private variable?
We can do that, assuming that sys.prefix
doesn't change over the lifetime of a run. In the case of composition, since a user can change their default installed Python this value can change (e.g. make python3
the default python
when python2
was python
before). We would not be able to detect a change based on environment variables once loaded though.
I was actually thinking about making another opt for which python is used to run sys.prefix
, since, as the image above shows they can be wildly different.
Here's sys-prefix-promise
by the way.
On 22/01/16 17:56, Kyle Kelley wrote:
We can do that, assuming that |sys.prefix| doesn't change over the lifetime of a run.
In this case, I would call execSync() each time, and let the user cache the value only when they think it necessary.
I'd prefer that the user cache it in those cases. Also happy to expose a Sync()
method if that works better for IJavascript's codebase. I tend to prefer relying on Promises for single valued things that can block.
Closing down on #5 and #4.
Will be a work in progress as I first bring in the original implementation that was a direct Python -> JS port, followed by a cleaner API like in ipython-paths.