Skip to content

Commit

Permalink
2023.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
FredHappyface committed Aug 30, 2023
1 parent 209d716 commit b4a564b
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All major and minor version changes will be documented in this file. Details of
patch-level version changes can be found in [commit messages](../../commits/master).

## 2023.4.3 - 2023/08/30

- Add a new flag `--skip-dependencies` which will exclude from the processing a list of the current project dependencies. Suitable for private dependencies which are only available on a private registry and not on PyPi. Thank you https://github.com/Azraeht :)

## 2023.4.2 - 2023/08/25

- Fixed Bug: handle missing urls for a pypi package https://github.com/FHPythonUtils/LicenseCheck/issues/57. Thank you https://github.com/Azraeht!
Expand Down
7 changes: 5 additions & 2 deletions documentation/reference/licensecheck/get_deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Get Deps

## getDepsWithLicenses

[Show source in get_deps.py:157](../../../licensecheck/get_deps.py#L157)
[Show source in get_deps.py:168](../../../licensecheck/get_deps.py#L168)

Get a set of dependencies with licenses and determine license compatibility.

Expand All @@ -23,6 +23,7 @@ Get a set of dependencies with licenses and determine license compatibility.
- `failPackages` *list[ucstr]* - a list of packages to fail (compat=False)
- `ignoreLicenses` *list[ucstr]* - a list of licenses to ignore (skipped, compat may still be False)
- `failLicenses` *list[ucstr]* - a list of licenses to fail (compat=False)
- `skipDependencies` *list[ucstr]* - a list of dependencies to skip (compat=False)

#### Returns

Expand All @@ -39,6 +40,7 @@ def getDepsWithLicenses(
failPackages: list[ucstr],
ignoreLicenses: list[ucstr],
failLicenses: list[ucstr],
skipDependencies: list[ucstr],
) -> tuple[License, set[PackageInfo]]:
...
```
Expand Down Expand Up @@ -69,6 +71,7 @@ Get requirements for the end user project/ lib.
#### Arguments

- `using` *str* - use requirements, poetry or PEP631.
- `skipDependencies` *list[str]* - list of dependencies to skip.

#### Returns

Expand All @@ -77,7 +80,7 @@ Get requirements for the end user project/ lib.
#### Signature

```python
def getReqs(using: str) -> set[ucstr]:
def getReqs(using: str, skipDependencies: list(ucstr)) -> set[ucstr]:
...
```

Expand Down
13 changes: 10 additions & 3 deletions licensecheck/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def cli() -> None:
parser.add_argument(
"--using",
"-u",
help="Environment to use e.g. requirements.txt. one of: " f"{', '.join(get_deps.USINGS)}. default=poetry",
help="Environment to use e.g. requirements.txt. one of: "
f"{', '.join(get_deps.USINGS)}. default=poetry",
)
parser.add_argument(
"--ignore-packages",
Expand Down Expand Up @@ -85,7 +86,11 @@ def cli() -> None:
simpleConf = SimpleConf(configparser, "licensecheck", args)

# File
filename = stdout if simpleConf.get("file") is None else open(simpleConf.get("file"), "w", encoding="utf-8")
filename = (
stdout
if simpleConf.get("file") is None
else open(simpleConf.get("file"), "w", encoding="utf-8")
)

# Get list of licenses
myLice, depsWithLicenses = get_deps.getDepsWithLicenses(
Expand All @@ -103,7 +108,9 @@ def cli() -> None:
# Format the results
if simpleConf.get("format", "simple") in formatter.formatMap:
print(
formatter.formatMap[simpleConf.get("format", "simple")](myLice, sorted(depsWithLicenses)),
formatter.formatMap[simpleConf.get("format", "simple")](
myLice, sorted(depsWithLicenses)
),
file=filename,
)
else:
Expand Down
4 changes: 3 additions & 1 deletion licensecheck/get_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def resolveExtraReq(extraReq: str) -> ucstr | None:
project = pyproject["project"]
reqLists = [project["dependencies"]]
except KeyError as error:
raise RuntimeError("Could not find specification of requirements (pyproject.toml).") from error
raise RuntimeError(
"Could not find specification of requirements (pyproject.toml)."
) from error
if extras:
reqLists.extend(project["optional-dependencies"][x] for x in extras.split(";"))
for reqList in reqLists:
Expand Down
13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "licensecheck"
version = "2023.4.2"
version = "2023.4.3"
license = "mit"
description = "Output the licenses used by dependencies and check if these are compatible with the project license"
authors = ["FredHappyface"]
Expand Down Expand Up @@ -35,11 +35,12 @@ rich = "<14,>=13.4.2"
requests-cache = "<2,>=1.1.0"
packaging = "<24,>=23.1"

[tool.poetry.dev-dependencies]
pytest = "^7.1.1"
pylint = "^2.13.5"
handsdown = "^1.1.0"
coverage = "^6.3.2"
[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
pylint = "^2.17.5"
handsdown = "^2.0.1"
fhmake = "^2023"
coverage = "^7.3.0"

[tool.black]
line-length = 100
Expand Down
18 changes: 9 additions & 9 deletions tests/data/advanced.ansi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
 
 Info 
┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
 Item   Value  
┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
┌─────────────────┬──────────────┐
 Item   Value  
├─────────────────┼──────────────┤
│ program  │ licensecheck │
│ version  │ 2023.1.3  │
│ license  │ MIT LICENSE  │
Expand All @@ -11,16 +11,16 @@
 
 List Of 
 Errors 
┏━━━━━━━━━━┓
 Package  
┡━━━━━━━━━━┩
┌──────────┐
 Package  
├──────────┤
│ example1 │
└──────────┘
 
 List Of Packages 
┏━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━┓
 Compatible  Package   License(s) 
┡━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━┩
┌────────────┬──────────┬────────────┐
 Compatible  Package   License(s) 
├────────────┼──────────┼────────────┤
│ ✔  │ example0 │ mit  │
│ ✖  │ example1 │ gpl3  │
└────────────┴──────────┴────────────┘
18 changes: 9 additions & 9 deletions tests/data/advanced.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

Info
┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
Item Value
┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
┌─────────────────┬──────────────┐
Item Value
├─────────────────┼──────────────┤
│ program │ licensecheck │
│ version │ 2023.1.3 │
│ license │ MIT LICENSE │
Expand All @@ -11,16 +11,16 @@

List Of
Errors
┏━━━━━━━━━━┓
Package
┡━━━━━━━━━━┩
┌──────────┐
Package
├──────────┤
│ example1 │
└──────────┘

List Of Packages
┏━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━┓
Compatible Package License(s)
┡━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━┩
┌────────────┬──────────┬────────────┐
Compatible Package License(s)
├────────────┼──────────┼────────────┤
│ ✔ │ example0 │ mit │
│ ✖ │ example1 │ gpl3 │
└────────────┴──────────┴────────────┘
12 changes: 6 additions & 6 deletions tests/data/simple.ansi
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
 
 Info 
┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
 Item   Value  
┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
┌─────────────────┬──────────────┐
 Item   Value  
├─────────────────┼──────────────┤
│ program  │ licensecheck │
│ version  │ 2023.1.3  │
│ license  │ MIT LICENSE  │
│ project_license │ MIT LICENSE  │
└─────────────────┴──────────────┘
 
 List Of Packages 
┏━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━┓
 Compatible  Package  License(s) 
┡━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━┩
┌────────────┬─────────┬────────────┐
 Compatible  Package  License(s) 
├────────────┼─────────┼────────────┤
│ ✖  │ example │ UNKNOWN  │
└────────────┴─────────┴────────────┘
12 changes: 6 additions & 6 deletions tests/data/simple.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

Info
┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
Item Value
┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
┌─────────────────┬──────────────┐
Item Value
├─────────────────┼──────────────┤
│ program │ licensecheck │
│ version │ 2023.1.3 │
│ license │ MIT LICENSE │
│ project_license │ MIT LICENSE │
└─────────────────┴──────────────┘

List Of Packages
┏━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━┓
Compatible Package License(s)
┡━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━┩
┌────────────┬─────────┬────────────┐
Compatible Package License(s)
├────────────┼─────────┼────────────┤
│ ✖ │ example │ UNKNOWN │
└────────────┴─────────┴────────────┘
2 changes: 1 addition & 1 deletion tests/test_get_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_doGetReqs_requirements():
pyproject = {}
requirementsPaths = [Path(f"{THISDIR}/data/test_requirements.txt")]
skipDependencies = ["TOSKIP"]

deps = get_deps._doGetReqs(using, skipDependencies, extras, pyproject, requirementsPaths)
assert deps == {
"NUMPY",
Expand Down

0 comments on commit b4a564b

Please sign in to comment.