Commit 77679bc
authored
Python: Pin
* Pin openrewrite Python package version in PythonRewriteRpc bootstrap
PythonRewriteRpc.bootstrapOpenrewrite() was running bare `pip install
openrewrite` without a version specifier, unlike the JavaScript side
which reads /META-INF/version.txt and pins `@openrewrite/rewrite@<version>`.
This meant the Python RPC could end up with a mismatched openrewrite
package version, and the existence-only check meant users could get
stuck on a stale version indefinitely.
Changes:
- Generate META-INF/version.txt in the build (PEP 440 format) so the
Java code can read the expected Python package version at runtime
- Pin `openrewrite==<version>` in bootstrapOpenrewrite() for release
and CI builds; skip pinning for local .dev0 builds
- Track installed version via a marker file to detect and upgrade
stale installs
- Add license exclude for version.txt and .gitignore entry
* Add --upgrade to pip install so stale versions get replaced
Without --upgrade, pip install --target may skip the install when
it sees the package already exists, even if the version differs.
* Skip bootstrap when dev interpreter already has rewrite package
For SNAPSHOT/dev builds, probe whether the Python interpreter can
already import rewrite (e.g., from a venv with an editable install).
If so, skip both the bootstrap and the PYTHONPATH prepend so the
interpreter's own package takes precedence.
For release/CI builds, always bootstrap and prepend to ensure the
correct pinned version is used. This mirrors the JS pattern where
SNAPSHOT trusts the local dev environment (npm link) while release
pins the exact version.openrewrite Python package version in RPC bootstrap (#6813)1 parent 890f876 commit 77679bc
3 files changed
Lines changed: 96 additions & 9 deletions
File tree
- rewrite-python
- src/main/java/org/openrewrite/python/rpc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
199 | | - | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
| |||
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
214 | 240 | | |
215 | 241 | | |
216 | 242 | | |
| |||
364 | 390 | | |
365 | 391 | | |
366 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
Lines changed: 64 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
519 | 520 | | |
520 | 521 | | |
521 | 522 | | |
522 | | - | |
523 | | - | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
524 | 535 | | |
525 | 536 | | |
526 | 537 | | |
| |||
550 | 561 | | |
551 | 562 | | |
552 | 563 | | |
553 | | - | |
554 | | - | |
| 564 | + | |
| 565 | + | |
555 | 566 | | |
556 | 567 | | |
557 | 568 | | |
| |||
602 | 613 | | |
603 | 614 | | |
604 | 615 | | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
605 | 638 | | |
606 | 639 | | |
607 | 640 | | |
608 | 641 | | |
609 | 642 | | |
610 | | - | |
611 | | - | |
612 | | - | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
613 | 661 | | |
614 | 662 | | |
| 663 | + | |
| 664 | + | |
615 | 665 | | |
616 | 666 | | |
617 | 667 | | |
618 | 668 | | |
619 | 669 | | |
620 | 670 | | |
| 671 | + | |
621 | 672 | | |
622 | | - | |
| 673 | + | |
623 | 674 | | |
624 | 675 | | |
625 | 676 | | |
| |||
652 | 703 | | |
653 | 704 | | |
654 | 705 | | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
655 | 711 | | |
656 | 712 | | |
657 | 713 | | |
| |||
0 commit comments