{"id":50974910,"url":"https://github.com/eznix86/python-license","last_synced_at":"2026-06-19T06:33:04.638Z","repository":{"id":320901064,"uuid":"1083711206","full_name":"eznix86/python-license","owner":"eznix86","description":"Automatically adds or updates SPDX license and copyright headers in source files. ","archived":false,"fork":false,"pushed_at":"2025-10-26T16:34:04.000Z","size":52,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-26T17:37:46.063Z","etag":null,"topics":["license","pre-commit","spdx-license"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eznix86.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-26T15:17:52.000Z","updated_at":"2025-10-26T16:34:07.000Z","dependencies_parsed_at":"2025-10-26T17:37:51.414Z","dependency_job_id":null,"html_url":"https://github.com/eznix86/python-license","commit_stats":null,"previous_names":["eznix86/python-license"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/eznix86/python-license","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eznix86%2Fpython-license","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eznix86%2Fpython-license/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eznix86%2Fpython-license/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eznix86%2Fpython-license/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eznix86","download_url":"https://codeload.github.com/eznix86/python-license/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eznix86%2Fpython-license/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34520431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["license","pre-commit","spdx-license"],"created_at":"2026-06-19T06:33:03.917Z","updated_at":"2026-06-19T06:33:04.626Z","avatar_url":"https://github.com/eznix86.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python License\n\n[![PyPI version](https://badge.fury.io/py/python-license.svg)](https://badge.fury.io/py/python-license)\n[![Python versions](https://img.shields.io/pypi/pyversions/python-license.svg)](https://pypi.org/project/python-license/)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Tests](https://github.com/eznix86/python-license/workflows/Tests/badge.svg)](https://github.com/eznix86/python-license/actions)\n\nOne command to add SPDX license headers to all your source files. Works best with pre-commit hooks.\n\n## What It Does\n\nAutomatically adds SPDX-compliant license headers to your source files.\n\n**For Python files:**\n```python\n# SPDX-License-Identifier: Apache-2.0\n# Copyright (C) 2025  Your Name\n\ndef your_code():\n    pass\n```\n\n**For JavaScript/TypeScript/Go/Rust:**\n```javascript\n// SPDX-License-Identifier: MIT\n// Copyright (C) 2025  Your Company\n\nfunction yourCode() {}\n```\n\n**For CSS:**\n```css\n/*\n * SPDX-License-Identifier: Apache-2.0\n * Copyright (C) 2025  Your Name\n*/\n\nbody { margin: 0; }\n```\n\n**For HTML/Vue:**\n```html\n\u003c!--\nSPDX-License-Identifier: Apache-2.0\nCopyright (C) 2025  Your Name\n--\u003e\n\n\u003c!DOCTYPE html\u003e\n```\n\n### Key Features\n\n- Supports 50+ file types including Python, JavaScript, TypeScript, Go, Rust, Java, C/C++, Swift, Kotlin, Ruby, Shell, SQL, Vue, and more\n- Custom notice templates for extended license information (e.g., AGPL, GPL notices)\n- Automatically updates copyright year ranges (e.g., `2023` becomes `2023-2025` when modified)\n- Check mode for CI/CD integration to ensure all files have headers\n- Respects `.licenseignore` and `.gitignore` files automatically\n- Preserves shebang lines in executable scripts\n- Handles multiple comment styles (hash, slash, dash, block comments)\n\n## Supported Languages\n\n**Hash comments (#):** Python, Shell (bash/zsh/fish), Ruby, Perl, R, YAML, TOML, CMake\n\n**Slash comments (//):** JavaScript, TypeScript, Go, Rust, Java, C/C++, Swift, Kotlin, C#, PHP, Scala, Objective-C, Gradle, Groovy, SCSS, Sass, Less\n\n**Dash comments (--):** SQL, Lua, Haskell, Elm\n\n**Block comments:** CSS (`/* */`), HTML/XML/SVG/Vue (`\u003c!-- --\u003e`)\n\n**Special files:** Dockerfile, Makefile, Jenkinsfile, Vagrantfile, Rakefile, Gemfile, Podfile, Fastfile, CMakeLists.txt, and more\n\n## Installation\n\n```sh\npipx install python-license\n```\n\nOr with pip:\n```sh\npip install python-license\n```\n\n## Usage\n\n### Command Line\n\nBasic syntax:\n```sh\nlicense [options] \u003clicense-id\u003e \"\u003cauthor\u003e\"\n```\n\nExamples:\n```sh\n# Check files without modifying (dry-run)\nlicense --check Apache-2.0 \"John Doe\"\n\n# Add/update headers in specific directory\nlicense --fix MIT \"Jane Smith\" --dir src/\n\n# Use custom ignore file\nlicense --ignore-file .licenseignore --fix GPL-3.0 \"ACME Corp\"\n\n# Process specific files only\nlicense --fix Apache-2.0 \"Your Name\" file1.py file2.js\n\n# Set custom copyright year\nlicense --fix --year 2024 MIT \"Your Company\"\n\n# Add extended notice (e.g., for AGPL, GPL licenses)\nlicense --fix --notice-template NOTICE.template AGPL-3.0-or-later \"Your Name\"\n```\n\n### Pre-commit Hook (Recommended)\n\nAdd to your `.pre-commit-config.yaml`:\n\n```yaml\nrepos:\n  - repo: https://github.com/eznix86/python-license\n    rev: v1.0.1\n    hooks:\n      - id: license-headers\n        args: ['--check', 'Apache-2.0', 'Your Name']\n```\n\nFor automatic fixing on commit:\n```yaml\nrepos:\n  - repo: https://github.com/eznix86/python-license\n    rev: v1.0.1\n    hooks:\n      - id: license-headers\n        args: ['--fix', 'Apache-2.0', 'Your Name']\n```\n\nSee [.pre-commit-config.yaml](./.pre-commit-config.yaml) for a complete example.\n\n### Options\n\n| Option | Description |\n|--------|-------------|\n| `--check` | Check files without modifying (default mode) |\n| `--fix` | Add or update headers in files |\n| `--dir DIR` | Root directory to process (default: current directory) |\n| `--year YEAR` | Copyright year (default: current year) |\n| `--no-recursive` | Don't process subdirectories |\n| `--verbose`, `-v` | Show all processed files |\n| `--ignore-file FILE` | Path to ignore file (default: .licenseignore or .gitignore) |\n| `--notice-template FILE` | Path to notice template file to append after copyright |\n| `files` | Specific files to process (overrides --dir) |\n\n### Notice Templates\n\nFor licenses that require extended notices (like AGPL, GPL), create a template file:\n\n**NOTICE.template:**\n```\nThis file is part of Your Project.\n\nYour Project is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nSee the LICENSE file for more details.\n```\n\nThen use it with:\n```sh\nlicense --fix --notice-template NOTICE.template AGPL-3.0-or-later \"Your Name\"\n```\n\n**Result:**\n```javascript\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025  Your Name\n//\n// This file is part of Your Project.\n//\n// Your Project is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// See the LICENSE file for more details.\n```\n\n### Ignore Files\n\nCreate a `.licenseignore` file to exclude specific files or directories:\n\n```\n# Ignore patterns (similar to .gitignore)\n*.min.js\n*.min.css\ngenerated/*\nvendor/\nthird_party/\nbuild/\ndist/\n\n# Negate patterns (don't ignore these)\n!important.min.js\n```\n\nIf no `.licenseignore` exists, the tool automatically uses `.gitignore` patterns.\n\nSee [.licenseignore](./.licenseignore) for an example.\n\n## FAQ\n\n### Does it overwrite existing headers?\n\nNo, it intelligently updates them. If a file already has an SPDX header, it will:\n- Update the license identifier if changed\n- Update the copyright year range (e.g., `2023` → `2023-2025`)\n- Preserve the existing header structure\n\n### How does it handle copyright years?\n\nThe tool automatically manages copyright year ranges:\n- First added: `Copyright (C) 2025  Your Name`\n- After modification in 2026: `Copyright (C) 2025-2026  Your Name`\n- If already current: no change\n\n### Can I use it in CI/CD?\n\nYes! Use `--check` mode to fail the build if any files are missing headers:\n\n```yaml\n# GitHub Actions example\n- name: Check license headers\n  run: license --check Apache-2.0 \"Your Name\"\n```\n\nThis returns exit code 1 if any files need updating.\n\n### What files are excluded by default?\n\nThe tool automatically excludes common build artifacts and dependencies:\n- Version control: `.git/`, `.svn/`, `.hg/`\n- Dependencies: `node_modules/`, `vendor/`, `third_party/`\n- Build outputs: `build/`, `dist/`, `target/`, `__pycache__/`\n- Minified files: `*.min.js`, `*.min.css`\n- Lock files: `*.lock`, `*.sum`, `go.mod`\n- Config files: `*.json`, `*.toml`, `*.yaml`\n\n### Can I use custom SPDX license identifiers?\n\nYes! Use any valid SPDX license identifier. Common examples:\n- `MIT`\n- `Apache-2.0`\n- `GPL-3.0-or-later`\n- `BSD-3-Clause`\n- `ISC`\n\nSee [SPDX License List](https://spdx.org/licenses/) for all valid identifiers.\n\n### Does it work with monorepos?\n\nYes! You can:\n- Run it on the entire repo\n- Use `--dir` to target specific packages\n- Use different `.licenseignore` files in different directories\n- Process specific files only\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## License\n\nThis project is licensed under the [Apache License 2.0](./LICENSE).\n\nSee the [NOTICE](./NOTICE) file for additional information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feznix86%2Fpython-license","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feznix86%2Fpython-license","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feznix86%2Fpython-license/lists"}