@@ -146,6 +146,193 @@ This project uses [uv](https://docs.astral.sh/uv/) for dependency management dur
146
146
### Development Setup
147
147
148
148
1 . Install [ uv] ( https://docs.astral.sh/uv/getting-started/installation/ )
149
+ ![ logo] ( https://github.com/codellm-devkit/codeanalyzer-python/blob/main/docs/assets/logo.png?raw=true )
150
+
151
+ # A Python Static Analysis Toolkit (and Library)
152
+
153
+ A comprehensive static analysis tool for Python source code that provides symbol table generation, call graph analysis, and semantic analysis using Jedi, CodeQL, and Tree-sitter.
154
+
155
+ ## Installation
156
+
157
+ ``` bash
158
+ pip install codeanalyzer-python
159
+ ```
160
+
161
+ ### Prerequisites
162
+
163
+ - Python 3.12 or higher
164
+
165
+ #### System Package Requirements
166
+
167
+ The tool creates virtual environments internally using Python's built-in ` venv ` module.
168
+
169
+ ** Ubuntu/Debian systems:**
170
+ ``` bash
171
+ sudo apt update
172
+ sudo apt install python3.12-venv python3-dev build-essential
173
+ ```
174
+
175
+ ** Fedora/RHEL/CentOS systems:**
176
+ ``` bash
177
+ sudo dnf group install " Development Tools"
178
+ sudo dnf install python3-pip python3-venv python3-devel
179
+ ```
180
+ or on older versions:
181
+ ``` bash
182
+ sudo yum groupinstall " Development Tools"
183
+ sudo yum install python3-pip python3-venv python3-devel
184
+ ```
185
+
186
+ ** macOS systems:**
187
+ ``` bash
188
+ # Install Xcode Command Line Tools (for compilation)
189
+ xcode-select --install
190
+
191
+ # If using Homebrew Python (recommended)
192
+
193
+
194
+ # If using pyenv (popular Python version manager)
195
+ # First ensure pyenv is properly installed and configured
196
+ pyenv install 3.12.0 # or latest 3.12.x version
197
+ pyenv global 3.12.0 # or pyenv local 3.12.0 for project-specific
198
+
199
+ # If using system Python, you may need to install certificates
200
+ /Applications/Python\ 3.12/Install\ Certificates.command
201
+ ```
202
+
203
+ > ** Note:** These packages are required as the tool uses Python's built-in ` venv ` module to create isolated environments for analysis.
204
+
205
+ ## Usage
206
+
207
+ The codeanalyzer provides a command-line interface for performing static analysis on Python projects.
208
+
209
+ ### Basic Usage
210
+
211
+ ``` bash
212
+ codeanalyzer --input /path/to/python/project
213
+ ```
214
+
215
+ ### Command Line Options
216
+
217
+ To view the available options and commands, run ` codeanalyzer --help ` . You should see output similar to the following:
218
+
219
+ ``` bash
220
+ ❯ codeanalyzer --help
221
+
222
+ Usage: codeanalyzer [OPTIONS] COMMAND [ARGS]...
223
+
224
+ Static Analysis on Python source code using Jedi, CodeQL and Tree sitter.
225
+
226
+
227
+ ╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────╮
228
+ │ * --input -i PATH Path to the project root directory. [default: None] [required] │
229
+ │ --output -o PATH Output directory for artifacts. [default: None] │
230
+ │ --format -f [json| msgpack] Output format: json or msgpack. [default: json]. │
231
+ │ --analysis-level -a INTEGER 1: symbol table, 2: call graph. [default: 1] │
232
+ │ --codeql --no-codeql Enable CodeQL-based analysis. [default: no-codeql] │
233
+ │ --eager --lazy Enable eager or lazy analysis. Defaults to lazy. [default: lazy] │
234
+ │ --cache-dir -c PATH Directory to store analysis cache. [default: None] │
235
+ │ --clear-cache --keep-cache Clear cache after analysis. [default: clear-cache] │
236
+ │ -v INTEGER Increase verbosity: -v, -vv, -vvv [default: 0] │
237
+ │ --help Show this message and exit. │
238
+ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
239
+ ```
240
+
241
+ ### Examples
242
+
243
+ 1 . ** Basic analysis with symbol table:**
244
+ ``` bash
245
+ codeanalyzer --input ./my-python-project
246
+ ```
247
+
248
+ This will print the symbol table to stdout in JSON format to the standard output. If you want to save the output, you can use the ` --output ` option.
249
+
250
+ ``` bash
251
+ codeanalyzer --input ./my-python-project --output /path/to/analysis-results
252
+ ```
253
+
254
+ Now, you can find the analysis results in ` analysis.json ` in the specified directory.
255
+
256
+ 2 . ** Toggle analysis levels with ` --analysis-level ` :**
257
+ ``` bash
258
+ codeanalyzer --input ./my-python-project --analysis-level 1 # Symbol table only
259
+ ```
260
+ Call graph analysis can be enabled by setting the level to ` 2 ` :
261
+ ``` bash
262
+ codeanalyzer --input ./my-python-project --analysis-level 2 # Symbol table + Call graph
263
+ ```
264
+ *** Note: The ` --analysis-level=2 ` is not yet implemented in this version.***
265
+
266
+ 3 . ** Analysis with CodeQL enabled:**
267
+ ``` bash
268
+ codeanalyzer --input ./my-python-project --codeql
269
+ ```
270
+ This will perform CodeQL-based analysis in addition to the standard symbol table generation.
271
+
272
+ *** Note: Not yet fully implemented. Please refrain from using this option until further notice.***
273
+
274
+ 4 . ** Eager analysis with custom cache directory:**
275
+ ``` bash
276
+ codeanalyzer --input ./my-python-project --eager --cache-dir /path/to/custom-cache
277
+ ```
278
+ This will rebuild the analysis cache at every run and store it in ` /path/to/custom-cache/.codeanalyzer ` . The cache will be cleared by default after analysis unless you specify ` --keep-cache ` .
279
+
280
+ If you provide --cache-dir, the cache will be stored in that directory. If not specified, it defaults to ` .codeanalyzer ` in the current working directory (` $PWD ` ).
281
+
282
+ 5 . ** Save output in msgpack format:**
283
+ ``` bash
284
+ codeanalyzer --input ./my-python-project --output /path/to/analysis-results --format msgpack
285
+ ```
286
+
287
+ ### Output
288
+
289
+ By default, analysis results are printed to stdout in JSON format. When using the ` --output ` option, results are saved to ` analysis.json ` in the specified directory.
290
+
291
+ ## Development
292
+
293
+ This project uses [ uv] ( https://docs.astral.sh/uv/ ) for dependency management during development.
294
+
295
+ ### Development Setup
296
+
297
+ 1 . Install [ uv] ( https://docs.astral.sh/uv/getting-started/installation/ )
298
+
299
+ 2 . Clone the repository:
300
+ ``` bash
301
+ git clone https://github.com/codellm-devkit/codeanalyzer-python
302
+ cd codeanalyzer-python
303
+ ```
304
+
305
+ 3 . Install dependencies using uv:
306
+ ``` bash
307
+ uv sync --all-groups
308
+ ```
309
+ This will install all dependencies including development and test dependencies.
310
+
311
+ ### Running from Source
312
+
313
+ When developing, you can run the tool directly from source:
314
+
315
+ ``` bash
316
+ uv run codeanalyzer --input /path/to/python/project
317
+ ```
318
+
319
+ ### Running Tests
320
+
321
+ ``` bash
322
+ uv run pytest --pspec -s
323
+ ```
324
+
325
+ ### Development Dependencies
326
+
327
+ The project includes additional dependency groups for development:
328
+
329
+ - ** test** : pytest and related testing tools
330
+ - ** dev** : development tools like ipdb
331
+
332
+ Install all groups with:
333
+ ``` bash
334
+ uv sync --all-groups
335
+ ```
149
336
150
337
2 . Clone the repository:
151
338
``` bash
0 commit comments