A simple tool to gather symbols provided or library calls and attribute usage based on static analysis of sources of Python applications.
See [the linked article describing this tool](https://developers.redhat.com/articles/2022/01/05/extracting-information-python-source-code).
Installation
Invectio can be installed from PyPI using:
$ pip3 install invectio
$ invectio --help
Usage
You can use this library as a CLI tool or as a Python module:
invectio whatprovides project-dir/ # To scan all Python files recursively for symbols provided.
invectio whatprovides app.py # To perform symbols gathering on app.py file.
invectio whatuses project-dir/ # To scan all Python files recursively for symbols used from libraries.
invectio whatuses app.py # To perform gather symbols used from libraries on app.py file.
from invectio import gather_library_calls
from invectio import gather_symbols_provided
result: dict = gather_library_usage("project-dir")
result: dict = gather_library_usage("app.py")
result: dict = gather_symbols_provided("project-dir")
result: dict = gather_symbols_provided("app.py")
Limitations
As Python is a dynamic programming language, it’s not possible to obtain all library functions/attributes usage simply by performing static analysis of sources. One can still perfom “crazy” things like:
import tensorflow
getattr(tensorflow, "const" + "ant")("Hello, Invectio")
This library does its best to detect all function/attributes being used inside Python sources, but usage like shown above cannot be detected simply by static analysis of source code.
Development
To create a dev environment, clone the invectio repo and install all the dependencies:
git clone https://github.com/thoth-station/invectio && cd invectio
pipenv install --dev
To perform checks against unit tests present in the tests/ directory, issue the following command from the root of the git repo:
pipenv run python3 setup.py test
Release files for invectio 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| invectio-0.2.2.tar.gz | 20.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| invectio-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.1 kB
Release files / invectio-0.2.2.tar.gz
| Download URL | invectio-0.2.2.tar.gz |
|---|---|
| Size | 20.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f20c8a35f1747eff5cc0a2d5222b0427f75d6096712e67ec2829f491bc5ed82e
|
|
BLAKE2b-256 checksum How to use checksums |
f7ecb400457660d1298f21ee89c47258b91e2dfe058cd0d5d73513832f06bbc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8
|
Release files / invectio-0.2.2-py3-none-any.whl
| Download URL | invectio-0.2.2-py3-none-any.whl |
|---|---|
| Size | 21.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc1a2e69dd95ab98d90bc23fa6ad245d7f1a5f58b40cc9320c4d81786db01bdb
|
|
BLAKE2b-256 checksum How to use checksums |
0f3c98d23e4011f3ceb2d05bfb67878b469c6cd81b60b0104ddac73f2679275b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8
|