PyMaven Patch

raw JSON →
0.3.2 verified Fri May 01 auth: no python

Python library for accessing and working with Maven artifacts using Maven coordinates and dependency resolution. Version 0.3.2 is the current release, maintained by nexB as a fork/advanced patch of the original pymaven library. Release cadence is low.

pip install pymaven-patch
error ModuleNotFoundError: No module named 'pymaven_patch'
cause Trying to import the package name as it appears on PyPI.
fix
Import the library as 'pymaven' (the internal package name).
error AttributeError: module 'pymaven' has no attribute 'artifact'
cause Using an older version (pre-0.3.0) where the API was different, or only installing a subset of the package.
fix
Upgrade to latest version: pip install --upgrade pymaven-patch
gotcha The library is a fork ('pymaven-patch') with slight API differences from the original 'pymaven' package. Import 'pymaven', not 'pymaven_patch'.
fix Use 'pip install pymaven-patch' but import as 'pymaven'.
gotcha Dependency resolution may fail silently or return incomplete results if the Maven repository is unavailable or the POM is malformed.
fix Wrap resolution in try/except and check the returned list length for sanity.
deprecated The 'mvn.resolve' function does not support custom repository URLs easily; it defaults to Maven Central only.
fix Use a separate HTTP client to fetch from custom repos and manually construct artifacts if needed.

Create a Maven artifact coordinate and resolve its dependencies.

from pymaven import artifact, mvn

# Create an artifact coordinate
coord = artifact.Artifact(group_id='com.example', artifact_id='my-lib', version='1.0.0')
print(f"Coordinate: {coord}")

# Resolve dependencies (requires internet access to Maven Central)
# This will fetch the POM and resolve transitive dependencies
try:
    deps = mvn.resolve(coord)
    print(f"Number of dependencies: {len(deps)}")
except Exception as e:
    print(f"Resolution failed: {e}")