@@ -490,11 +490,13 @@ public Builder workingDirectory(@Nullable Path workingDirectory) {
490490 }
491491
492492 /**
493- * Set the pip packages directory for recipe installations.
494- * When set, this directory will be added to PYTHONPATH and the openrewrite
495- * package will be automatically installed if not present.
493+ * Set the base pip packages directory.
494+ * When set, a version-specific subdirectory (e.g., {@code <pipPackagesPath>/0.5.3/}
495+ * for releases, or {@code <pipPackagesPath>/dev/} for dev builds) will be resolved
496+ * and added to PYTHONPATH. The openrewrite package is automatically installed
497+ * into that subdirectory if not already present.
496498 *
497- * @param pipPackagesPath The directory where pip packages are installed
499+ * @param pipPackagesPath The base directory under which version-specific pip packages are installed
498500 * @return This builder
499501 */
500502 public Builder pipPackagesPath (@ Nullable Path pipPackagesPath ) {
@@ -540,7 +542,7 @@ public PythonRewriteRpc get() {
540542 // version takes precedence. For release/CI builds, always use pipPackagesPath
541543 // to ensure the correct pinned version.
542544 String version = StringUtils .readFully (
543- PythonRewriteRpc .class .getResourceAsStream ("/META-INF/version.txt" ));
545+ PythonRewriteRpc .class .getResourceAsStream ("/META-INF/version.txt" )). trim () ;
544546 boolean isDevBuild = version .isEmpty () || version .endsWith (".dev0" );
545547 boolean interpreterHasRewrite = isDevBuild && pipPackagesPath != null && canImportRewrite (pythonPath );
546548 boolean usePipPackagesPath = pipPackagesPath != null && !interpreterHasRewrite ;
@@ -550,7 +552,7 @@ public PythonRewriteRpc get() {
550552 if (usePipPackagesPath ) {
551553 String versionDir = isDevBuild ? "dev" : version ;
552554 resolvedPipPackagesPath = pipPackagesPath .resolve (versionDir );
553- bootstrapOpenrewrite (resolvedPipPackagesPath );
555+ bootstrapOpenrewrite (resolvedPipPackagesPath , version , isDevBuild );
554556 }
555557
556558 Stream <@ Nullable String > cmd ;
@@ -662,10 +664,8 @@ private static boolean canImportRewrite(Path pythonPath) {
662664 * Ensures the openrewrite Python package is installed in the pip packages directory.
663665 * This is required for the RPC server to start.
664666 */
665- private void bootstrapOpenrewrite (Path pipPackagesPath ) {
666- String version = StringUtils .readFully (
667- PythonRewriteRpc .class .getResourceAsStream ("/META-INF/version.txt" ));
668- boolean pinVersion = !version .isEmpty () && !version .endsWith (".dev0" );
667+ private void bootstrapOpenrewrite (Path pipPackagesPath , String version , boolean isDevBuild ) {
668+ boolean pinVersion = !isDevBuild ;
669669
670670 Path versionMarker = pipPackagesPath .resolve (".openrewrite-version" );
671671 if (Files .exists (pipPackagesPath .resolve ("rewrite" ))) {
0 commit comments