depcycle 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
depcycle-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kishan Thanki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,264 @@
1
+ Metadata-Version: 2.4
2
+ Name: depcycle
3
+ Version: 0.2.0
4
+ Summary: Command-line tool to visualize Python project dependencies.
5
+ Author: DepCycle Maintainers
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Kishan Thanki
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/Matricess/depcycle
29
+ Project-URL: Repository, https://github.com/Matricess/depcycle
30
+ Project-URL: Issues, https://github.com/Matricess/depcycle/issues
31
+ Keywords: dependencies,graphviz,architecture,visualization,cli
32
+ Classifier: Development Status :: 3 - Alpha
33
+ Classifier: Environment :: Console
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: OS Independent
37
+ Classifier: Programming Language :: Python
38
+ Classifier: Programming Language :: Python :: 3
39
+ Classifier: Programming Language :: Python :: 3.8
40
+ Classifier: Programming Language :: Python :: 3.9
41
+ Classifier: Programming Language :: Python :: 3.10
42
+ Classifier: Programming Language :: Python :: 3.11
43
+ Classifier: Programming Language :: Python :: 3.12
44
+ Classifier: Topic :: Software Development :: Build Tools
45
+ Classifier: Topic :: Software Development :: Testing
46
+ Classifier: Topic :: Utilities
47
+ Requires-Python: >=3.8
48
+ Description-Content-Type: text/markdown
49
+ License-File: LICENSE
50
+ Requires-Dist: graphviz>=0.20.0
51
+ Provides-Extra: dev
52
+ Requires-Dist: pytest>=7.0; extra == "dev"
53
+ Dynamic: license-file
54
+
55
+ # DepCycle
56
+
57
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
58
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
59
+
60
+ **DepCycle** is a command-line tool to visualize Python project dependencies. It helps developers understand complex codebases by automatically generating visual maps of how modules are connected, making it easy to spot architectural problems like **circular dependencies** and untangle coupled code.
61
+
62
+ ## Features
63
+
64
+ - **Automatic Dependency Discovery**: Scans Python projects and builds a complete dependency graph
65
+ - **Cycle Detection**: Identifies circular dependencies that can lead to architectural issues
66
+ - **Flexible Visualization**: Multiple output formats including PNG, SVG, and HTML
67
+ - **Smart Filtering**: Exclude specific patterns, third-party libraries, or standard library modules
68
+ - **AST-Based Parsing**: Uses Python's Abstract Syntax Tree for accurate import detection
69
+
70
+ ## Links
71
+
72
+ - **Repository:** https://github.com/Matricess/depcycle.git
73
+ - **Tests:** https://github.com/Matricess/depcycle/tree/main/tests
74
+ - **Design commentary:** https://github.com/Matricess/depcycle/blob/main/DESIGN.md
75
+ - **Sample dependency graph:** `examples/` (local)
76
+
77
+ ## Prerequisites
78
+
79
+ - Python 3.8 or higher
80
+ - [Graphviz](https://graphviz.org/download/) (for PNG/SVG output)
81
+
82
+ ### Installing Graphviz
83
+
84
+ **macOS:**
85
+ ```bash
86
+ brew install graphviz
87
+ ```
88
+
89
+ **Ubuntu/Debian:**
90
+ ```bash
91
+ sudo apt-get install graphviz
92
+ ```
93
+
94
+ **Windows:**
95
+ Download and install from [Graphviz website](https://graphviz.org/download/)
96
+
97
+ ## Installation
98
+
99
+ ### Install via pip (recommended)
100
+
101
+ ```bash
102
+ pip install depcycle
103
+
104
+ or
105
+
106
+ # install directly from GitHub
107
+ pip install git+https://github.com/Matricess/depcycle.git
108
+ ```
109
+
110
+ ### Install from a clone (editable dev setup)
111
+
112
+ ```bash
113
+ git clone https://github.com/Matricess/depcycle.git
114
+ cd depcycle
115
+ pip install -e .[dev]
116
+ ```
117
+
118
+ If you prefer requirements files, `pip install -r requirements.txt` will install runtime deps plus `pytest` for the test suite.
119
+
120
+ ## Usage
121
+
122
+ ### Basic Usage
123
+
124
+ Analyze a Python project and generate a dependency graph (PNG by default):
125
+
126
+ ```bash
127
+ depcycle /path/to/your/project
128
+ ```
129
+
130
+ The output is written to `dependencies.png` in the current working directory.
131
+
132
+ > **Note:** By default DepCycle skips common noise directories such as `venv/`, `.venv/`, `.git/`, `__pycache__/`, `node_modules/`, build artifacts, and Python cache folders. Use `-e` flags if you need extra exclusions, or disable the defaults via the API (`Project.get_python_files(include_defaults=False)`).
133
+
134
+ ### Using as a Module
135
+
136
+ ```bash
137
+ python -m depcycle /path/to/your/project
138
+ ```
139
+
140
+ ### Advanced Options
141
+
142
+ Generate a different output format or explicit location:
143
+
144
+ ```bash
145
+ depcycle /path/to/project --format svg --output diagrams/dependencies.svg
146
+ ```
147
+
148
+ Exclude specific directories or files (glob syntax):
149
+
150
+ ```bash
151
+ depcycle /path/to/project -e venv -e ".*/tests/*" -e "*.test.py"
152
+ ```
153
+
154
+ Focus only on local code:
155
+
156
+ ```bash
157
+ depcycle /path/to/project --no-third-party --no-stdlib
158
+ ```
159
+
160
+ **Full help:**
161
+
162
+ ```bash
163
+ depcycle --help
164
+ ```
165
+
166
+ ## Tests
167
+
168
+ Tests live under `tests/` and run without touching the sample projects in `examples/`.
169
+
170
+ ```bash
171
+ pip install -e .[dev]
172
+ pytest -q
173
+ ```
174
+
175
+ See [`tests/README.md`](tests/README.md) for a quick summary.
176
+
177
+ ## Project Structure
178
+
179
+ ```
180
+ depcycle/
181
+ ├── src/
182
+ │ └── depcycle/
183
+ │ ├── __init__.py
184
+ │ ├── __main__.py
185
+ │ ├── cli.py # Command-line interface
186
+ │ ├── config.py # Configuration management
187
+ │ ├── graph/
188
+ │ │ ├── __init__.py
189
+ │ │ ├── dependency_graph.py # Core graph logic
190
+ │ │ └── module_node.py # Module representation
191
+ │ ├── parsing/
192
+ │ │ ├── __init__.py
193
+ │ │ ├── ast_parser.py # AST-based import parsing
194
+ │ │ └── project.py # File discovery
195
+ │ └── rendering/
196
+ │ ├── __init__.py
197
+ │ ├── interface.py # Visualization interface
198
+ │ └── visualizers.py # Output implementations
199
+ ├── requirements.txt
200
+ ├── README.md
201
+ └── LICENSE
202
+ ```
203
+
204
+ ## Architecture
205
+
206
+ DepCycle follows a clean, modular architecture:
207
+
208
+ 1. **CLI Layer** (`cli.py`): Handles user input and orchestrates the workflow
209
+ 2. **Configuration** (`config.py`): Manages all settings and options
210
+ 3. **Graph Layer** (`graph/`): Core data structures for the dependency graph
211
+ 4. **Parsing Layer** (`parsing/`): Discovers files and extracts imports using AST
212
+ 5. **Rendering Layer** (`rendering/`): Generates visualizations in various formats
213
+
214
+ ## Key Classes
215
+
216
+ - **`DepCycleCLI`**: Main entry point that handles command-line arguments
217
+ - **`DependencyGraph`**: Central data structure holding all module relationships
218
+ - **`ModuleNode`**: Represents a single Python module/file
219
+ - **`Project`**: Discovers and manages Python files in a project
220
+ - **`ASTParser`**: Extracts imports using Python's AST module
221
+ - **`GraphvizVisualizer`**: Renders graphs as PNG/SVG images
222
+ - **`HtmlVisualizer`**: Generates interactive HTML visualizations
223
+
224
+ ## How It Works
225
+
226
+ 1. **Discovery**: Recursively scans the project directory for all `.py` files
227
+ 2. **Parsing**: Uses Python's AST to extract import statements from each file
228
+ 3. **Resolution**: Maps import strings to actual modules in the project
229
+ 4. **Classification**: Categorizes modules as LOCAL, THIRD_PARTY, or STDLIB
230
+ 5. **Analysis**: Detects circular dependencies using depth-first search
231
+ 6. **Visualization**: Renders the graph using Graphviz or HTML
232
+
233
+ ## Example Output
234
+
235
+ When you run DepCycle, you'll see output like:
236
+
237
+ ```
238
+ Analyzing project: /path/to/my-project
239
+ Building dependency graph...
240
+ Found 42 modules
241
+ ✓ No circular dependencies detected
242
+ Generating PNG visualization...
243
+ ✓ Visualization saved to: dependencies.png
244
+ ```
245
+
246
+ If circular dependencies are found:
247
+
248
+ ```
249
+ ⚠️ Warning: Found 2 circular dependency cycles!
250
+ Cycle 1: app.models.user → app.services.auth → app.models.user
251
+ Cycle 2: app.core.database → app.core.config → app.core.database
252
+ ```
253
+
254
+ ## Contributing
255
+
256
+ Contributions are welcome! Please feel free to submit a Pull Request.
257
+
258
+ ## License
259
+
260
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
261
+
262
+ ## Acknowledgments
263
+
264
+ Built as part of a Software Design and Testing course project (IT643).
@@ -0,0 +1,210 @@
1
+ # DepCycle
2
+
3
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ **DepCycle** is a command-line tool to visualize Python project dependencies. It helps developers understand complex codebases by automatically generating visual maps of how modules are connected, making it easy to spot architectural problems like **circular dependencies** and untangle coupled code.
7
+
8
+ ## Features
9
+
10
+ - **Automatic Dependency Discovery**: Scans Python projects and builds a complete dependency graph
11
+ - **Cycle Detection**: Identifies circular dependencies that can lead to architectural issues
12
+ - **Flexible Visualization**: Multiple output formats including PNG, SVG, and HTML
13
+ - **Smart Filtering**: Exclude specific patterns, third-party libraries, or standard library modules
14
+ - **AST-Based Parsing**: Uses Python's Abstract Syntax Tree for accurate import detection
15
+
16
+ ## Links
17
+
18
+ - **Repository:** https://github.com/Matricess/depcycle.git
19
+ - **Tests:** https://github.com/Matricess/depcycle/tree/main/tests
20
+ - **Design commentary:** https://github.com/Matricess/depcycle/blob/main/DESIGN.md
21
+ - **Sample dependency graph:** `examples/` (local)
22
+
23
+ ## Prerequisites
24
+
25
+ - Python 3.8 or higher
26
+ - [Graphviz](https://graphviz.org/download/) (for PNG/SVG output)
27
+
28
+ ### Installing Graphviz
29
+
30
+ **macOS:**
31
+ ```bash
32
+ brew install graphviz
33
+ ```
34
+
35
+ **Ubuntu/Debian:**
36
+ ```bash
37
+ sudo apt-get install graphviz
38
+ ```
39
+
40
+ **Windows:**
41
+ Download and install from [Graphviz website](https://graphviz.org/download/)
42
+
43
+ ## Installation
44
+
45
+ ### Install via pip (recommended)
46
+
47
+ ```bash
48
+ pip install depcycle
49
+
50
+ or
51
+
52
+ # install directly from GitHub
53
+ pip install git+https://github.com/Matricess/depcycle.git
54
+ ```
55
+
56
+ ### Install from a clone (editable dev setup)
57
+
58
+ ```bash
59
+ git clone https://github.com/Matricess/depcycle.git
60
+ cd depcycle
61
+ pip install -e .[dev]
62
+ ```
63
+
64
+ If you prefer requirements files, `pip install -r requirements.txt` will install runtime deps plus `pytest` for the test suite.
65
+
66
+ ## Usage
67
+
68
+ ### Basic Usage
69
+
70
+ Analyze a Python project and generate a dependency graph (PNG by default):
71
+
72
+ ```bash
73
+ depcycle /path/to/your/project
74
+ ```
75
+
76
+ The output is written to `dependencies.png` in the current working directory.
77
+
78
+ > **Note:** By default DepCycle skips common noise directories such as `venv/`, `.venv/`, `.git/`, `__pycache__/`, `node_modules/`, build artifacts, and Python cache folders. Use `-e` flags if you need extra exclusions, or disable the defaults via the API (`Project.get_python_files(include_defaults=False)`).
79
+
80
+ ### Using as a Module
81
+
82
+ ```bash
83
+ python -m depcycle /path/to/your/project
84
+ ```
85
+
86
+ ### Advanced Options
87
+
88
+ Generate a different output format or explicit location:
89
+
90
+ ```bash
91
+ depcycle /path/to/project --format svg --output diagrams/dependencies.svg
92
+ ```
93
+
94
+ Exclude specific directories or files (glob syntax):
95
+
96
+ ```bash
97
+ depcycle /path/to/project -e venv -e ".*/tests/*" -e "*.test.py"
98
+ ```
99
+
100
+ Focus only on local code:
101
+
102
+ ```bash
103
+ depcycle /path/to/project --no-third-party --no-stdlib
104
+ ```
105
+
106
+ **Full help:**
107
+
108
+ ```bash
109
+ depcycle --help
110
+ ```
111
+
112
+ ## Tests
113
+
114
+ Tests live under `tests/` and run without touching the sample projects in `examples/`.
115
+
116
+ ```bash
117
+ pip install -e .[dev]
118
+ pytest -q
119
+ ```
120
+
121
+ See [`tests/README.md`](tests/README.md) for a quick summary.
122
+
123
+ ## Project Structure
124
+
125
+ ```
126
+ depcycle/
127
+ ├── src/
128
+ │ └── depcycle/
129
+ │ ├── __init__.py
130
+ │ ├── __main__.py
131
+ │ ├── cli.py # Command-line interface
132
+ │ ├── config.py # Configuration management
133
+ │ ├── graph/
134
+ │ │ ├── __init__.py
135
+ │ │ ├── dependency_graph.py # Core graph logic
136
+ │ │ └── module_node.py # Module representation
137
+ │ ├── parsing/
138
+ │ │ ├── __init__.py
139
+ │ │ ├── ast_parser.py # AST-based import parsing
140
+ │ │ └── project.py # File discovery
141
+ │ └── rendering/
142
+ │ ├── __init__.py
143
+ │ ├── interface.py # Visualization interface
144
+ │ └── visualizers.py # Output implementations
145
+ ├── requirements.txt
146
+ ├── README.md
147
+ └── LICENSE
148
+ ```
149
+
150
+ ## Architecture
151
+
152
+ DepCycle follows a clean, modular architecture:
153
+
154
+ 1. **CLI Layer** (`cli.py`): Handles user input and orchestrates the workflow
155
+ 2. **Configuration** (`config.py`): Manages all settings and options
156
+ 3. **Graph Layer** (`graph/`): Core data structures for the dependency graph
157
+ 4. **Parsing Layer** (`parsing/`): Discovers files and extracts imports using AST
158
+ 5. **Rendering Layer** (`rendering/`): Generates visualizations in various formats
159
+
160
+ ## Key Classes
161
+
162
+ - **`DepCycleCLI`**: Main entry point that handles command-line arguments
163
+ - **`DependencyGraph`**: Central data structure holding all module relationships
164
+ - **`ModuleNode`**: Represents a single Python module/file
165
+ - **`Project`**: Discovers and manages Python files in a project
166
+ - **`ASTParser`**: Extracts imports using Python's AST module
167
+ - **`GraphvizVisualizer`**: Renders graphs as PNG/SVG images
168
+ - **`HtmlVisualizer`**: Generates interactive HTML visualizations
169
+
170
+ ## How It Works
171
+
172
+ 1. **Discovery**: Recursively scans the project directory for all `.py` files
173
+ 2. **Parsing**: Uses Python's AST to extract import statements from each file
174
+ 3. **Resolution**: Maps import strings to actual modules in the project
175
+ 4. **Classification**: Categorizes modules as LOCAL, THIRD_PARTY, or STDLIB
176
+ 5. **Analysis**: Detects circular dependencies using depth-first search
177
+ 6. **Visualization**: Renders the graph using Graphviz or HTML
178
+
179
+ ## Example Output
180
+
181
+ When you run DepCycle, you'll see output like:
182
+
183
+ ```
184
+ Analyzing project: /path/to/my-project
185
+ Building dependency graph...
186
+ Found 42 modules
187
+ ✓ No circular dependencies detected
188
+ Generating PNG visualization...
189
+ ✓ Visualization saved to: dependencies.png
190
+ ```
191
+
192
+ If circular dependencies are found:
193
+
194
+ ```
195
+ ⚠️ Warning: Found 2 circular dependency cycles!
196
+ Cycle 1: app.models.user → app.services.auth → app.models.user
197
+ Cycle 2: app.core.database → app.core.config → app.core.database
198
+ ```
199
+
200
+ ## Contributing
201
+
202
+ Contributions are welcome! Please feel free to submit a Pull Request.
203
+
204
+ ## License
205
+
206
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
207
+
208
+ ## Acknowledgments
209
+
210
+ Built as part of a Software Design and Testing course project (IT643).
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "depcycle"
7
+ version = "0.2.0"
8
+ description = "Command-line tool to visualize Python project dependencies."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { file = "LICENSE" }
12
+ authors = [
13
+ { name = "DepCycle Maintainers" }
14
+ ]
15
+ keywords = ["dependencies", "graphviz", "architecture", "visualization", "cli"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Operating System :: OS Independent",
22
+ "Programming Language :: Python",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.8",
25
+ "Programming Language :: Python :: 3.9",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Topic :: Software Development :: Build Tools",
30
+ "Topic :: Software Development :: Testing",
31
+ "Topic :: Utilities"
32
+ ]
33
+ dependencies = [
34
+ "graphviz>=0.20.0",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "pytest>=7.0",
40
+ ]
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/Matricess/depcycle"
44
+ Repository = "https://github.com/Matricess/depcycle"
45
+ Issues = "https://github.com/Matricess/depcycle/issues"
46
+
47
+ [project.scripts]
48
+ depcycle = "depcycle.cli:DepCycleCLI.main"
49
+
50
+ [tool.setuptools]
51
+ package-dir = {"" = "src"}
52
+
53
+ [tool.setuptools.packages.find]
54
+ where = ["src"]
55
+ include = ["depcycle*"]
56
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,28 @@
1
+ """
2
+ DepCycle - A dependency graph visualization tool for Python projects.
3
+
4
+ DepCycle helps developers understand complex codebases by automatically
5
+ generating visual maps of module dependencies.
6
+ """
7
+
8
+ __version__ = "0.2.0"
9
+
10
+ from .cli import DepCycleCLI
11
+ from .config import Config
12
+ from .graph import DependencyGraph, ModuleNode, ModuleType
13
+ from .parsing import Project, ASTParser
14
+ from .rendering import IGraphVisualizer, GraphvizVisualizer, HtmlVisualizer
15
+
16
+ __all__ = [
17
+ 'DepCycleCLI',
18
+ 'Config',
19
+ 'DependencyGraph',
20
+ 'ModuleNode',
21
+ 'ModuleType',
22
+ 'Project',
23
+ 'ASTParser',
24
+ 'IGraphVisualizer',
25
+ 'GraphvizVisualizer',
26
+ 'HtmlVisualizer',
27
+ ]
28
+
@@ -0,0 +1,7 @@
1
+ """Entry point for running depcycle as a module: python -m depcycle"""
2
+
3
+ from .cli import DepCycleCLI
4
+
5
+ if __name__ == '__main__':
6
+ DepCycleCLI.main()
7
+