Declare a Python dependency only for older Pythons
ProprietaryAdd the environment marker python_version < "<version>" to each declaration of a dependency, so that installing the project on that Python version or a later one does not install it. Edits pyproject.toml ([project] dependencies, [project.optional-dependencies], [dependency-groups] and Poetry's dependency tables), Pipfile, requirements*.txt and requirements*.in, setup.cfg's install_requires and extras_require, and the requirement strings in setup.py's lists. A declaration that already excludes that version and later ones is left alone, and another marker is kept, joined with and. With unlessImporting, a project whose sources import one of those modules unguarded keeps its declaration as it is. uv.lock and Pipfile.lock are regenerated natively to match. Use it for a backport that the standard library replaces from that version on.
org. openrewrite. python. migrate. FenceDependencyRequired
The name of the package to fence, as PyPI spells it.
The first Python version, as MAJOR.MINOR, that should no longer install the package.
Optional
Modules that, imported by a project's Python sources outside an if or a try, keep its declaration unfenced, since that import would fail where the package is no longer installed. An import of a submodule counts. Separate values with commas.
mod run . --recipe= org. openrewrite. python. migrate. FenceDependency \
-P packageName= async-timeout \
-P belowPythonVersion=3.11Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.