Skip to main content

Python dependency insight

org.openrewrite.python.search.DependencyInsight

Find direct and transitive Python dependencies matching a package name pattern. Results include dependencies that either directly match or transitively include a matching dependency.

Recipe source

This recipe is only available to users of Moderne.

This recipe is available under the Moderne Proprietary License.

Options

TypeNameDescriptionExample
StringpackageNamePatternA glob pattern to match Python package names (PEP 503 normalized). Use * as a wildcard.requests*
StringscopeOptional. Match dependencies in the specified scope. All scopes are searched by default. Valid options: dependencies, buildRequires, optionalDependencies, dependencyGroupsdependencies
BooleanonlyDirectOptional. If enabled, transitive dependencies will not be considered. All dependencies are searched by default.true

Usage

This recipe has required configuration parameters and can only be run by users of Moderne. To run this recipe, you will need to provide the Moderne CLI run command with the required options. Or, if you'd like to create a declarative recipe, please see the below example of a rewrite.yml file:

rewrite.yml
---
type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.DependencyInsightExample
displayName: Python dependency insight example
recipeList:
- org.openrewrite.python.search.DependencyInsight:
packageNamePattern: requests*
scope: dependencies
onlyDirect: true

You will need to have configured the Moderne CLI on your machine before you can run the following command.

shell
mod run . --recipe DependencyInsight --recipe-option "packageNamePattern=requests*" --recipe-option "scope=dependencies" --recipe-option "onlyDirect=true"

If the recipe is not available locally, then you can install it using:

mod config recipes jar install org.openrewrite:rewrite-python:8.73.1

See how this recipe works across multiple open-source repositories

Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.

Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.

Data Tables

Python dependencies in use

org.openrewrite.python.table.PythonDependenciesInUse

Direct and transitive dependencies in use in Python projects.

Column NameDescription
Project nameThe name of the project that contains the dependency (from pyproject.toml).
Project pathThe path to the project.
Package nameThe name of the Python package.
VersionThe resolved version of the package.
Version constraintThe version constraint as declared in pyproject.toml.
ScopeDependency scope: dependencies, buildRequires, optionalDependencies, or dependencyGroups.
DirectWhether this is a direct dependency (true) or transitive dependency (false).
CountHow many times this dependency appears in the dependency tree.
LicenseThe SPDX license identifier of the project, if available.