# license_scanner
[](https://pepy.tech/project/license-scanner)
Find all licenses needed by the package in your python environment.
It will sort all package by license.
Install by pip
```cmd
pip install license_scanner
```
Usage
```cmd
license_scanner
```

## Check within you pipeline
You can make your pipeline fail if a project does not have the correct licenses.
To do so create a `pyproject.toml` and add underneath `tool.license_scanner` two lists `allowed-licenses` and `allowed-packages`.
If a package does not have license in `allowed-licenses` AND it is not in `allowed-packages` it will throw an error.
```toml
[tool.license_scanner]
allowed-licenses = [
"MIT",
"apache software license",
"apache software license v2",
"apache software license v3",
"BSD license",
"BSD 3-clause license",
'GNU lesser general public license',
'GNU lesser general public license v2',
'GNU lesser general public license v3',
'Python software foundation license',
'Mozilla public license 2.0 (mpl 2.0)',
'mozilla',
]
allowed-packages = ["license_scanner"]
```
To run the license scanner make sure you are in the same directory as `pyproject.toml` and run `license_scanner -m whitelist` or `python -m license_scanner -m whitelist`.
It will now throw you an error if your environment has an package with a license you did not approve of.
### Example: Github actions
This github actions triggers every time you make a PR to the main branch. With `pip install .` it installs the current project, next it installs `license_scanner`, and lastly it runs the check.
Be aware, if you want to do unittest make sure you install `pytest` AFTER you run license_scanner. Otherwise `pytest` is in your environment when you check for unwanted licenses.
```yaml
name: Licenses check
on:
pull_request:
branches:
- main
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Check for licenses
run: |
python -m pip install --upgrade pip
pip install .
pip install license_scanner
python -m license_scanner -m whitelist
```
## Supported licenses
- Apache license
- Apache license 1.0
- Apache license 2.0
- Azure License
- BSD license
- BSD 0-clause license
- BSD 2-clause license
- BSD 3-clause license
- BSD 4-clause license
- Creative Commons Zero, CC-0
- Eclipse public license 1.0 (epl-1.0)
- Eclipse public license 2.0 (epl-2.0)
- GNU Affero general public license (apl)
- GNU Affero general public license v3 (aplv3)
- GNU lesser general public license
- GNU lesser general public license v2 (lgplv2)
- GNU lesser general public license v3 (lgplv3)
- GNU general public license
- GNU general public license v2 (gplv2)
- GNU general public license v3 (gplv3)
- Historical Permission Notice and Disclaimer (HPND)
- ISC license (iscl)
- MIT license
- MIT No Attribution
- Mozilla public license (mpl)
- Mozilla public license 2.0 (mpl 2.0)
- Public domain
- Python software foundation license
- Repoze public license
- The Unlicense (Unlicense)
- DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
- Zope Public License
- Zope Public License v1
- Zope Public License v2
# Credits
- Tom Nijhof
Raw data
{
"_id": null,
"home_page": null,
"name": "license-scanner",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "checker, license, scanner",
"author": null,
"author_email": "Tom Nijhof <tomsspamadress@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/0d/63/093a49cead1a5310b222cd4c45c42de609f50c80eece4f1842b4f2d9dbdc/license_scanner-0.2.7.tar.gz",
"platform": null,
"description": "# license_scanner\n\n[](https://pepy.tech/project/license-scanner)\n\nFind all licenses needed by the package in your python environment.\nIt will sort all package by license.\n\nInstall by pip\n\n```cmd\npip install license_scanner\n```\n\nUsage\n\n```cmd\nlicense_scanner\n```\n\n\n\n## Check within you pipeline\n\nYou can make your pipeline fail if a project does not have the correct licenses.\nTo do so create a `pyproject.toml` and add underneath `tool.license_scanner` two lists `allowed-licenses` and `allowed-packages`.\nIf a package does not have license in `allowed-licenses` AND it is not in `allowed-packages` it will throw an error.\n\n```toml\n[tool.license_scanner]\nallowed-licenses = [\n \"MIT\",\n \"apache software license\",\n \"apache software license v2\",\n \"apache software license v3\",\n \"BSD license\",\n \"BSD 3-clause license\",\n 'GNU lesser general public license',\n 'GNU lesser general public license v2',\n 'GNU lesser general public license v3',\n 'Python software foundation license',\n 'Mozilla public license 2.0 (mpl 2.0)',\n 'mozilla',\n]\nallowed-packages = [\"license_scanner\"]\n```\n\nTo run the license scanner make sure you are in the same directory as `pyproject.toml` and run `license_scanner -m whitelist` or `python -m license_scanner -m whitelist`. \nIt will now throw you an error if your environment has an package with a license you did not approve of.\n\n### Example: Github actions\n\nThis github actions triggers every time you make a PR to the main branch. With `pip install .` it installs the current project, next it installs `license_scanner`, and lastly it runs the check.\n\nBe aware, if you want to do unittest make sure you install `pytest` AFTER you run license_scanner. Otherwise `pytest` is in your environment when you check for unwanted licenses.\n\n```yaml\nname: Licenses check\n\non:\n pull_request:\n branches:\n - main\n\npermissions:\n contents: read\n\njobs:\n deploy:\n\n runs-on: ubuntu-latest\n\n steps:\n - uses: actions/checkout@v3\n - name: Set up Python\n uses: actions/setup-python@v3\n with:\n python-version: '3.x'\n - name: Check for licenses\n run: |\n python -m pip install --upgrade pip\n pip install .\n pip install license_scanner\n python -m license_scanner -m whitelist\n\n```\n\n## Supported licenses\n\n- Apache license\n- Apache license 1.0\n- Apache license 2.0\n- Azure License\n- BSD license\n- BSD 0-clause license\n- BSD 2-clause license\n- BSD 3-clause license\n- BSD 4-clause license\n- Creative Commons Zero, CC-0\n- Eclipse public license 1.0 (epl-1.0)\n- Eclipse public license 2.0 (epl-2.0)\n- GNU Affero general public license (apl)\n- GNU Affero general public license v3 (aplv3)\n- GNU lesser general public license\n- GNU lesser general public license v2 (lgplv2)\n- GNU lesser general public license v3 (lgplv3)\n- GNU general public license\n- GNU general public license v2 (gplv2)\n- GNU general public license v3 (gplv3)\n- Historical Permission Notice and Disclaimer (HPND)\n- ISC license (iscl)\n- MIT license\n- MIT No Attribution\n- Mozilla public license (mpl)\n- Mozilla public license 2.0 (mpl 2.0)\n- Public domain\n- Python software foundation license\n- Repoze public license\n- The Unlicense (Unlicense)\n- DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE\n- Zope Public License\n- Zope Public License v1\n- Zope Public License v2\n# Credits\n\n- Tom Nijhof\n",
"bugtrack_url": null,
"license": "MIT",
"summary": null,
"version": "0.2.7",
"project_urls": null,
"split_keywords": [
"checker",
" license",
" scanner"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "21f40d46bb710e8ff26dd7373188ef1c3bec8ba317b84883a675af004c08e272",
"md5": "0532bb89b677554eb30b4fee2626f4f2",
"sha256": "5fa57a85a11a2232eb6f96c308ab0bc98e4bc86e039fded39a40c28a94b07227"
},
"downloads": -1,
"filename": "license_scanner-0.2.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0532bb89b677554eb30b4fee2626f4f2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 8999,
"upload_time": "2024-10-23T12:54:28",
"upload_time_iso_8601": "2024-10-23T12:54:28.792592Z",
"url": "https://files.pythonhosted.org/packages/21/f4/0d46bb710e8ff26dd7373188ef1c3bec8ba317b84883a675af004c08e272/license_scanner-0.2.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0d63093a49cead1a5310b222cd4c45c42de609f50c80eece4f1842b4f2d9dbdc",
"md5": "666be10813f510c6c11bbe67f736f228",
"sha256": "978744a1024b19cd6a6eb23c2d6dc371bd3d46e38f2067622c2b985bea3187b6"
},
"downloads": -1,
"filename": "license_scanner-0.2.7.tar.gz",
"has_sig": false,
"md5_digest": "666be10813f510c6c11bbe67f736f228",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 8898068,
"upload_time": "2024-10-23T12:54:30",
"upload_time_iso_8601": "2024-10-23T12:54:30.685441Z",
"url": "https://files.pythonhosted.org/packages/0d/63/093a49cead1a5310b222cd4c45c42de609f50c80eece4f1842b4f2d9dbdc/license_scanner-0.2.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-23 12:54:30",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "license-scanner"
}