././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1748823443.6148043 coherent_licensed-0.5.2/0000755000175100001660000000000015017166624014606 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1748823425.7608008 coherent_licensed-0.5.2/(meta)/0000755000175100001660000000000015017166602015651 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1748823425.7608008 coherent_licensed-0.5.2/(meta)/entry_points.txt0000644000175100001660000000014015017166602021142 0ustar00runnerdocker[setuptools.finalize_distribution_options] inject-license = coherent.licensed.setuptools:inject ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1748823425.7608008 coherent_licensed-0.5.2/coherent/licensed/__init__.py0000644000175100001660000000102715017166602022310 0ustar00runnerdockerimport datetime import re import urllib.request def inject_year(text): pattern = re.compile(r'\[yyyy\]|') return pattern.sub(str(datetime.date.today().year), text) def resolve(expression): """ Resolve an SPDX license expression into a license text. >>> resolve('MIT') 'MIT License...' """ url = f"https://raw.githubusercontent.com/spdx/license-list-data/main/text/{expression}.txt" with urllib.request.urlopen(url) as response: return inject_year(response.read().decode('utf-8')) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1748823425.7608008 coherent_licensed-0.5.2/coherent/licensed/_functools.py0000644000175100001660000000152215017166602022724 0ustar00runnerdockerimport functools # from jaraco.functools 4.1 def compose(*funcs): def compose_two(f1, f2): return lambda *args, **kwargs: f1(f2(*args, **kwargs)) return functools.reduce(compose_two, funcs) def apply(transform): def wrap(func): return functools.wraps(func)(compose(transform, func)) return wrap def result_invoke(action): def wrap(func): @functools.wraps(func) def wrapper(*args, **kwargs): result = func(*args, **kwargs) action(result) return result return wrapper return wrap def identity(x): return x def bypass_when(check, *, _op=identity): def decorate(func): @functools.wraps(func) def wrapper(param, /): return param if _op(check) else func(param) return wrapper return decorate ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1748823425.7608008 coherent_licensed-0.5.2/coherent/licensed/setuptools.py0000644000175100001660000000276115017166602023000 0ustar00runnerdockerimport contextlib import functools import os import pathlib import warnings from . import resolve from ._functools import apply, bypass_when, result_invoke @bypass_when(os.environ.get('COHERENT_LICENSED_UNUSED_ACTION', 'warn') == 'ignore') def warn_if_false(enabled): enabled or warnings.warn( "Avoid installing this plugin for projects that don't depend on it." ) def dist_root(dist): return pathlib.Path(dist.src_root or '') @result_invoke(warn_if_false) @apply(bool) def enabled(dist): root = dist_root(dist) with contextlib.suppress(FileNotFoundError): project = root.joinpath('pyproject.toml').read_text(encoding='utf-8') return 'coherent.licensed' in project def _finalize_license_files(dist, orig): """ Resolve the license expression into a license file. """ if not enabled(dist): return orig() license = dist_root(dist) / 'LICENSE' dist.metadata.license_files = [str(license)] if license.exists(): return license.write_text(resolve(dist.metadata.license_expression)) def inject(dist): """ Patch the dist to resolve the license expression. This hook is called before `dist.parse_config_files` has been called, so the license expression has not been loaded yet, so patch _finalize_license_files to write out the license after expressions are loaded. """ dist._finalize_license_files = functools.partial( _finalize_license_files, dist, orig=dist._finalize_license_files ) ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1748823444.740903 coherent_licensed-0.5.2/PKG-INFO0000644000000000000000000000363315017166625013234 0ustar00Metadata-Version: 2.4 Name: coherent.licensed Version: 0.5.2 Author-Email: "Jason R. Coombs" Summary: License management tooling for Coherent System and skeleton projects Requires-Python: >= 3.9 Provides-Extra: doc Provides-Extra: test Project-URL: Source, https://github.com/coherent-oss/coherent.licensed Description-Content-Type: text/markdown Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only License-Expression: MIT [![](https://img.shields.io/pypi/v/coherent.licensed)](https://pypi.org/project/coherent.licensed) ![](https://img.shields.io/pypi/pyversions/coherent.licensed) [![](https://github.com/coherent-oss/coherent.licensed/actions/workflows/main.yml/badge.svg)](https://github.com/coherent-oss/coherent.licensed/actions?query=workflow%3A%22tests%22) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Coherent Software Development System](https://img.shields.io/badge/coherent%20system-informational)](https://github.com/coherent-oss/system) This library was built for [coherent.build](https://github.com/coherent-oss/coherent.build) and [skeleton](https://blog.jaraco.com/skeleton) projects to inject a license file at build time to reflect the license declared in the License Expression. ## Setuptools Plugin ### Installation This plugin is intended only to be installed as a build requirement. Avoid installing it except temporarily for a build that requires it. If it is installed to a shared/system environment, it will be activated for all Setuptools builds and emit a warning. If the target ecosystem expects build artifacts to be installed to a shared environment, the warning can be disabled by setting `COHERENT_LICENSED_UNUSED_ACTION=ignore`. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1748823444.7428737 coherent_licensed-0.5.2/pyproject.toml0000644000000000000000000000140515017166625015046 0ustar00[build-system] requires = ["flit-core >=3.11, <4"] build-backend = "flit_core.buildapi" [project] name = "coherent.licensed" version = "0.5.2" description = "License management tooling for Coherent System and skeleton projects" readme = "README.md" requires-python = ">= 3.9" dependencies = [] classifiers = ["Development Status :: 4 - Beta", "Intended Audience :: Developers", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only"] license = "MIT" [[project.authors]] name = "Jason R. Coombs" email = "jaraco@jaraco.com" [project.urls] Source = "https://github.com/coherent-oss/coherent.licensed" [project.entry-points."setuptools.finalize_distribution_options"] inject-license = "coherent.licensed.setuptools:inject" [project.scripts] ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1748823444.7429936 coherent_licensed-0.5.2/README.md0000644000000000000000000000252415017166625013414 0ustar00[![](https://img.shields.io/pypi/v/coherent.licensed)](https://pypi.org/project/coherent.licensed) ![](https://img.shields.io/pypi/pyversions/coherent.licensed) [![](https://github.com/coherent-oss/coherent.licensed/actions/workflows/main.yml/badge.svg)](https://github.com/coherent-oss/coherent.licensed/actions?query=workflow%3A%22tests%22) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Coherent Software Development System](https://img.shields.io/badge/coherent%20system-informational)](https://github.com/coherent-oss/system) This library was built for [coherent.build](https://github.com/coherent-oss/coherent.build) and [skeleton](https://blog.jaraco.com/skeleton) projects to inject a license file at build time to reflect the license declared in the License Expression. ## Setuptools Plugin ### Installation This plugin is intended only to be installed as a build requirement. Avoid installing it except temporarily for a build that requires it. If it is installed to a shared/system environment, it will be activated for all Setuptools builds and emit a warning. If the target ecosystem expects build artifacts to be installed to a shared environment, the warning can be disabled by setting `COHERENT_LICENSED_UNUSED_ACTION=ignore`. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1748823444.7911685 coherent_licensed-0.5.2/LICENSE0000644000000000000000000000206415017166625013141 0ustar00MIT License Copyright (c) 2025 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.