Commit 7d7d453
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 7d7d453
3 files changed
Lines changed: 108 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 | + | |
| 82 | + | |
| 83 | + | |
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
| |||
627 | 633 | | |
628 | 634 | | |
629 | 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 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
630 | 676 | | |
631 | 677 | | |
632 | 678 | | |
633 | | - | |
634 | | - | |
635 | | - | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
636 | 684 | | |
637 | 685 | | |
638 | 686 | | |
| |||
675 | 723 | | |
676 | 724 | | |
677 | 725 | | |
678 | | - | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
679 | 730 | | |
680 | 731 | | |
681 | 732 | | |
682 | 733 | | |
683 | 734 | | |
684 | 735 | | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
685 | 739 | | |
686 | 740 | | |
687 | | - | |
688 | 741 | | |
689 | 742 | | |
690 | 743 | | |
| |||
1640 | 1693 | | |
1641 | 1694 | | |
1642 | 1695 | | |
| 1696 | + | |
1643 | 1697 | | |
1644 | 1698 | | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
1645 | 1703 | | |
1646 | 1704 | | |
1647 | 1705 | | |
| |||
| 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 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
29 | 72 | | |
30 | 73 | | |
31 | 74 | | |
| |||
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