-
Notifications
You must be signed in to change notification settings - Fork 414
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
Option to install package globally for multi-user access #754
Comments
There are a couple environment variables that I think can do what you’re asking for. See PIPX_HOME and PIPX_BIN_DIR. |
ahhhh, ok. Apologies, i completely missed that in the documentation! so if i understood correctly, a workaround to install globally accessible python apps with pipx on linux would be:
is that right? in that case, would pipx create /opt/pipx, or does it need to exist first? |
I just tested the above command, and it works exactly as intended! didn't need to pre-create the directory or futz with directory permissions or anything :) Is there any interest in me creating a PR to add this to the documentation? |
Yes, that would be awesome 🙂 |
It appears that this is already mentioned in the documentation: Is there any interest in exposing this in pipx for easier use or should users just be expected to create a shell alias if they want to use this regularly? |
Something I observed while trying out this solution today - it is impossible to run pretty much all commands (e.g. |
Presumably, it would be safer to take additional pre-cautions such as only using the elevated permissions for installing the package, while building it with a normal user account. I imagine that this, however, might be out of scope for pipx, even if it would be incredibly cool if it could do that 😄 |
We can probably detect the log directory’s permission, and log to somewhere the user is likely to own (e.g. use |
What I hear is PRs welcome? :-) I might tinker with it later today. |
I think it would be nice to have a switch for global install. For example when using |
I definitely would like to have a
Example usage:
All-in-all, that's a fair amount of work, but not a ton of work to make the change, but I think that all of that work would be necessary to fully implement this change. Alternately, |
This would be very useful to install binaries globally on a server for consumption by all users. The workaround with |
I don't understand why this discussion assumes we need a PS: To be clear, I guess I should point out that running code can trivially determine that is is running with root/sudo privilege so I am suggesting to exploit that. |
Though that sounds good in theory, I worry that it violates the principle of least surprise. Most package managers do not behave differently when run like that, and even pip, which operates globally by default, has an explicit ‘—user’ flag for when the default mode isn’t wanted I would prefer to see an explicit ‘—global’ flag than implicit behaviour |
@alextremblay I was actually surprised it didn't work like this! I tried it and found it installed to |
I created Just type |
Personally I also feel making |
Frankly, this statement horrifies me. That would break the honored orthogonal behavior of |
To clarify:
|
@uranusjr after writing those rules out don't they seem convoluted, and certainly redundant? Compared to simply: # Install for my user personally:
$ pipx install cowsay
# Or, install for all users globally:
$ sudo pipx install cowsay
|
I disagree with Relying on
Taking a page off of NPM (analogously pipx was inspired by NPX), only one addition to @eode's suggestion:
these rules flexible using, for example, |
|
It actually failed for me:
On the second run it worked, so some directories were created and some others weren't. |
A bit late to the party since this seems to be natively implemented soon, but here is my quick function to add a
Hope it works OK for someone else as well, not duly tested. |
) (#1281) * The bare minimum implementation of --global * Added --global switch that sets the relevant paths to point to locations that should be accessable to all users. * Added --global specific tests * The implementation is crude. * Fixing failing windows tests ...by not having --global in windows The behavior intended by --global doesn't have a precedent in windows when using pip (as in running pip with sudo). Leaving windows support to another time after some discussion. * Cleaned up the changes made to implement --global * Moved path management to `pipx.paths` * Path "constants" available via a context object `pipx.paths.ctx` * Fixed some stuff missed in the merge * Fix rebase issues * Add missing mkdir calls, fix test_upgrade * Add feature note to changelog.d * Use decorator for test skips on windows * Global tests update, PR cleanup * Add note about --global switch in installation docs * Revert unnecessary formatter changes * Satisfy mypy import * Add note about --global argument to how-pipx-works * --global documentation improvements * Update home_exists in make_global * Run test_fetch_missing_python with setting local * Add make_local at the end of all global tests * Fix ensurepath * make_local on fixture cleanup * Revert "Fix ensurepath" This reverts commit fe24c8f. * Remove explicit make_local from tests * Inform user about sudo pipx ensurepath --global * Make test_cli test less tolerant * Improve grammar --------- Co-authored-by: haxwithaxe <spam@haxwithaxe.net>
This feature was added in #1281 and released as part of |
Awesome, thanks!
…On Sun, Apr 21, 2024, 7:14 AM chrysle ***@***.***> wrote:
Closed #754 <#754> as completed.
—
Reply to this email directly, view it on GitHub
<#754 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAS4PT5K2KFK6MY6YYSTGN3Y6ONSXAVCNFSM5GVICI7KU5DIOJSWCZC7NNSXTWQAEJEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW4OZRGI2TKMBWGM2DOOJS>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi All, not sure if this qualifies as a feature request, or if it's already possible and just needs to be documented?
pipx by default installs its virtualenvs in a folder inside the user's home directory (ie
~/.local/pipx/venvs/
), and installs the entrypoint binaries for those packages/virtualenvs in the user's personal path (ie~/.local/bin
).Is it possible to install packages with pipx such that they are globally executable by all users on a system (ie install entrypoint binaries in
/usr/local/bin
, install virtualenvs somewhere that all users can access them?How would this feature be useful?
Having this ability would make pipx a prime candidate for people looking to deploy python software in multi-user environments. Without this ability, pipx is not usable at all in such situations
Describe the solution you'd like
Ideally, some kind of
--shared
or--global
flag would be the most straightforward solution, but even something like an optional environment variable would be niceEx:
sudo pipx install --global cowsay
Describe alternatives you've considered
There are currently no alternatives / workarounds that I'm aware of. I cannot find anything about this in the documentation, the github issues, or on the web
The text was updated successfully, but these errors were encountered: