-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(pipx): ensure Python minor version symlink exists for postinstall hooks #7869
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
eac063b
fix(pipx): ensure Python minor version symlink exists for postinstall…
jdx fb9d6b0
[autofix.ci] apply automated fixes
autofix-ci[bot] f279cf2
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] f044462
fix: address review feedback for symlink format consistency
jdx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #!/usr/bin/env bash | ||
| require_cmd python3 | ||
|
|
||
| # Test that pipx postinstall hooks can invoke the installed tool when using uvx. | ||
| # This validates the fix for https://github.com/jdx/mise/discussions/7864 | ||
| # The bug was that uvx creates venv symlinks pointing to minor version paths | ||
| # (e.g., python/3.12/) but the symlink didn't exist yet when postinstall ran. | ||
|
|
||
| # Create a system pipx that always fails and push it to the front of PATH | ||
| cat >"$HOME/bin/pipx" <<'EOF' | ||
| #!/usr/bin/env bash | ||
| echo "CALL TO SYSTEM pipx! args: $*" >&2 | ||
| exit 1 | ||
| EOF | ||
| chmod +x "$HOME"/bin/pipx | ||
| export PATH="$HOME/bin:$PATH" | ||
|
|
||
| # Just to be sure... | ||
| assert_fail "pipx" | ||
|
|
||
| # Use precompiled python and uvx (the default) | ||
| export MISE_PYTHON_COMPILE=0 | ||
| export MISE_PIPX_UVX=1 | ||
|
|
||
| # Set up mise-managed Python with a pipx package that has a postinstall hook | ||
| # The hook invokes the installed tool, which requires the Python symlink to work | ||
| cat >.mise.toml <<EOF | ||
| [tools] | ||
| python = "3.12.3" | ||
| uv = "0.5.5" | ||
|
|
||
| [tools."pipx:mkdocs"] | ||
| version = "1.6.0" | ||
| postinstall = "mkdocs --version" | ||
| EOF | ||
|
|
||
| # Install the tools - this should succeed with the postinstall hook | ||
| mise install | ||
|
|
||
| # Verify mkdocs is installed and works | ||
| assert_contains "mise x -- mkdocs --version" "1.6.0" | ||
|
|
||
| # Verify the minor version symlink was created early (before runtime_symlinks::rebuild) | ||
| MINOR_VERSION_DIR="$MISE_DATA_DIR/installs/python/3.12" | ||
| if [[ -L $MINOR_VERSION_DIR ]]; then | ||
| ok "Minor version symlink 3.12 was created" | ||
| elif [[ -d $MINOR_VERSION_DIR ]]; then | ||
| ok "Minor version directory 3.12 exists" | ||
| else | ||
| fail "Minor version symlink/directory 3.12 does not exist" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern differs from the one in
path_with_minor_version()which usesr\"/python/(\\d+)\\.(\\d+)\\.\\d+/\". While functionally similar, the inconsistency makes maintenance harder. Consider extracting a shared regex constant or using the same pattern format for consistency.