A command line tool for generating project dependencies table
Project description
leafhopper
Do you get asked by your employer to provide a list of open source libraries that you use in the project for legal review?
leafhopper is a command line tool used for generating a table of dependencies for a project, including their licenses, so that you don't have to manually maintain such a list for every release of your project.
How it works
The tool parses the project descriptor, based on different project types (poetry/maven/vcpkg are supported currently), and generates a table of dependencies. When some critical information, such as license, is not available in the project descriptor, leafhopper will test if this is a github/sourceforge project and try loading relevant information from github.com/sourceforge.net.
Features
- parse multiple different project types to generate a table of dependencies from them
- load license information from github/sourceforge
- support overriding the list of dependencies from the project descriptor when you cannot get correct information from the project descriptor
- support customizing the output columns
- multiple outout formats
- generate a combined license file from all the licenses of the dependencies
- github token can be provided in environment variable to avoid github API rate limiting
Installation
pip install leafhopper
Usage
leafhopper /path/to/project/descriptor
arguments
--format: the format of the output. Possible values aremarkdown/html/json/latex/csv. Default ismarkdown.--output: the output file path. If not specified, the output will be printed to stdout.--columns: the output table header columns. It is a comma separated string. Default value isname,version,homepage,license,description. You can change the order of columns or add empty columns by changing the value. For example,name,license,homepage,componentadd a new empty column calledcomponentand reorder the columns as well.--logging-level: the logging level. Possible values aredebug/info/warning/error/critical. Default isinfo.- Set the logging level to above
info(e.g.error) to supress non critical messages so that only table is printed to stdout (if no output file is specified). - Set the logging level to
debugto enable debug messages.
- Set the logging level to above
--extra: the file path to a JSON file path containing extra package information to override the information parsed from project descriptors. Theoverridesproperty in JSON file is an array of objects with the following properties (here is an example):nameversion, optionallicense, optionalhomepage, optionaldescription, optionaldisclosed_source, optional, a url to the discolosed source for some license requirement such as MPL
--combine: whether to generate a combined license file. Usetrue/falseto toggle it. Default is false.--help: show the help message
examples
- extract
pyproject.tomldependencies with markdown format and save it intodependencies.mdfile
leafhopper /path/to/pyproject.toml --output=dependencies.md
- extract
pom.xmldependencies with html format
leaphopper /path/to/pom.xml --format=html
- suppress logging and output to stdout and use CLI tool
glowto display it
leafhopper /path/to/vcpkg.json --format md --logging-level error | glow -
- use custom columns to change the column order and add an empty column called
component, which you can fill later on
leaphopper /path/to/pom.xml --columns name,component,version,license,homepage,description
- use an extra JSON file to override the information parsed from project descriptors
leaphopper /path/to/pom.xml --extra=tests/data/extra.json
- generate a combined license file so that you can put it as part of your project
leaphopper /path/to/pom.xml --combine=true
It will generate a file called LICENSES.txt with all the licenses information of the dependencies.
- [advanced] when providing both
--extraand--columns, you can get any information from the extra JSON file to be shown in the output table. For example, if you would like to add adisclosed_sourcecolumn, you can specify this property in theextra.jsonfile and specify thedisclosed_sourcecolumn in the--columnsargument.
leaphopper /path/to/vcpkg.json --extra=/extra/with/disclosed/sources/extra.json --columns name,version,homepage,license,description,disclosed_source
Supported formats
- markdown
- LaTex
- html
- json
- csv
sample output
- markdown format output
# Package Dependencies
| name |version| homepage | license | description |
|-----------------|-------|-------------------------------|----------|-------------------------------------------------------------------------|
|simdjson |2.2.0 |https://simdjson.org/ |Apache-2.0|A extremely fast JSON library that can parse gigabytes of JSON per second|
|pcre | 8.45|https://www.pcre.org/ | |Perl Compatible Regular Expressions |
|pugixml |1.12.1 |https://github.com/zeux/pugixml|MIT |Light-weight, simple and fast XML parser for C++ with XPath support |
|arrow |8.0.0 |https://arrow.apache.org |Apache-2.0|Cross-language development platform for in-memory analytics |
Supported project types
- poetry project described by
pyproject.toml - maven project described by
pom.xml- https://maven.apache.org/pom.html
pom.xmlwith or without Maven XML namespace are supported.
- vcpkg project described by
vcpkg.json - more project types such as npm will be supported in the future
Github API rating limit
If you have a really large project, you may encounter github API rate limiting. You can provide a github personal token in the environment variables to avoid this:
LEAFHOPPER_GITHUB_USERNAMELEAFHOPPER_GITHUB_PASSWORDYou can export these variables to your shell environment like this:
export LEAFHOPPER_GITHUB_USERNAME={your_github_user_name}
export LEAFHOPPER_GITHUB_PASSWORD={your_personal_token} # something like `ghp_pciFGDQlXAqDGNBXHsUbHHHZly7cf71ZKEVg`
To create a Github personal token, follow the instructions here
- Unless you need to access some private project information in Github, you can keep the personal token's permission minimal in Github since it only needs to be authencated against Github so that you can use higher the rate limit (see more details here).
Changelog
Known issues
- Some open source libraries, doesn't have the license information available in the project descriptor (or in
github.com/sourceforge.net), and the cell will be blank and you have to manually fill it.
TODO
- Support more project types, such as
npm'spackage.jsonandpip'srequirements.txt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file leafhopper-0.5.1.tar.gz.
File metadata
- Download URL: leafhopper-0.5.1.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.0 Darwin/21.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac63a26bf3b4955572d105ef6fa405ef240a639dc059dae1f871fd5f97195c1e
|
|
| MD5 |
829fe5e39a2386bdb6ab67f785438779
|
|
| BLAKE2b-256 |
cc96747965fc7ef67f8ba9229b29ccd1f4dfde9b4f6ec55da66e29562a94441c
|
File details
Details for the file leafhopper-0.5.1-py3-none-any.whl.
File metadata
- Download URL: leafhopper-0.5.1-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.0 Darwin/21.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ac91dbed4d118cc0b92e355529191e868e3e18d4afaeb2296ac1311b0a31f4a
|
|
| MD5 |
632e0d09d81cf574943240e7cb9d1755
|
|
| BLAKE2b-256 |
64f7b1aa009dbcac4708eca3344af99e3c375204a6ddbcb1de1f21bb0f6a1bba
|