Skip to content

Python: Unify dev and release bootstrap for openrewrite package#6839

Merged
knutwannheden merged 5 commits intomainfrom
python-dev-bootstrap
Feb 27, 2026
Merged

Python: Unify dev and release bootstrap for openrewrite package#6839
knutwannheden merged 5 commits intomainfrom
python-dev-bootstrap

Conversation

@knutwannheden
Copy link
Copy Markdown
Contributor

@knutwannheden knutwannheden commented Feb 27, 2026

Summary

The Python RPC bootstrap logic previously had separate paths for dev and release builds. For dev builds, it ran pip install openrewrite (unpinned) into a dev/ directory, which installed whatever version was latest on PyPI and never updated it — leading to stale release code silently running in a development context.

The bootstrap is now unified for both dev pre-releases (e.g., 8.75.0.dev0) and stable releases:

  1. If pipPackagesPath is set, check for a version-specific install there (e.g., 8.75.0.dev0/)
  2. If the Python interpreter already has the right version installed, use it as-is
  3. Otherwise, install the exact version via pip install openrewrite==<version> to pipPackagesPath
  4. If pipPackagesPath is not set and the interpreter doesn't have the right version, fail with an actionable error

This eliminates the dev/ directory entirely. Dev pre-releases published to PyPI are now installed to version-specific subdirectories just like stable releases.

Developer setup

For local development (when no version file is present), the interpreter must already have the rewrite package importable. Set up the venv:

cd rewrite-python/rewrite
uv sync --extra dev

This creates a .venv with an editable install pointing at the local source tree. Then either:

  • Point pythonPath to .venv/bin/python, or
  • Activate the venv before running

Test plan

  • Compiles
  • Verify dev pre-release version installs to version-specific directory
  • Verify interpreter with correct version skips bootstrap
  • Verify missing version without pipPackagesPath fails with helpful error
  • Verify local dev (empty version) with venv works

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Feb 27, 2026
@knutwannheden knutwannheden changed the title Python: Require interpreter to have openrewrite installed for dev builds Python: Require interpreter to have openrewrite installed for dev builds Feb 27, 2026
The bootstrap logic now works the same for dev pre-releases (e.g.,
8.75.0.dev0) and stable releases:

1. If pipPackagesPath is set, check for a version-specific install there
2. If the interpreter already has the right version, use it as-is
3. Otherwise install via pip to pipPackagesPath (or fail if not set)

This eliminates the stale `dev/` directory that previously installed
an unpinned PyPI release and never updated it. Dev pre-releases are
now installed to version-specific subdirectories like stable releases.

For local development without a version file (version is empty),
the interpreter must already have the rewrite package available
(e.g., via `uv sync --extra dev` in rewrite-python/rewrite/).
@knutwannheden knutwannheden changed the title Python: Require interpreter to have openrewrite installed for dev builds Python: Unify dev and release bootstrap for openrewrite package Feb 27, 2026
The .dev0 suffix indicates a local dev build that isn't published to
PyPI, so attempting `pip install openrewrite==X.Y.Z.dev0` will always
fail. Restore the dev build check so these versions require the
interpreter to already have the package (e.g. via editable install).

Also improve pip install error messages to include the version being
installed and capture pip output on failure.
…ests

Handle Gradle's "unspecified" version (used in IDE runs) the same as
.dev0 — require the interpreter to already have the rewrite package
rather than attempting to pip-install a non-existent version.

Also remove ad-hoc paramiko/fabric parsing tests that were committed
by mistake.
CI builds produce timestamped versions like 8.75.0.dev20260227100441
which are also not published to PyPI. Use .contains(".dev") instead
of .endsWith(".dev0") to catch all PEP 440 dev versions.
Timestamped .dev versions (e.g., 8.75.0.dev20260227100441) are real
publishable pre-releases, not local dev builds. When the exact version
isn't found and pipPackagesPath isn't set, fall back to checking if the
interpreter can import rewrite at all. This handles CI test runs where
the venv has an editable install that doesn't match the timestamped
version.
@knutwannheden knutwannheden changed the title Python: Unify dev and release bootstrap for openrewrite package Python: Unify dev and release bootstrap for openrewrite package Feb 27, 2026
@knutwannheden knutwannheden merged commit 33ac75a into main Feb 27, 2026
1 check passed
@knutwannheden knutwannheden deleted the python-dev-bootstrap branch February 27, 2026 10:27
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant