Skip to main content

A high-performance Python dependency mapping tool written in Rust, powered by the Ruff parser.

Project description

py-dependency-mapper

High-performance static analyzer to map Python dependencies — written in Rust and powered by the Ruff parser.


Overview

py-dependency-mapper is a high-performance tool for analyzing static dependencies in Python projects.
It is implemented in Rust and uses the Ruff parser to provide extremely fast and accurate parsing of import graphs.

This makes it ideal for packaging (e.g., serverless deployments), dependency audits, or simply understanding the dependency graph of large applications.


Features

:zap: High performance thanks to the Ruff parser.

:jigsaw: Two-phase architecture: indexing and subgraph extraction per entry point.

:dart: Prefix filtering (e.g., ["my_app"]) to reduce noise.

:snake: Python API and CLI utilities.

:rocket: CI/CD friendly — designed for large projects with hundreds or thousands of files.


Installation

From PyPI

pip install py-dependency-mapper

Basic Usage

The workflow is designed to be efficient:

Indexing Phase — build a map of your entire project (or only the parts you're interested in).
Querying Phase — use that map to instantly resolve the dependencies of specific entry points.


Example Project

/path/to/project/
└── my_app/
    ├── __init__.py
    ├── main.py       # imports utils
    └── utils.py      # has no other local imports

Usage

import py_dependency_mapper
from pprint import pprint

# --- PHASE 1: Indexing (Done once at the start) ---
# This builds a complete map of all files, their hashes, and their imports.
# This is the heavy operation, but it's only done once.
print("Building the project's dependency map...")

dependency_map = py_dependency_mapper.build_dependency_map(
    source_root="/path/to/project",
    include_paths=["my_app/"],
    filter_prefixes=["my_app"]
)
print(f"Map built with {len(dependency_map)} files.")
# Expected output: Map built with 3 files.

# --- PHASE 2: Querying (Done as many times as you need) ---
# Now, for any Lambda or application entry point, you can get
# its specific dependency graph almost instantly.
entry_point = "/path/to/project/my_app/main.py"

print(f"\nGetting dependency graph for: {entry_point}")
# This call is extremely fast because it only queries the in-memory map.
dependency_graph = py_dependency_mapper.get_dependency_graph(
    dependency_map=dependency_map,
    entry_point=entry_point
)

print(f"The entry point requires {len(dependency_graph)} total files.")
# Expected output: The entry point requires 3 total files.

# `dependency_graph` is now a dictionary of {file_path: hash}
# ready to be used for building an asset hash or a ZIP file.
pprint(dependency_graph)

Expected Output

Building the project's dependency map...
Map built with 3 files.

Getting dependency graph for: /path/to/project/my_app/main.py
The entry point requires 3 total files.
{
  '/path/to/project/my_app/__init__.py': 'e3b0c442...',
  '/path/to/project/my_app/main.py': '...',
  '/path/to/project/my_app/utils.py': '...'
}

:book: API Reference

build_dependency_map(
    source_root: str,
    include_paths: List[str],
    filter_prefixes: List[str]
) -> Dict[str, ProjectFile]

Scans the project and builds the dependency map.

source_root: Absolute path to the root of your source code.

include_paths: A list of directories or files (relative to source_root) to begin the scan from.

filter_prefixes: A list of module prefixes to include in the analysis (e.g., ["my_app"]).

returns: A dictionary mapping file paths to ProjectFile objects.


pythonget_dependency_graph(
    dependency_map: Dict,
    entry_point: str
) -> Dict[str, str]

From the pre-built map, gets the dependency subgraph for a specific entry point.

dependency_map: The dictionary returned by build_dependency_map.

entry_point: The absolute path to the initial .py file.

returns: A dictionary mapping {file_path: hash} for all dependencies required by the entry point.


:scroll: License

This project is licensed under the MIT License.
See the LICENSE file for more details.


:raised_hands: Acknowledgements

This tool would not be possible without the incredible work of the team behind the Ruff project,
whose high-performance parser is the heart of this analyzer.

Ruff's license can be found in licenses/LICENSE-RUFF.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

py_dependency_mapper-0.1.3-cp313-cp313-win_amd64.whl (920.0 kB view details)

Uploaded CPython 3.13Windows x86-64

py_dependency_mapper-0.1.3-cp313-cp313-manylinux_2_34_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

py_dependency_mapper-0.1.3-cp313-cp313-macosx_11_0_arm64.whl (996.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

py_dependency_mapper-0.1.3-cp313-cp313-macosx_10_12_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

py_dependency_mapper-0.1.3-cp312-cp312-win_amd64.whl (920.1 kB view details)

Uploaded CPython 3.12Windows x86-64

py_dependency_mapper-0.1.3-cp312-cp312-manylinux_2_34_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

py_dependency_mapper-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (996.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

py_dependency_mapper-0.1.3-cp312-cp312-macosx_10_12_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

py_dependency_mapper-0.1.3-cp311-cp311-win_amd64.whl (920.1 kB view details)

Uploaded CPython 3.11Windows x86-64

py_dependency_mapper-0.1.3-cp311-cp311-manylinux_2_34_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

py_dependency_mapper-0.1.3-cp311-cp311-macosx_11_0_arm64.whl (999.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

py_dependency_mapper-0.1.3-cp311-cp311-macosx_10_12_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

py_dependency_mapper-0.1.3-cp310-cp310-win_amd64.whl (920.1 kB view details)

Uploaded CPython 3.10Windows x86-64

py_dependency_mapper-0.1.3-cp310-cp310-manylinux_2_34_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

py_dependency_mapper-0.1.3-cp310-cp310-macosx_11_0_arm64.whl (999.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

py_dependency_mapper-0.1.3-cp310-cp310-macosx_10_12_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

py_dependency_mapper-0.1.3-cp39-cp39-win_amd64.whl (920.2 kB view details)

Uploaded CPython 3.9Windows x86-64

py_dependency_mapper-0.1.3-cp39-cp39-manylinux_2_34_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

py_dependency_mapper-0.1.3-cp39-cp39-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

py_dependency_mapper-0.1.3-cp39-cp39-macosx_10_12_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.9macOS 10.12+ x86-64

py_dependency_mapper-0.1.3-cp38-cp38-win_amd64.whl (920.1 kB view details)

Uploaded CPython 3.8Windows x86-64

py_dependency_mapper-0.1.3-cp38-cp38-manylinux_2_34_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

py_dependency_mapper-0.1.3-cp38-cp38-macosx_11_0_arm64.whl (999.8 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

py_dependency_mapper-0.1.3-cp38-cp38-macosx_10_12_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.8macOS 10.12+ x86-64

File details

Details for the file py_dependency_mapper-0.1.3-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1439b6742e50ab27f07cb72b82a3898d6c4fe38f50c067366191954099eb170d
MD5 7753627a560a50345123b7b94e0412e9
BLAKE2b-256 219ab5ba2efbe4e88ae1860883d8c8a83d4c7cba45c144c621f71dcd4dbc4a82

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b33c0e40c52b8b55656ae1c0e6ad5907489628dd554963761e1aca26028565b7
MD5 6dcc55affb96ddf06d931cfabe1f44ca
BLAKE2b-256 b9fb4ac76cca936188de2e79adfdf512fa4ea6f251eb11e73996628991502824

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f3c15a7728eb8367eb8e45b605d07c38fdd80b13fd430fad2c418489ce91561e
MD5 a38035879ad2674e3cddd1c4418d6b86
BLAKE2b-256 7be918649bac591f7f8b237472391000a29c7ffaa69cf5700f8a24bfc58b756f

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3f644fc0e3e126a98d0087d9ebb02ae4b4ef8c4b23029eb71c36b157760eb2cc
MD5 072b7b8b74035c14368f88c03681a88c
BLAKE2b-256 a2226de40bc99a6968ca98e94873a2901f48a01080046acd155778ff25ff5d44

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e2686041366b110cf0bd33cd3b273a62ff08a19fb0a4d0b4e5581fc69fa49c5b
MD5 2c298471f90207044aa0c4089013cd00
BLAKE2b-256 28d42dab00b221be273d8d31c3b2fd584b651b2ac6be05ed48ee673044127eb5

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4b87e6985cbb2c40d14e625a57227f6f3fa6186e18830fa3f393b83c615dedf1
MD5 2ecc56a1ac93fe831605f3f3e2aa5bbe
BLAKE2b-256 a963a72259455322cb1ac376c2139f791bc56556be9ad7f892fda3e19042805e

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8c46f523a95143e23ad0c4a81b1c9c863cc7a4ac6170ff4f3abbb103b512327
MD5 a5bc1427192f3270fe6b83e5100bfcb4
BLAKE2b-256 bfd7ef2df22288e289d857aef284df1e77f96d8c7458edb6ab15fee36ab8ae44

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b0820b1f9b7ca7d6fa9214ea070202aad737bf2a966c74a91e281f379c7c44cd
MD5 b228f71ed6073e0cbdb4a6a04c6f1d6a
BLAKE2b-256 1eca3ca16782d5dbbd8be5101cf5aa633b4260f418f8676f80d2a9ec1047f87d

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8282f23a1b4a260a844442d979ad6e06de72251aff4c6202eb5149c28677435c
MD5 2a3cd22968ed760c0e2db5ed553ae836
BLAKE2b-256 a36d244af6470670b343a543dfcf3ada22d4f556bf52ff54ee6ae442c576017f

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 693df6ea27d756b43f94797d2a73219cfc4146a96fdcf23ede4d3018aca54764
MD5 d174ee1b3ab828411fad737892f9b8bc
BLAKE2b-256 c0ea7906611e936af4c54680654cdce3ecb23cd23b85313a155f72d54f659311

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 21045005f2260205db3db54412bde2cc4cc80008e95fa1cca889e2db90eedb77
MD5 cb41a5d68bdd3bb3efa7da8a80335aa9
BLAKE2b-256 84cbe78c51dbefadfddbc146252a99092c6e33581c8191c00d0e130ccd2fe301

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8fb9815acb437d72972178a0e4f19bfb926c3ae21413acb5f6eaf4adf2db3fa5
MD5 ce42a5eef1207776b12b953f81df0cad
BLAKE2b-256 10f7a8446e73dd1e34d0cdc38fbfd1fa00a07cbd9f455daa9340267295bfc149

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8130dec292823a91f5212b3231976d10536d93140f9dd82cb7df0a9a467b5e73
MD5 48506189188ac40506db9b3d16e01cf2
BLAKE2b-256 5bc767ee05c97f71e4ac962291511cba897619e5c63d30de2ac3cdf04b4f9d2a

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 92614605addad291412726183a43e7142fef05a0b5a0cbe76dc753e9fee1a538
MD5 371c59680e8a3979261ab6c2d4994451
BLAKE2b-256 766aef932946f8b18aef8b8e70cc912d00f6e83b2c657aad68eadd11782b5d5c

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b519188690eb6c7bb3e8890689eb72e5ccb5e3a856b5e22e639766252183fde8
MD5 e1eb025e8312a2d390d3478adc493a66
BLAKE2b-256 210e64f74be5681fc93c6a2a92e8f5e2ce821a0c06b3c295d380a791aad00f45

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ca2adce4c8f224d1ca043cbd498a1b87c0e7a2ef6a93e5c37e4a8a04af980474
MD5 1a714df261225e8bd7ff853e5850eedb
BLAKE2b-256 36fc5d30f6acfaaa2d3bc89427506cff4b58e17647c1ffafa5ff4619c49d0d6f

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 993c5086dd53878cac94db0aa1fd40a2083bb9d69eeba1b16909859904003e38
MD5 64ff9d4c49bde3985cac39ba7aed9629
BLAKE2b-256 d04fa9c5ffc9a6ff06ca68ed34480f8dc487138dffe3f2f59d094aab0fbfd6cd

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d6eb54e38a986b3ec2dbdce143e838d7cc2c2b7a34dffa8ce0df863fa6d87f63
MD5 e7164409c696ae3a0ddcd59472f5758c
BLAKE2b-256 2d0ed78658b620db42074692c97136ec2bebd9be76dba1870c85afb36e7d7e07

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 34d8c040d2b9b9d4e81c0fd536b64f07bb214231b6d396961ae37671a87bc131
MD5 b6079f15dab3c1985a95a8f5fef55f23
BLAKE2b-256 b7c92287be140baeaaf80d5b9a6650e5090b07f6efe9d646fbe66613b02afeed

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp39-cp39-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6cdedbf048f368e6fe1a2dc4c098c444a4bb8c3b45413629814f9e01bd1155e1
MD5 7c9fc3b39ed2fc7d4d182c8f499b8b10
BLAKE2b-256 2d048212417505c01cef17527a2669c06982b2b88d188aa6a9c7bc23c88ff5f2

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ee8fea30683752e2ff208099b40fc5b5533fda56f3c0e5acb2247a23b77683a2
MD5 3ceb6284f5af09e0bfd7d4ae2ad91c40
BLAKE2b-256 19e07abe77166adf560a928b269ff3ad137150cc314a7530bbcd8b7aaa763669

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 20538b41042c51a29a8915b0e7e2e2137bca9e38be506afc363a5f6ff59879f3
MD5 5c66ffecd356413d34a51a13b67bb87d
BLAKE2b-256 bfc6710703c768507c51e6aade08a70c60d759d33c140708e42584b573893680

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93b1c81c541288be652502d9599ecbee9340e26ed7c929ba035ae12ff40045a4
MD5 9f258a8cbceba07aaa0aeb78e5f0e455
BLAKE2b-256 6e95ca8deca92822d67c4c97e7f430091a47a3fcdaf9dc102b8c313757731102

See more details on using hashes here.

File details

Details for the file py_dependency_mapper-0.1.3-cp38-cp38-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for py_dependency_mapper-0.1.3-cp38-cp38-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7d9c8bd2d273b85bc258f10ae9265fac4869f4f43c51f6aaf202c24f6d6449f2
MD5 092d9c42ef89dede0bace3492a11997b
BLAKE2b-256 baa7a304278eb9b6a26fab7272e0113e9f4474b854ac26e358b98bd7600630b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page