[IPython-dev] Installing kernels and libs under a virtual env

Doug Blank doug.blank at gmail.com
Tue Dec 30 17:54:11 EST 2014


On Tue, Dec 30, 2014 at 4:42 PM, Matthias Bussonnier <
bussonniermatthias at gmail.com> wrote:

> From what I can tell it is perfectly normal to install a vent kernel to be
> use globally, and we try not to have any venv specific code for the Jupyter
> part.
> Installing was the most problematic part in last discussion, and there is
> no "right" answer so the only logical one is to try to do as least as
> possible.
>

Perhaps the issue isn't clear. Currently (as I understand it), if one is
trying to install a Python file *AND* kernelspecs in a virtual env using
"python setup.py install" then:

1) if you use the "--user" flag, then it installs the kernel into the
user's ~/.ipython/kernels (ok), and installs the Python code into ~/.local/
(not ok, because the virtual environment doesn't look there... it has its
own local folder). [This sounds like a bug in either venv or distutils, or
just a disagreement between them.]

2) if you don't use the --user flag, then you need to use root/sudo,
because the kernel installs into the system directory (ok), but installing
the Python code fails because it can't find IPython (because it is in the
virtual env).

It appears that others get around this problem by using the --prefix
flag. If install_kernel_spec also accepted an optional prefix argument,
then it could work seamlessly with distutils.

There are other possibilities (if the above is correct):

a) separate the kernelspec and Python code installs... one to work with
--prefix (for the Python code), and one to work with --user (for the
kernelspec).

b) make a new flag in setup.py to handle these two cases.

c) don't use --user, check permissions to install kernel into system
directory (regardless of self.user), and fallback to user = True. This
works because the code will go into the virtual env, and kernel will go
into wherever it can be written.

Perhaps this will be more clear if someone writes a setup.py for a
kernelspec and tries to test it under Travis.

-Doug


>
> --
> M
>
> Envoyé de mon iPhone
>
> Le 30 déc. 2014 à 22:31, Doug Blank <doug.blank at gmail.com> a écrit :
>
> On Tue, Dec 30, 2014 at 3:51 PM, Doug Blank <doug.blank at gmail.com> wrote:
>
>> On Tue, Dec 30, 2014 at 2:28 PM, Fernando Perez <fperez.net at gmail.com>
>> wrote:
>>
>>> Hi Doug,
>>>
>>> On Tue, Dec 30, 2014 at 9:57 AM, Doug Blank <doug.blank at gmail.com>
>>> wrote:
>>>
>>>> I think that if "python setup.py install --user" under a venv went to
>>>> the virtual env's local, then everything would be fine. But maybe I'm doing
>>>> something wrong (need to use pip?).
>>>
>>>
>>> The issue is that the list of targets is hardcoded here:
>>>
>>>
>>> https://github.com/ipython/ipython/blob/master/IPython/kernel/kernelspec.py#L21
>>>
>>> that code isn't currently aware in any way of virtualenvs.
>>>
>>> I'm fuzzy on the details of how we ended up deciding we'd interact with
>>> venvs, other than saying that we'll try to bake as little knowledge of
>>> 'environment managers' (venv, conda, etc) directly into our kernel
>>> installation tools directly.  That discussion has lots of subtly
>>> interacting moving parts, and I'm afraid to say something misleading right
>>> now.
>>>
>>> Min and Thomas were deep in those details, and I'd wait for further
>>> feedback from them (or anyone else who remembers well).  But in the
>>> meantime, you may want to play with that code in a local copy: you may find
>>> a minimally intrusive improvement for venv support that could be a good
>>> solution for a PR.
>>>
>>
>> Actually, the kernel is installed fine, and is found in the user's kernel
>> area. It is the installed Python code with "--user" that causes the issue.
>> Maybe this is just a venv/setup interaction bug.
>>
>
> I see that distutils can use either a --user flag or a --prefix flag, but
> not both at the same time. Adding a "prefix" kwarg option could also work
> for install_kernel_spec, and would solve the problem that I am currently
> running into with venv with --user.
>
> Min and/or Thomas: does that sound like a viable option?
>
> -Doug
>
>
>> -Doug
>>
>>
>>>
>>> Cheers,
>>>
>>> f
>>>
>>>
>>>
>>> --
>>> Fernando Perez (@fperez_org; http://fperez.org)
>>> fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
>>> fernando.perez-at-berkeley: contact me here for any direct mail
>>>
>>> _______________________________________________
>>> IPython-dev mailing list
>>> IPython-dev at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>
>>>
>>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20141230/f732a5b5/attachment.html>


More information about the IPython-dev mailing list