Skip to content

Commit

Permalink
Use pip to get Python dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
waynebeaton committed Jul 9, 2024
1 parent 4e8bf93 commit 14ac4fb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,23 @@ Note that, in order to better leverage ClearlyDefined data, the "v" should **not

### Example Python

Use the `requirements.txt` file that's generated by the compiler to check dependencies:
You can use `pip` and a `requirements.txt` (or similar) file to check Python dependencies:

```
pip install -r requirements.txt --dry-run \
| grep -Poh "(?<=^Would install ).*$" | grep -oP '[^\s]+' \
| sed -E -e 's|(.+)\-([a-zA-Z0-9\.]+)|pypi/pypi/-/\1/\2|' \
| java -jar/dash-licenses/org.eclipse.dash.licenses-<version>.jar -
````

Steps:

1. Do a dry-run install with `pip` feeding it with your requirements file;
2. Extract the "Would install" line from the results and dump the libraries on separate lines;
3. Map each line to a ClearlyDefined ID; and
4. Invoke the tool.

Very often, you can get away with `grep`ing the `requirements.txt` file check dependencies (if there's some reason why you can't use `pip`):

```
cat requirements.txt | grep -v \# \
Expand Down

0 comments on commit 14ac4fb

Please sign in to comment.