-
Notifications
You must be signed in to change notification settings - Fork 52
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
Support for --prefix #98
Comments
I think this should be fixed in the Python upstream, not this project, so I recommend you open a bug there asking for a way for vendors to specify dynamic Alternatively, this can be easily implemented in a Nixpkgs-specific install script. |
Would we be ok with addding an option for scheme names in the command line which would get passed to |
Can someone explain how the two use cases are different, ideally with some illustrative paths as an example?
This is not the interface we'd take. Regardless, see #92 for the discussions on such a CLI. At this point, you can (and, likely, should) write a small Python script that uses the API directly to do what you need. If there's more than one user who wants this functionality, we can explore adding that into this package. :) |
If you have, say, a purelib path
If you have a hypothetical
In Nix, each package resides under a unique prefix, so that the Python a Python package is installed for will have a different prefix (aka
... and Nix will need to shear it off somehow and prefix the package's actual prefix. This is made difficult by the fact that the prefix is an automatically-generated hash. What Nix have been doing is to install packages with |
Essentially, what is happening here is that unlike DESTDIR (which is used for installing into .deb or .rpm archives), Nix is actually installing to a different install scheme for every module. The install scheme includes e.g. the hash of the package name/version/contents. What this means is you need a couple thousand different sysconfig schemes, all dynamically calculated. I wonder if, instead, Nix could patch sysconfig with a |
I'll also have a go at explaining destdir & prefix - I'm not disputing anything in @layday's explanation, but I think a bit more 'why' might be useful. destdir (aka prefix is more like a virtual environment - a relatively lightweight directory containing subdirectories like
I dare say Nix could, but I don't know why they would want to. Even without the option in the installer CLI, it would seem simpler for them to either stick with pip or write their own wrapper calling the installer Python API, so they can specify prefix directly rather than persuading sysconfig to give the answer they know they want. Patching and environment variables seems like a rather convoluted way to do a simple thing. (I'm not involved in the Nix project, though, so maybe they'll see it differently) |
There's not really any reason to go into all that effort if they are adding a new scheme. They can simply replace all base/platbase placeholders with |
This would be my proposal. Currently,
I'd recommend avoiding adding such an option until we get a path forward with the |
Something like that was what I was thinking as well (see also https://bugs.python.org/issue43976#msg411657).
I imagine this to typically work fine indeed. As suggested, I think it will be easier in the end for us to write our own script using the installer API in the end. Of course, such script will also be needed by some other distro's such as Guix and Spack if they were to migrate from pip to installer. Maybe something could improve in sysconfig, but it seems convoluted to me, and realistically speaking it won't happen for 3.12 anyway either. |
In MSYS2 we also install to a different prefix compared to the installed Python, so this would also be helpful to us. Our Python installation is relocatable, so our packages are too (just like wheels) |
Actually, I think this would be helpful outside of Nix too. Just imagine you're running Let's say I'm running a virtualenv at |
Though I suppose a hack like |
Or using Or if you must install installer itself in a venv (why? this is not something Gentoo itself should need, is it just a shower thought?) then being able to do |
But then it wouldn't find the installer inside the venv. |
Well I mean yes, but... That's why I suggested the correct solution would instead be But you still haven't explained why it's important to Gentoo that you can install the installer-tool into a venv and use it to install wheels outside of the venv. |
We're installing to a temporary venv to run tests in, then we're stripping the venv bits and transferring the result to the filesystem. |
In either case, this looks really trivial to do and I'm working on a PR where we can discuss this further. |
Implement a --prefix option that can be used to override platbase and base when expanding the paths from install scheme. This can be used to install paths to a layout using another prefix than the one used to run installer. Gentoo use case for this is running installer inside a venv to prepare installation images for the real system. The nixOS maintainers have also indicated interest in this feature. Fixes pypa#98
Implement a --prefix option that can be used to override platbase and base when expanding the paths from install scheme. This can be used to install paths to a layout using another prefix than the one used to run installer. Gentoo use case for this is running installer inside a venv to prepare installation images for the real system. The nixOS maintainers have also indicated interest in this feature. Fixes pypa#98
Implement a --prefix option that can be used to override platbase and base when expanding the paths from install scheme. This can be used to install paths to a layout using another prefix than the one used to run installer. Gentoo use case for this is running installer inside a venv to prepare installation images for the real system. The nixOS maintainers have also indicated interest in this feature. Fixes pypa#98
Implement a --prefix option that can be used to override platbase and base when expanding the paths from install scheme. This can be used to install paths to a layout using another prefix than the one used to run installer. Gentoo use case for this is running installer inside a venv to prepare installation images for the real system. The nixOS maintainers have also indicated interest in this feature. Fixes pypa#98
I'd prefer to keep discussion of "should we do this" in the issue, keeping the PR purely for implementation-related concerns. And, uhm, "this is trivial to do" isn't sufficient rationale to do something like this (not that that's the only rationale provided here). |
FWIW, this is how I'm leaning as well.
A better way of phrasing this: So, if installer is able to install into a different Python interpreter, that would satisfy your usecase, correct?
I'll take this as a good reminder to change the name to Edit: Done in fad2894 |
Could you elaborate a bit on why this would be helpful? I'm still very much at a point of trying to gather a better understanding of what workflows redistributors have, to figure out what are good/reasonable ways to support them in this package. |
Having had to deal with a bunch of issues related to this, I'd also very much prefer that in this package. |
I'm sorry but I'm not sure if I understand what you're saying. If you mean that when started from inside a venv, installer would have paths as if it had been started via |
No, it would have the paths of the venv (eg. |
Implement a --prefix option that can be used to override platbase and base when expanding the paths from install scheme. This can be used to install paths to a layout using another prefix than the one used to run installer. Gentoo use case for this is running installer inside a venv to prepare installation images for the real system. The nixOS maintainers have also indicated interest in this feature. Fixes pypa#98
Implement a --prefix option that can be used to override platbase and base when expanding the paths from install scheme. This can be used to install paths to a layout using another prefix than the one used to run installer. Gentoo use case for this is running installer inside a venv to prepare installation images for the real system. The nixOS maintainers have also indicated interest in this feature. Fixes pypa#98
@mgorny could you remove the reference to the issue from the commit message? It’s unnecessarily causing spam in this discussion and it’s generally not a good idea to mention an issue when you have a corresponding PR open. |
Sorry. Done that now. |
Spack developer here. Just want to +1 this idea. Like Nix and Guix, Spack installs every single software package to a separate installation prefix. This allows us to, for example, install 3 different versions of numpy with 4 different compilers and 5 different BLAS/LAPACK providers. We then either add these directories to |
Add support for
--prefix
. Note this is not the same as--destdir
which was discussed in https://github.com/pradyunsg/installer/issues/58 and has been added.Discussion on
--prefix
in https://github.com/pradyunsg/installer/pull/94#issuecomment-1013876999 and https://github.com/pradyunsg/installer/pull/66. I don't see anyway around needing--prefix
in Nixpkgs.A
sysconfig
scheme is static and doesn't provide the flexibility we need, that is, being able to install every package in its own prefix.Alternatively, I could imagine reading a scheme from say a json or toml file when installing.
Something that could work for us:
The text was updated successfully, but these errors were encountered: