Skip to content

Commit 8d8d465

Browse files
committed
fix: usr: make sure github can see the license, add tox files, update reuse
Signed-off-by: Stephen L Arnold <sarnold@vctlabs.com>
1 parent 140149e commit 8d8d465

File tree

5 files changed

+196
-10
lines changed

5 files changed

+196
-10
lines changed

LICENSE

Lines changed: 0 additions & 1 deletion
This file was deleted.

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) <year> <copyright holders>
4+
5+
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:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
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.

LICENSES/MIT.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

LICENSES/MIT.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE

REUSE.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ SPDX-FileCopyrightText = [
66
"2025 Stephen Arnold <sarnold@vctlabs.com>",
77
]
88
SPDX-License-Identifier = "MIT"
9+
10+
[[annotations]]
11+
path = "toxfile.py"
12+
SPDX-FileCopyrightText = "Copyright (c) 2023 Masen Furer"
13+
SPDX-License-Identifier = "MIT"

tox.ini

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
[tox]
2+
envlist = sync,do,dev,changes,clean
3+
skip_missing_interpreters = true
4+
isolated_build = true
5+
skipsdist = true
6+
7+
[base]
8+
deps =
9+
pip>=22.1
10+
11+
[testenv]
12+
skip_install = true
13+
install_command = pip install {opts} {packages}
14+
15+
[testenv:{sync,do}]
16+
envdir = {toxinidir}/.sync
17+
# these 2 tox env cmds share a virtual env using the following plugin
18+
# https://github.com/masenf/tox-ignore-env-name-mismatch
19+
runner = ignore_env_name_mismatch
20+
21+
description =
22+
do: Run cmd following "--" from .sync environment, e.g. "tox -e do -- repolite --show"
23+
sync: Install repolite and use it for cloning worflow deps
24+
25+
passenv =
26+
REPO_CFG
27+
DISPLAY
28+
XAUTHORITY
29+
HOME
30+
USERNAME
31+
USER
32+
CI
33+
LANG
34+
LC_COLLATE
35+
SSH_*
36+
GID
37+
UID
38+
XDG_*
39+
PYTHONIOENCODING
40+
PIP_DOWNLOAD_CACHE
41+
42+
deps =
43+
# logging_tree
44+
{[base]deps}
45+
-r requirements-sync.txt
46+
47+
commands =
48+
sync: repolite {posargs:--quiet}
49+
do: {posargs:python -c 'print("No cmd provided")'}
50+
51+
[testenv:dev]
52+
envdir = {toxinidir}/.venv
53+
54+
description =
55+
Create a devel .venv with repolite-managed deps
56+
57+
passenv =
58+
DISPLAY
59+
XAUTHORITY
60+
HOME
61+
USERNAME
62+
USER
63+
CI
64+
LANG
65+
LC_COLLATE
66+
SSH_*
67+
GID
68+
UID
69+
XDG_*
70+
PYTHONIOENCODING
71+
PIP_DOWNLOAD_CACHE
72+
73+
deps =
74+
# logging_tree
75+
{[base]deps}
76+
reuse
77+
78+
commands =
79+
reuse {posargs:"lint"}
80+
81+
[testenv:changes]
82+
skip_install = true
83+
always_copy = False
84+
85+
allowlist_externals =
86+
bash
87+
88+
deps =
89+
{[base]deps}
90+
gitchangelog @ https://github.com/sarnold/gitchangelog/releases/download/3.2.0/gitchangelog-3.2.0-py3-none-any.whl
91+
92+
commands =
93+
bash -c 'gitchangelog {posargs} > CHANGELOG.rst'
94+
95+
[testenv:clean]
96+
skip_install = true
97+
allowlist_externals =
98+
bash
99+
100+
deps =
101+
pip>=21.1
102+
103+
commands =
104+
bash -c 'rm -rf ext/*/dist ext/*/build __pycache__'

toxfile.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"""
2+
https://github.com/masenf/tox-ignore-env-name-mismatch
3+
4+
MIT License
5+
Copyright (c) 2023 Masen Furer
6+
"""
7+
from contextlib import contextmanager
8+
from typing import Any, Iterator, Optional, Sequence, Tuple
9+
10+
from tox.plugin import impl
11+
from tox.tox_env.api import ToxEnv
12+
from tox.tox_env.info import Info
13+
from tox.tox_env.python.virtual_env.runner import VirtualEnvRunner
14+
from tox.tox_env.register import ToxEnvRegister
15+
16+
17+
class FilteredInfo(Info):
18+
"""Subclass of Info that optionally filters specific keys during compare()."""
19+
20+
def __init__(
21+
self,
22+
*args: Any,
23+
filter_keys: Optional[Sequence[str]] = None,
24+
filter_section: Optional[str] = None,
25+
**kwargs: Any,
26+
):
27+
"""
28+
:param filter_keys: key names to pop from value
29+
:param filter_section: if specified, only pop filter_keys when the compared section matches
30+
31+
All other args and kwargs are passed to super().__init__
32+
"""
33+
self.filter_keys = filter_keys
34+
self.filter_section = filter_section
35+
super().__init__(*args, **kwargs)
36+
37+
@contextmanager
38+
def compare(
39+
self,
40+
value: Any,
41+
section: str,
42+
sub_section: Optional[str] = None,
43+
) -> Iterator[Tuple[bool, Optional[Any]]]:
44+
"""Perform comparison and update cached info after filtering `value`."""
45+
if self.filter_section is None or section == self.filter_section:
46+
try:
47+
value = value.copy()
48+
except AttributeError: # pragma: no cover
49+
pass
50+
else:
51+
for fkey in self.filter_keys or []:
52+
value.pop(fkey, None)
53+
with super().compare(value, section, sub_section) as rv:
54+
yield rv
55+
56+
57+
class IgnoreEnvNameMismatchVirtualEnvRunner(VirtualEnvRunner):
58+
"""EnvRunner that does NOT save the env name as part of the cached info."""
59+
60+
@staticmethod
61+
def id() -> str:
62+
return "ignore_env_name_mismatch"
63+
64+
@property
65+
def cache(self) -> Info:
66+
"""Return a modified Info class that does NOT pass "name" key to `Info.compare`."""
67+
return FilteredInfo(
68+
self.env_dir,
69+
filter_keys=["name"],
70+
filter_section=ToxEnv.__name__,
71+
)
72+
73+
74+
@impl
75+
def tox_register_tox_env(register: ToxEnvRegister) -> None:
76+
"""tox4 entry point: add IgnoreEnvNameMismatchVirtualEnvRunner to registry."""
77+
register.add_run_env(IgnoreEnvNameMismatchVirtualEnvRunner)

0 commit comments

Comments
 (0)