license-reporter


Namelicense-reporter JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryUniversal Python License Report Generator for dependency compliance analysis
upload_time2025-08-04 03:26:04
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT License Copyright (c) 2025 Ethan Li Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords attribution compliance dependencies legal license packages pyinstaller third-party
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # License Reporter

[![PyPI version](https://badge.fury.io/py/license-reporter.svg)](https://badge.fury.io/py/license-reporter)
[![Python Support](https://img.shields.io/pypi/pyversions/license-reporter.svg)](https://pypi.org/project/license-reporter/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Tests](https://github.com/yourusername/license-reporter/workflows/Tests/badge.svg)](https://github.com/yourusername/license-reporter/actions)
[![Coverage](https://codecov.io/gh/yourusername/license-reporter/branch/main/graph/badge.svg)](https://codecov.io/gh/yourusername/license-reporter)

A comprehensive, project-agnostic tool for analyzing Python project dependencies and generating license compliance reports. Perfect for legal compliance, security audits, and understanding your project's dependency landscape.

## Features

- **Universal Compatibility**: Supports multiple dependency specification formats:
  - `requirements.txt` (and variants like `dev-requirements.txt`)
  - `setup.py` and `setup.cfg`
  - `pyproject.toml` (PEP 621 and Poetry formats)
  - `Pipfile` (Pipenv)
  - `environment.yml` (Conda)

- **Intelligent Dependency Classification**: Automatically distinguishes between:
  - Runtime dependencies
  - Development dependencies
  - Optional dependencies
  - Build-time tools

- **Multiple Output Formats**: Generate reports in:
  - Human-readable text
  - JSON for programmatic processing
  - Markdown for documentation

- **Smart Deduplication**:
  - Automatically removes duplicate packages from multiple dependency files
  - Preserves the most specific version constraints
  - Prioritizes runtime dependencies over development dependencies
  - Maintains transparency about dependency sources

- **Advanced Filtering**:
  - Include/exclude development dependencies
  - Runtime-only mode for PyInstaller compliance
  - Pattern-based package exclusion
  - Build tool filtering

- **License Analysis**:
  - Automatic license detection
  - Attribution requirement analysis
  - Unknown license identification

## Installation

### From PyPI (Recommended)

```bash
pip install license-reporter
```

### From Source

```bash
git clone https://github.com/yourusername/license-reporter.git
cd license-reporter
pip install -e .
```

### With Optional Dependencies

For enhanced functionality with YAML files:

```bash
pip install license-reporter[enhanced]
```

**Note**: TOML support is now included by default since `pyproject.toml` is the standard for modern Python projects.

For development:

```bash
pip install license-reporter[dev]
```

## Quick Start

### Basic Usage

```bash
# Analyze current directory
license-reporter

# Analyze specific project
license-reporter /path/to/project

# Generate JSON report
license-reporter --format json --output licenses.json
```

### Common Use Cases

#### PyInstaller Compliance Report

Generate a report of only the packages that will be bundled with your PyInstaller executable:

```bash
license-reporter --runtime-only --format text --output THIRD_PARTY_LICENSES.txt
```

#### Complete Project Analysis

Include all dependencies (runtime, development, and optional):

```bash
license-reporter --all-deps --format markdown --output LICENSE_REPORT.md
```

#### Exclude Test Dependencies

```bash
license-reporter --exclude "test*,pytest*,mock*" --format json
```

## Command Line Options

```
usage: license-reporter [-h] [--format {text,json,markdown}] [--output OUTPUT]
                        [--include-dev] [--include-optional] [--runtime-only]
                        [--all-deps] [--exclude EXCLUDE] [--project-name PROJECT_NAME]
                        [--legacy-mode]
                        [project_path]

positional arguments:
  project_path          Path to project directory (default: current directory)

optional arguments:
  -h, --help            show this help message and exit
  --format {text,json,markdown}
                        Output format (default: text)
  --output OUTPUT, -o OUTPUT
                        Output file (default: stdout)
  --include-dev         Include development dependencies
  --include-optional    Include optional dependencies
  --runtime-only        Include only runtime dependencies (PyInstaller compliance mode)
  --all-deps            Include all dependencies (runtime + dev + optional)
  --exclude EXCLUDE     Comma-separated list of package patterns to exclude (supports wildcards)
  --project-name PROJECT_NAME
                        Override detected project name
  --legacy-mode         Use legacy OSI-specific behavior for backward compatibility
```

## Python API

### Basic Usage

```python
from license_reporter import LicenseReporter

# Create reporter for current directory
reporter = LicenseReporter()

# Generate report
report = reporter.generate_report(
    include_dev=True,
    runtime_only=False,
    exclude_patterns=["test*"]
)

# Access report data
print(f"Found {report['summary']['total_packages']} packages")
for package in report['packages']:
    print(f"{package['name']}: {package['license']}")
```

### Advanced Usage

```python
from pathlib import Path
from license_reporter import LicenseReporter
from license_reporter.formatters import get_formatter

# Analyze specific project
project_path = Path("/path/to/project")
reporter = LicenseReporter(project_path)

# Generate comprehensive report
report = reporter.generate_report(
    include_dev=True,
    include_optional=True,
    exclude_patterns=["*test*", "dev-*"],
    project_name="My Project"
)

# Format as Markdown
formatter = get_formatter("markdown")
markdown_output = formatter.format(report)

# Save to file
with open("LICENSE_REPORT.md", "w") as f:
    f.write(markdown_output)
```

## Report Structure

The generated reports include:

- **Project Information**: Name, path, analysis type
- **Summary Statistics**: Package counts, attribution requirements
- **Dependency Files**: List of analyzed files
- **Package Details**: For each dependency:
  - Name and version
  - License information
  - Author and homepage
  - Attribution requirements
  - Dependency type (runtime/dev/optional)

## Smart Deduplication

When your project has multiple dependency files (e.g., both `requirements.txt` and `pyproject.toml`), License Reporter automatically deduplicates packages that appear in multiple files. The deduplication logic:

1. **Combines packages from all sources**: Analyzes all discovered dependency files
2. **Removes duplicates by package name**: Case-insensitive matching
3. **Preserves the most specific version**: Prioritizes exact versions (`==`) over ranges (`>=`)
4. **Maintains dependency type priority**: Runtime dependencies take precedence over dev/optional
5. **Tracks source information**: Reports which files were analyzed

### Example

If you have:
- `requirements.txt`: `requests>=2.25.0`
- `pyproject.toml`: `requests>=2.30.0`

The final report will contain only one `requests` entry with version `>=2.30.0` (the more restrictive constraint).

## Supported File Formats

### requirements.txt
```
requests>=2.25.0
click>=8.0.0
# Comments are ignored
-e git+https://github.com/user/repo.git#egg=package  # Ignored
```

### pyproject.toml (PEP 621)
```toml
[project]
dependencies = [
    "requests>=2.25.0",
    "click>=8.0.0"
]

[project.optional-dependencies]
dev = ["pytest>=7.0.0"]
```

### pyproject.toml (Poetry)
```toml
[tool.poetry.dependencies]
python = "^3.8"
requests = "^2.25.0"

[tool.poetry.dev-dependencies]
pytest = "^7.0.0"
```

### setup.py
```python
setup(
    name="my-project",
    install_requires=[
        "requests>=2.25.0",
        "click>=8.0.0"
    ],
    extras_require={
        "dev": ["pytest>=7.0.0"]
    }
)
```

## Contributing

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

### Development Setup

```bash
git clone https://github.com/yourusername/license-reporter.git
cd license-reporter
pip install -e .[dev]
pre-commit install
```

### Running Tests

```bash
pytest
```

### Code Quality

```bash
black src tests
isort src tests
flake8 src tests
mypy src
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Changelog

See [CHANGELOG.md](CHANGELOG.md) for a history of changes.

## Support

- **Issues**: [GitHub Issues](https://github.com/yourusername/license-reporter/issues)
- **Documentation**: [Read the Docs](https://license-reporter.readthedocs.io)
- **Discussions**: [GitHub Discussions](https://github.com/yourusername/license-reporter/discussions)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "license-reporter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "Ethan Li <aeon.zheng.li@gmail.com>",
    "keywords": "attribution, compliance, dependencies, legal, license, packages, pyinstaller, third-party",
    "author": null,
    "author_email": "Ethan Li <aeon.zheng.li@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/2a/b7/f55c18e233a11e6914c8d3f6600fe19725f046ce88693a00bc2e7ca4c319/license_reporter-1.0.1.tar.gz",
    "platform": null,
    "description": "# License Reporter\n\n[![PyPI version](https://badge.fury.io/py/license-reporter.svg)](https://badge.fury.io/py/license-reporter)\n[![Python Support](https://img.shields.io/pypi/pyversions/license-reporter.svg)](https://pypi.org/project/license-reporter/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Tests](https://github.com/yourusername/license-reporter/workflows/Tests/badge.svg)](https://github.com/yourusername/license-reporter/actions)\n[![Coverage](https://codecov.io/gh/yourusername/license-reporter/branch/main/graph/badge.svg)](https://codecov.io/gh/yourusername/license-reporter)\n\nA comprehensive, project-agnostic tool for analyzing Python project dependencies and generating license compliance reports. Perfect for legal compliance, security audits, and understanding your project's dependency landscape.\n\n## Features\n\n- **Universal Compatibility**: Supports multiple dependency specification formats:\n  - `requirements.txt` (and variants like `dev-requirements.txt`)\n  - `setup.py` and `setup.cfg`\n  - `pyproject.toml` (PEP 621 and Poetry formats)\n  - `Pipfile` (Pipenv)\n  - `environment.yml` (Conda)\n\n- **Intelligent Dependency Classification**: Automatically distinguishes between:\n  - Runtime dependencies\n  - Development dependencies\n  - Optional dependencies\n  - Build-time tools\n\n- **Multiple Output Formats**: Generate reports in:\n  - Human-readable text\n  - JSON for programmatic processing\n  - Markdown for documentation\n\n- **Smart Deduplication**:\n  - Automatically removes duplicate packages from multiple dependency files\n  - Preserves the most specific version constraints\n  - Prioritizes runtime dependencies over development dependencies\n  - Maintains transparency about dependency sources\n\n- **Advanced Filtering**:\n  - Include/exclude development dependencies\n  - Runtime-only mode for PyInstaller compliance\n  - Pattern-based package exclusion\n  - Build tool filtering\n\n- **License Analysis**:\n  - Automatic license detection\n  - Attribution requirement analysis\n  - Unknown license identification\n\n## Installation\n\n### From PyPI (Recommended)\n\n```bash\npip install license-reporter\n```\n\n### From Source\n\n```bash\ngit clone https://github.com/yourusername/license-reporter.git\ncd license-reporter\npip install -e .\n```\n\n### With Optional Dependencies\n\nFor enhanced functionality with YAML files:\n\n```bash\npip install license-reporter[enhanced]\n```\n\n**Note**: TOML support is now included by default since `pyproject.toml` is the standard for modern Python projects.\n\nFor development:\n\n```bash\npip install license-reporter[dev]\n```\n\n## Quick Start\n\n### Basic Usage\n\n```bash\n# Analyze current directory\nlicense-reporter\n\n# Analyze specific project\nlicense-reporter /path/to/project\n\n# Generate JSON report\nlicense-reporter --format json --output licenses.json\n```\n\n### Common Use Cases\n\n#### PyInstaller Compliance Report\n\nGenerate a report of only the packages that will be bundled with your PyInstaller executable:\n\n```bash\nlicense-reporter --runtime-only --format text --output THIRD_PARTY_LICENSES.txt\n```\n\n#### Complete Project Analysis\n\nInclude all dependencies (runtime, development, and optional):\n\n```bash\nlicense-reporter --all-deps --format markdown --output LICENSE_REPORT.md\n```\n\n#### Exclude Test Dependencies\n\n```bash\nlicense-reporter --exclude \"test*,pytest*,mock*\" --format json\n```\n\n## Command Line Options\n\n```\nusage: license-reporter [-h] [--format {text,json,markdown}] [--output OUTPUT]\n                        [--include-dev] [--include-optional] [--runtime-only]\n                        [--all-deps] [--exclude EXCLUDE] [--project-name PROJECT_NAME]\n                        [--legacy-mode]\n                        [project_path]\n\npositional arguments:\n  project_path          Path to project directory (default: current directory)\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --format {text,json,markdown}\n                        Output format (default: text)\n  --output OUTPUT, -o OUTPUT\n                        Output file (default: stdout)\n  --include-dev         Include development dependencies\n  --include-optional    Include optional dependencies\n  --runtime-only        Include only runtime dependencies (PyInstaller compliance mode)\n  --all-deps            Include all dependencies (runtime + dev + optional)\n  --exclude EXCLUDE     Comma-separated list of package patterns to exclude (supports wildcards)\n  --project-name PROJECT_NAME\n                        Override detected project name\n  --legacy-mode         Use legacy OSI-specific behavior for backward compatibility\n```\n\n## Python API\n\n### Basic Usage\n\n```python\nfrom license_reporter import LicenseReporter\n\n# Create reporter for current directory\nreporter = LicenseReporter()\n\n# Generate report\nreport = reporter.generate_report(\n    include_dev=True,\n    runtime_only=False,\n    exclude_patterns=[\"test*\"]\n)\n\n# Access report data\nprint(f\"Found {report['summary']['total_packages']} packages\")\nfor package in report['packages']:\n    print(f\"{package['name']}: {package['license']}\")\n```\n\n### Advanced Usage\n\n```python\nfrom pathlib import Path\nfrom license_reporter import LicenseReporter\nfrom license_reporter.formatters import get_formatter\n\n# Analyze specific project\nproject_path = Path(\"/path/to/project\")\nreporter = LicenseReporter(project_path)\n\n# Generate comprehensive report\nreport = reporter.generate_report(\n    include_dev=True,\n    include_optional=True,\n    exclude_patterns=[\"*test*\", \"dev-*\"],\n    project_name=\"My Project\"\n)\n\n# Format as Markdown\nformatter = get_formatter(\"markdown\")\nmarkdown_output = formatter.format(report)\n\n# Save to file\nwith open(\"LICENSE_REPORT.md\", \"w\") as f:\n    f.write(markdown_output)\n```\n\n## Report Structure\n\nThe generated reports include:\n\n- **Project Information**: Name, path, analysis type\n- **Summary Statistics**: Package counts, attribution requirements\n- **Dependency Files**: List of analyzed files\n- **Package Details**: For each dependency:\n  - Name and version\n  - License information\n  - Author and homepage\n  - Attribution requirements\n  - Dependency type (runtime/dev/optional)\n\n## Smart Deduplication\n\nWhen your project has multiple dependency files (e.g., both `requirements.txt` and `pyproject.toml`), License Reporter automatically deduplicates packages that appear in multiple files. The deduplication logic:\n\n1. **Combines packages from all sources**: Analyzes all discovered dependency files\n2. **Removes duplicates by package name**: Case-insensitive matching\n3. **Preserves the most specific version**: Prioritizes exact versions (`==`) over ranges (`>=`)\n4. **Maintains dependency type priority**: Runtime dependencies take precedence over dev/optional\n5. **Tracks source information**: Reports which files were analyzed\n\n### Example\n\nIf you have:\n- `requirements.txt`: `requests>=2.25.0`\n- `pyproject.toml`: `requests>=2.30.0`\n\nThe final report will contain only one `requests` entry with version `>=2.30.0` (the more restrictive constraint).\n\n## Supported File Formats\n\n### requirements.txt\n```\nrequests>=2.25.0\nclick>=8.0.0\n# Comments are ignored\n-e git+https://github.com/user/repo.git#egg=package  # Ignored\n```\n\n### pyproject.toml (PEP 621)\n```toml\n[project]\ndependencies = [\n    \"requests>=2.25.0\",\n    \"click>=8.0.0\"\n]\n\n[project.optional-dependencies]\ndev = [\"pytest>=7.0.0\"]\n```\n\n### pyproject.toml (Poetry)\n```toml\n[tool.poetry.dependencies]\npython = \"^3.8\"\nrequests = \"^2.25.0\"\n\n[tool.poetry.dev-dependencies]\npytest = \"^7.0.0\"\n```\n\n### setup.py\n```python\nsetup(\n    name=\"my-project\",\n    install_requires=[\n        \"requests>=2.25.0\",\n        \"click>=8.0.0\"\n    ],\n    extras_require={\n        \"dev\": [\"pytest>=7.0.0\"]\n    }\n)\n```\n\n## Contributing\n\nWe welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n### Development Setup\n\n```bash\ngit clone https://github.com/yourusername/license-reporter.git\ncd license-reporter\npip install -e .[dev]\npre-commit install\n```\n\n### Running Tests\n\n```bash\npytest\n```\n\n### Code Quality\n\n```bash\nblack src tests\nisort src tests\nflake8 src tests\nmypy src\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for a history of changes.\n\n## Support\n\n- **Issues**: [GitHub Issues](https://github.com/yourusername/license-reporter/issues)\n- **Documentation**: [Read the Docs](https://license-reporter.readthedocs.io)\n- **Discussions**: [GitHub Discussions](https://github.com/yourusername/license-reporter/discussions)\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 Ethan Li\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "Universal Python License Report Generator for dependency compliance analysis",
    "version": "1.0.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/yourusername/license-reporter/issues",
        "Changelog": "https://github.com/yourusername/license-reporter/blob/main/CHANGELOG.md",
        "Documentation": "https://license-reporter.readthedocs.io",
        "Homepage": "https://github.com/yourusername/license-reporter",
        "Repository": "https://github.com/yourusername/license-reporter.git"
    },
    "split_keywords": [
        "attribution",
        " compliance",
        " dependencies",
        " legal",
        " license",
        " packages",
        " pyinstaller",
        " third-party"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bf9d3e306611179303c349195c4742445eca5d1ca48395be1f0f3857ef2ca082",
                "md5": "18f0d40ebbd606f71720d1aad42de797",
                "sha256": "cc72a15a3eedd5bad7726adfb81d8ef461daa9ba4fd9d93057ebe788bdae7902"
            },
            "downloads": -1,
            "filename": "license_reporter-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "18f0d40ebbd606f71720d1aad42de797",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 19958,
            "upload_time": "2025-08-04T03:26:04",
            "upload_time_iso_8601": "2025-08-04T03:26:04.036973Z",
            "url": "https://files.pythonhosted.org/packages/bf/9d/3e306611179303c349195c4742445eca5d1ca48395be1f0f3857ef2ca082/license_reporter-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2ab7f55c18e233a11e6914c8d3f6600fe19725f046ce88693a00bc2e7ca4c319",
                "md5": "d91c2488cdc43fda842344c0f0d995dc",
                "sha256": "54b27128b264019311ac44733250b8c27a058425bb545260fcf8a3c957424d4a"
            },
            "downloads": -1,
            "filename": "license_reporter-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d91c2488cdc43fda842344c0f0d995dc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 28459,
            "upload_time": "2025-08-04T03:26:04",
            "upload_time_iso_8601": "2025-08-04T03:26:04.963234Z",
            "url": "https://files.pythonhosted.org/packages/2a/b7/f55c18e233a11e6914c8d3f6600fe19725f046ce88693a00bc2e7ca4c319/license_reporter-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-04 03:26:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "license-reporter",
    "github_not_found": true,
    "lcname": "license-reporter"
}
        
Elapsed time: 0.40837s