Skip to content
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

Add support for --reinstall and --reinstall-package in uv tool install #4504

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jun 25, 2024

Adds support for --reinstall and --reinstall-package to uv tool install. These are already available via the installer settings, we just respect them now.

--reinstall implies a recreation of the environment and reinstallation of the entry points.
--reinstall-package will only update a subset of the environment. If the target package is the one with the entry points, we'll reinstall the entry points. Otherwise, the entry points are not changed.

@zanieb zanieb added the preview Experimental behavior label Jun 25, 2024
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch from 214b411 to b695e26 Compare June 25, 2024 01:25
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch from b695e26 to 8620ab2 Compare June 25, 2024 01:28
@zanieb zanieb force-pushed the zb/tool-install-force branch 2 times, most recently from e8685a2 to 05bc596 Compare June 25, 2024 13:24
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch from 8620ab2 to 51f4a7d Compare June 25, 2024 13:32
@zanieb zanieb mentioned this pull request Jun 25, 2024
zanieb added a commit that referenced this pull request Jun 26, 2024
This is the minimal "working" implementation. In summary, we:

- Resolve the requested requirements
- Create an environment at `$UV_STATE_DIR/tools/$name`
- Inspect the `dist-info` for the main requirement to determine its
entry points scripts
- Link the entry points from a user-executable directory
(`$XDG_BIN_HOME`) to the environment bin
- Create an entry at `$UV_STATE_DIR/tools/tools.toml` tracking the
user's request

The idea with `tools.toml` is that it allows us to perform upgrades and
syncs, retaining the original user request (similar to declarations in a
`pyproject.toml`). I imagine using a similar schema in the
`pyproject.toml` in the future if/when we add project-levle tools. I'm
also considering exposing `tools.toml` in the standard uv configuration
directory instead of the state directory, but it seems nice to tuck it
away for now while we iterate on it. Installing a tool won't perform a
sync of other tool environments, we'll probably have an explicit `uv
tool sync` command for that?

I've split out todos into follow-up pull requests:

- #4509 (failing on Windows)
- #4501 
- #4504 

Closes #4485
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch from 51f4a7d to b360b39 Compare June 26, 2024 16:09
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch from b360b39 to 73f519c Compare June 26, 2024 16:25
@zanieb zanieb force-pushed the zb/tool-install-force branch 3 times, most recently from 9ec3452 to 46e4225 Compare June 26, 2024 16:51
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch from 73f519c to 41f1dd8 Compare June 26, 2024 16:56
@zanieb zanieb marked this pull request as ready for review June 26, 2024 16:58
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch 2 times, most recently from 4d2654d to 1736eb3 Compare June 26, 2024 19:32
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch 2 times, most recently from bbc9c38 to 19273fc Compare June 26, 2024 19:53
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch from 19273fc to cb16a68 Compare June 26, 2024 20:02
zanieb added a commit that referenced this pull request Jun 26, 2024
Adds detection of existing entry points, avoiding clobbering entry
points that were installed by another tool. If we see any existing entry
point collisions, we'll stop instead of overwriting them. The `--force`
flag can be used to opt-in to overwriting the files; we can't use `-f`
because it's taken by `--find-links` which is silly. The `--force` flag
also implies replacing a tool previously installed by uv (the
environment is rebuilt).

Similarly, #4504 adds support for reinstalls that _will not_ clobber
entry points managed by other tools.
Base automatically changed from zb/tool-install-force to main June 26, 2024 20:03
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch from cb16a68 to ca5a754 Compare June 26, 2024 20:03
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch 2 times, most recently from 18d6ece to 7b5ee7f Compare June 26, 2024 20:12
@zanieb zanieb force-pushed the zb/tool-install-reinstall branch from 7b5ee7f to f7904ce Compare June 26, 2024 20:15
@zanieb zanieb enabled auto-merge (squash) June 26, 2024 20:15
@zanieb zanieb merged commit b44c47f into main Jun 26, 2024
47 checks passed
@zanieb zanieb deleted the zb/tool-install-reinstall branch June 26, 2024 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants