Module Scan
Scans Python project repositories for all module imports that are NOT part of Python standard library regardless of whether the package is installed or not. Since this module does not consult pip installed modules, this scan can be performed on CI.
Features
- Scan source code repository recursively for module imports
- Uses native Python parser to find module imports
- Find packages even if they are not installed (useful in automated builds with no virtual environments)
- Lightweight scanner useful for generating Software Bill Of Materials (SBOM)
Installation
- Clone repository and run the script
$ git clone git@github.com:cetcs92/module-scanner.git
- Install using pip
$ pip install module-scan
Scan repository
$ cd <repo root>
$ module-scan
Import in your code
from module_scan import ImportScan
s = ImportScan()
# scan repository in current working directory
s.scan()
# OR scan repository in a different location
# s.scan(<path to repository to scan>)
# Print the modules discovered
# _imports_found is a dictionary with filename as key and set of packages as value
# {
# file1: {pkg1, pkg2, ...},
# file2: ....
# }
print(s._imports_found)
# Let module scan do a pretty print of modules discovered
s.print()
# Use module-scan info in your code
for file, pkg in s.packages():
# do something with file, pkg
Metadata
Release files for module-scan 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| module-scan-1.0.0.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| module_scan-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.9 kB
Release files / module-scan-1.0.0.tar.gz
| Download URL | module-scan-1.0.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85cf564edd16ba95d6118bb76fb3926efb668041b80223e8ede5876903ef29bd
|
|
BLAKE2b-256 checksum How to use checksums |
23ac660d292a019c685614adfe2500169d71a8064cf57e874bd17a62f156c111
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Release files / module_scan-1.0.0-py3-none-any.whl
| Download URL | module_scan-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4fda00fa3c193033d33e3e9b2cd32379cd674daa4bbcf67839d3e42a420b4c38
|
|
BLAKE2b-256 checksum How to use checksums |
bb8cacf5adc9e2ff42d3d38546758bb570b32f577c3662a5eae0eff78564ef0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|