Commit 2dbbb53
committed
PipRecipeBundleResolver: pip install on the server side
Mirrors the JS RPC server's design where `npm install` runs server-side
during InstallRecipes. Today the Python RPC server's
handle_install_recipes assumes the package is already importable; if it
isn't, prepareRecipe later throws "Recipe not found". The JVM-side
PipRecipeBundleResolver doesn't pip install either, so the contract was
implicit: "some other process must have pre-installed this package",
which is fragile and forced downstream callers to duplicate install
logic.
Fix on the Python side:
- New `--recipe-install-dir` argv stores the install target globally.
- `_pip_install_recipe_package` shells out to `python -m pip install
--target <dir> <package>==<version>` and primes sys.path.
- `handle_install_recipes`'s package-spec branch invokes it when the
requested package isn't already importable at the requested version,
before the existing import + activate flow.
Fix on the Java side:
- `PythonRewriteRpc` passes `--recipe-install-dir=<path>` to the
Python process when the builder's `recipeInstallDir` is set. The
existing PYTHONPATH wiring is unchanged, so a package that's already
installed remains importable as before.
The local-path branch (caller passes a directory containing an already-
unpacked recipe package) is unchanged.1 parent 72154fd commit 2dbbb53
3 files changed
Lines changed: 78 additions & 6 deletions
File tree
- rewrite-python
- rewrite
- src/rewrite/rpc
- tests/rpc
- src/main/java/org/openrewrite/python/rpc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
| |||
627 | 631 | | |
628 | 632 | | |
629 | 633 | | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
630 | 663 | | |
631 | 664 | | |
632 | 665 | | |
633 | | - | |
634 | | - | |
635 | | - | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
636 | 670 | | |
637 | 671 | | |
638 | 672 | | |
| |||
675 | 709 | | |
676 | 710 | | |
677 | 711 | | |
678 | | - | |
679 | 712 | | |
680 | 713 | | |
681 | 714 | | |
682 | 715 | | |
683 | 716 | | |
684 | 717 | | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
685 | 721 | | |
686 | 722 | | |
687 | | - | |
688 | 723 | | |
689 | 724 | | |
690 | 725 | | |
| |||
1640 | 1675 | | |
1641 | 1676 | | |
1642 | 1677 | | |
| 1678 | + | |
1643 | 1679 | | |
1644 | 1680 | | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
1645 | 1685 | | |
1646 | 1686 | | |
1647 | 1687 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
29 | 60 | | |
30 | 61 | | |
31 | 62 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
602 | | - | |
| 602 | + | |
| 603 | + | |
603 | 604 | | |
604 | 605 | | |
605 | 606 | | |
| |||
0 commit comments