-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
install kernelspecs to datarootdir #61
Conversation
In many cases, this gives the wrong value:
In all the above cases, |
On OS X, the value is
why is that "wrong"? Isn't |
@jdemeyer nothing other than the system should ever write a file in
If you can provide an example where Python provides a reasonable value, that would be great. But I looked for a while (including sys.prefix, etc.) and could not find one that gives a sensible value in even the most common cases. The issue is that there are many Python installations (e.g. a system Python on OS X or Linux, or homebrew Python) where Python's own installation path should not be the installation path for user-installed things, and there doesn't seem to be a standard way of implementing this. Many of these in fact patch Python itself to change the installation process, to ensure things don't go in these locations. |
We're talking about system-installed things here, not user-installed things. Maybe that's the main point of the confusion? |
The main motivation for this pull request was Sage. Within Sage, |
@jdemeyer system-installed is distinguished from system-wide install by user. That is, |
OK, I understand the problem. There are really 3 cases:
There is a problem distinguishing in software between the first two cases. Suppose I am a distro developer and I want to install some Jupyter kernel files, then what should I do? Right now, the only solution seems patching the Jupyter sources or some manual copying. I don't have a simple solution, but it's clear that there is a problem to be solved here. |
You can specify |
The whole point of this pull request is that |
@jdemeyer I'm not sure what you mean by ignoring it. While the default install path is /usr/local, it does add |
So, are you saying that it's wrong for |
@jdemeyer if a system install should go in a different path, it can specify
Or more generally:
Only if you want to change the default behavior when users install things after the fact would modifying the code make sense. |
Can you find documentation for whether third-parties should be considering Python's datarootdir as an install path? Because all I find are direct references to |
I agree with replacing |
See also jupyter/jupyter_client#75 |
I didn't understand your comment about I guess what I'm missing is information for kernel authors on how they should implement the installation of the kernel spec file. Since this is Python, there should be an easy way to do this using distutils. Something like this in
So I see two possibilities:
|
If you go with data_files = [
('share/jupyter/kernels/mykernel', ['/path/to/src/kernel.json'])
] and there's nothing to import from Jupyter. Alternately, you can install with Jupyter APIs, and there are three available choices:
prefix=sys.prefix makes sense if you want the kernel to only be available when the notebook server is an env of various sorts (conda, virtualenv, manual install), but it's frequently wrong for non-env cases, especially the case of the kernel being in an env that's different from the notebook server. |
According to distutils documentation, this might install stuff in In any case, I would prefer to get the path from Jupyter such that it's certainly correct.
Sure, there are many choices. But we don't need many choices, we need one good choice. I think it's not good if every kernel uses a different system to install the kernel specs. As long as this isn't resolved, I am just going to use |
IMHO /usr/local is never the right value, its cargo cult from a time before we had package management. Users should never do system-wide installations. Rely on your distributor (who will have to patch out the /local/ for packaging), or do a private install (~/.local). If you are maintaining a multiuser system then you should be packaging & installing as well, that is just standard devops best practices. On a related note, the R ipython kernel also ignores sys.prefix and installs the to /usr/local. So you can't install it into a prefixed Python / virtualenv, yay. |
The |
We have been discussing some of this stuff at Sage Days 70 and there is a general agreement that Regarding
Creating and installing wheels also works this way. Annoyingly, a plain installation does not work with A more robust version of
|
Here is a write-up of the Sage Days 70 discussion: Jupyter KernelsFollow-up on #61
Documentation
|
That's interesting. I guess we will just special-case all of the instances where |
But /usr/local is the wrong choice on those platforms for Anaconda, for example. I don't think you can make a platform-wide decision. |
@jasongrout sorry, I was referring to the system-wide cases (System Python on OS X and debian, Python.org, homebrew), not things like conda, envs, or pythonbrew. It's also certainly not objectively true that putting kernelspecs in the env is strictly preferable to leaving them system-wide. Here's what I think makes the most sense: rather than using sys.prefix directly, we should ask where A bonus to asking where data_files will go means we should get The rest - making a complete working example, simple API for adding to setup.py makes perfect sense to me. These are the challenges I see of installing to Python's prefix:
|
Given that this is
Are you sure? I'm not saying it's impossible to make them differ, I'm just wondering if it ever happens it practice. Note that you also need to make sure that Jupyter actually looks in that directory for kernel specs. |
Two more arguments for using
|
Why should kernelspecs include the full path to
Are you sure we want to do this? Isn't the whole purpose of envs that they are supposed to be separate installs? |
Actually, we don't need to ask distutils, we just need to use
(by definition, this will install the kernel spec in the directory where distutils installs data_files) Problem: this doesn't work with setuptools :-( so we need some special-case for this. |
Yes. Debian and Homebrew are both examples.
For the same reason that Python does it in scripts: a kernelspec should, generally, correspond to a particular Python. Changing your PATH shouldn't change the interpreter associated with the kernelspec. If all kernelspecs use only
This is not true in general, because we need to ask at runtime to build the search path. But you are right that you won't need to ask in setup.py. There is also the fact that most kernelspecs are not Python packages, so setup.py install is not relevant to most kernelspec installation.
We've always included the env prefix in the search path, so installing with data_files already works; it's just not the default location. You've always been able to install in the env. The only question here is whether that should be the default behavior or not.
Yes, we certainly do want this, and it's why we have the current default behavior. It's quite sensible to run a webserver in one env, and use kernelspecs to run code in another. The primary goal of the kernelspec system is that you run one notebook webserver, and use kernelspecs to specify different execution environments, be they different languages, configurations, or environments. Switching the env for your kernel should not require installing and running multiple copies of the notebook server. |
Right, I always forget that. In any case, asking distutils isn't particularly hard, |
I opened a setuptools issue: https://bitbucket.org/pypa/setuptools/issues/460/setuptools-doesnt-install-data_files |
Right, but that's already advanced usage. I think the default should aim for the most basic usage, which is just one env (be it system or not) and one Python executable. |
I started putting together a sketch of the proposal; I'll post something when it's together. I'm really on the fence, and keep leaning one direction or the other. It's certainly worth prototyping, though. And multiple envs is advanced usage, as you said. Re: setuptools, under no circumstances should a non-pip setuptools install ever happen, so I'm less concerned about that one. This is just one more reason why it's broken. |
I'm looking forward to it :-)
|
Whatever you come up with, it should also support a |
@jdemeyer Not to restart the "rant" from an earlier message, upstream CPython does publish an authoritative guide to packaging. Link to repo | Link to guide The pypa repos should be referred to for packaging in Python. Just an FYI for future reference. |
Are you sure this is "upstream CPython" and not some random people publishing something on the internet? |
It's somewhere in between, as I understand it. The 'Python Packaging Authority' is not upstream CPython, but it has some amount of official blessing from core developers (and doubtless some overlap). PyPA maintains pip and setuptools, which are the primary packaging and installation tools. |
@jdemeyer Yes. CPython core devs, Donald Stufft and Nick Coghlan, are the leads of PyPA. |
We can continue discussion in the proposal in #69. |
There is currently no documented standard way of installing Jupyter kernels, leading to various different kernels doing it in a different way. The
echo_kernel
should be extended to a complete Python package, includingsetup.py
.The recommended way to install Jupyter kernel specs should be using distutils'
data_files
:We need to figure out how to emulate this behaviour for non-Python kernels.