Skip to content

Commit b1a00ac

Browse files
[SYNC] branch 'fix-lowercase-files-208' with 'dev-v5.6'
* dev-v5.6: [STYLE] Cleanup fixes from GHI #208 for release [STYLE] Cleanup fixes from GHI #292 for release [DOCUMENTATION] Update documentation and configs to match [DOCUMENTATION] Create SECURITY.md [FIX] Resolve regression in tests due to abbriviations in updated packages (- WIP #292 -) [FIX] resolve flaky test_different_python with improved diognostics (- WIP GHI #292 -) [FIX] resolve regression for test_fail_on_partial_match (- WIP GHI #292 -) [FIX] resolve regression for test_allow_only_partial (- WIP GHI #292 -) [DEBUG] revert some unstable changes to makefile Bump cryptography from 46.0.2 to 46.0.5
2 parents 8409b5d + 061cb74 commit b1a00ac

File tree

7 files changed

+67
-46
lines changed

7 files changed

+67
-46
lines changed

CONTRIBUTING.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,26 @@ The design policy of `pip-licenses` is as follows.
1313

1414
1. Fork this repository on your GitHub account.
1515
2. Create a branch to represent changes.
16-
* Branch name does **NOT** need `feature/` prefix. Because git-flow is too complicated.
17-
3. Create a new venv environment.
18-
4. Install package for development via `make setup` .
16+
* Branch name does **NOT** need `feature/` prefix. Because git-flow is configured differently for maintainers.
17+
3. Create a new venv environment and Install package for development via `make setup` .
1918
* Dependencies are managed by [pip-tools](https://pypi.org/project/pip-tools/).
20-
* If you want to add dependency packages for development, edit [dev-requirements.in](https://github.com/raimon49/pip-licenses/blob/master/dev-requirements.in) file and run `make update-depends` .
21-
* When you want to install the code under development, run `make local-install` .
19+
* If you want to add dependency packages for development, edit [the dev entry in pyproject.toml](https://github.com/raimon49/pip-licenses/blob/master/pyproject.toml) file and run `make update-depends` .
20+
* If you want to install the code under development, run `make local-install` .
2221

2322
## Implementation and testing
2423

25-
* `pip-licenses` always measures code coverage for code quality. If you implement the new feature, please also write unit test in [test\_piplicenses.py](https://github.com/raimon49/pip-licenses/blob/master/test_piplicenses.py).
24+
* `pip-licenses` always measures code coverage for code quality. If you implement a new feature, please also write unit test in [test\_piplicenses.py](https://github.com/raimon49/pip-licenses/blob/master/test_piplicenses.py).
2625
* Tests can be run with `make test` .
2726
* Code conventions follow the [PEP 8](https://www.python.org/dev/peps/pep-0008/).
2827
* You can format the code by running `make lint` .
29-
* Send pull request to master branch.
28+
* Send pull request to master branch. Maintainer(s) may adjust PRs to the appropriate development branch as realevant.
29+
30+
## Security policy
31+
32+
If you find a significant vulnerability, or evidence of one, please report it privately.
33+
34+
* We prefer that you use the
35+
[GitHub mechanism for privately reporting a vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability).
36+
Under the
37+
[main repository's security tab](https://github.com/raimon49/pip-licenses/security), click
38+
"Report a vulnerability" to open the advisory form.

Makefile

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env make -f
22

3-
# Pip-Licenses
3+
# Pip-Licenses Makefile
44
# ..................................
55
# Copyright (c) 2018-2024, raimon
66
# Copyright (c) 2024-2026, Mr. Walls
@@ -69,7 +69,7 @@ ifeq "$(PYTHON)" ""
6969
PYTHON=$(PY_CMD) $(PY_ARGS)
7070
endif
7171

72-
# SUPPORT PEP-517
72+
# SUPPORT PEP-517 with --use-pep517 when available
7373

7474
ifndef PIP_COMMON_FLAGS
7575
# Define probable pip install flags based on python command
@@ -81,24 +81,7 @@ ifndef PIP_COMMON_FLAGS
8181
PIP_PREFIX_FLAGS := --no-input
8282
endif
8383
# Define common pip install flags
84-
PIP_COMMON_FLAGS := --use-pep517 --exists-action s --upgrade --upgrade-strategy eager
85-
endif
86-
87-
# Define environment-specific pip install flags
88-
ifeq ($(shell uname),Darwin)
89-
# Check if pip supports --break-system-packages
90-
PIP_VERSION := $(shell $(PYTHON) -m pip --version | awk '{print $2}')
91-
PIP_MAJOR := $(word 2,$(subst ., ,$(PIP_VERSION)))
92-
PIP_MINOR := $(word 3,$(subst ., ,$(PIP_VERSION)))
93-
# --break-system-packages was added to pip in version 23.0.1 so check for 23.1+
94-
ifeq ($(shell [ $(PIP_MAJOR) -ge 24 ] || { [ $(PIP_MAJOR) -eq 23 ] && [ $(PIP_MINOR) -ge 1 ]; } && printf "%d" 1 || printf "%d" 0), 1)
95-
# workaround for specific xcode python + homebrew
96-
PIP_ENV_FLAGS := --break-system-packages
97-
else
98-
PIP_ENV_FLAGS :=
99-
endif
100-
else
101-
PIP_ENV_FLAGS :=
84+
PIP_COMMON_FLAGS := --exists-action s --upgrade --upgrade-strategy eager
10285
endif
10386

10487
ifeq "$(LOG)" ""
@@ -162,14 +145,14 @@ $(VENV_NAME): venv
162145
$(QUIET)test -d $(VENV_NAME) || exit 1 ;
163146

164147
setup: $(VENV_NAME)
165-
$(QUIET)$(VENV_NAME)/bin/python -m ensurepip || exit 2 ;
166-
$(VENV_NAME)/bin/python -m pip $(PIP_PREFIX_FLAGS) install $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) -r $(DEV_DEPENDS).txt
148+
$(QUIET)$(VENV_NAME)/bin/python -B -m ensurepip || exit 2 ;
149+
$(VENV_NAME)/bin/python -B -m pip $(PIP_PREFIX_FLAGS) install $(PIP_COMMON_FLAGS) -r $(DEV_DEPENDS).txt
167150

168151
local-install: $(VENV_NAME)
169-
$(VENV_NAME)/bin/python -m pip $(PIP_PREFIX_FLAGS) install $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) -e .
152+
$(VENV_NAME)/bin/python -m pip $(PIP_PREFIX_FLAGS) install $(PIP_COMMON_FLAGS) -e .
170153

171154
local-uninstall:
172-
$(VENV_NAME)/bin/python -m pip $(PIP_PREFIX_FLAGS) uninstall $(PIP_COMMON_FLAGS) $(PIP_ENV_FLAGS) -y pip-licenses
155+
$(VENV_NAME)/bin/python -m pip $(PIP_PREFIX_FLAGS) uninstall -y pip-licenses
173156

174157
local-ci-check: build lint test
175158
$(QUIET)$(DO_FAIL) # does nothing successfully (if reached)
@@ -183,8 +166,8 @@ build: clean
183166
$(VENV_NAME)/bin/python -m build
184167

185168
lint:
186-
$(VENV_NAME)/bin/python -m ruff check .
187-
$(VENV_NAME)/bin/python -m ruff format .
169+
$(VENV_NAME)/bin/python -m ruff --config pyproject.toml check .
170+
$(VENV_NAME)/bin/python -m ruff --config pyproject.toml format .
188171
$(VENV_NAME)/bin/python -m mypy --install-types --non-interactive .
189172

190173
test:

SECURITY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Security
2+
3+
If you find a significant vulnerability, or evidence of one, please report it privately.
4+
5+
* We prefer that you use the
6+
[GitHub mechanism for privately reporting a vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability).
7+
Under the
8+
[main repository's security tab](https://github.com/raimon49/pip-licenses/security), click
9+
"Report a vulnerability" to open the advisory form.

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ click==8.1.8
1818
# via pip-tools
1919
coverage[toml]==7.10.7
2020
# via pytest-cov
21-
cryptography==46.0.4
21+
cryptography==46.0.5
2222
# via secretstorage
2323
docutils==0.22.4
2424
# via

piplicenses.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,13 @@ def get_pkg_included_file(
346346

347347
def get_pkg_info(pkg: Distribution) -> dict[str, str | list[str]]:
348348
license_file, license_text = get_pkg_included_file(
349-
pkg, "[Ll][Ii][Cc][Ee][Nn][CScs][Ee].*|[Cc][Oo][Pp][Yy][Ii][Nn][Gg].*",
349+
pkg,
350+
"[Ll][Ii][Cc][Ee][Nn][CScs][Ee].*|[Cc][Oo][Pp][Yy][Ii][Nn][Gg].*",
350351
)
351352
notice_file, notice_text = get_pkg_included_file(pkg, "NOTICE.*")
352353
other_file, other_text = get_pkg_included_file(
353-
pkg, "[Aa][Uu][Tt][Hh][Oo][Rr][Ss].*",
354+
pkg,
355+
"[Aa][Uu][Tt][Hh][Oo][Rr][Ss].*",
354356
)
355357
pkg_info: dict[str, str | list[str]] = {
356358
"name": pkg.metadata["name"],

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ ignore = [
9797
isort.known-first-party = ["piplicenses"]
9898

9999
[tool.mypy]
100-
exclude = ["venv"]
100+
exclude = ["venv"] # and thus venv[subprocess].CalledProcessError
101101

102102
[tool.coverage.run]
103103
include = ["piplicenses.py"]

test_piplicenses.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,10 @@ def test_allow_only(monkeypatch) -> None:
938938
assert (
939939
"license MIT License not in allow-only licenses was found for "
940940
"package" in mocked_stderr.printed
941-
)
941+
) or (
942+
"license MIT not in allow-only licenses was found for "
943+
"package" in mocked_stderr.printed
944+
) # GHI #292 -- MIT License has become abreviated to just MIT for some
942945

943946

944947
def test_allow_only_partial(monkeypatch) -> None:
@@ -965,7 +968,9 @@ def test_allow_only_partial(monkeypatch) -> None:
965968

966969
assert "" == mocked_stdout.printed
967970
assert (
968-
"license MIT License not in allow-only licenses was found for "
971+
"license MIT" in mocked_stderr.printed
972+
) and ( # GHI #292 -- partial match may ommit 'License'
973+
" not in allow-only licenses was found for "
969974
"package" in mocked_stderr.printed
970975
)
971976

@@ -995,7 +1000,10 @@ def test_allow_only_with_empty_tokens(monkeypatch) -> None:
9951000
assert (
9961001
"license MIT License not in allow-only licenses was found for "
9971002
"package" in mocked_stderr.printed
998-
)
1003+
) or (
1004+
"license MIT not in allow-only licenses was found for "
1005+
"package" in mocked_stderr.printed
1006+
) # GHI #292 -- MIT License has become abreviated to just MIT for some
9991007

10001008

10011009
def test_fail_on_with_empty_tokens(monkeypatch) -> None:
@@ -1019,16 +1027,25 @@ def test_fail_on_with_empty_tokens(monkeypatch) -> None:
10191027

10201028
def test_different_python() -> None:
10211029
import tempfile
1030+
from venv import ( # type: ignore[attr-defined]
1031+
subprocess as venv_subprocess,
1032+
)
1033+
1034+
_warning_skip: str = "Testing via venv unsupported. Skipping."
10221035

10231036
class TempEnvBuild(venv.EnvBuilder):
10241037
def post_setup(self, context: SimpleNamespace) -> None:
10251038
self.context = context
10261039

10271040
with tempfile.TemporaryDirectory() as target_dir_path:
1028-
venv_builder = TempEnvBuild(with_pip=True)
1029-
venv_builder.create(str(target_dir_path))
1030-
python_exec = venv_builder.context.env_exe
1031-
python_arg = f"--python={python_exec}"
1041+
python_exec = None
1042+
try:
1043+
venv_builder = TempEnvBuild(with_pip=True)
1044+
venv_builder.create(str(target_dir_path))
1045+
python_exec = venv_builder.context.env_exe
1046+
except venv_subprocess.CalledProcessError as skip_cause:
1047+
raise unittest.SkipTest(_warning_skip) from skip_cause
1048+
python_arg = f"--python={python_exec}" if python_exec else ""
10321049
args = create_parser().parse_args([python_arg, "-s", "-f=json"])
10331050
pkgs = get_packages(args)
10341051
package_names = sorted(set(p["name"] for p in pkgs))
@@ -1074,8 +1091,9 @@ def test_fail_on_partial_match(monkeypatch) -> None:
10741091

10751092
assert "" == mocked_stdout.printed
10761093
assert (
1077-
"fail-on license MIT License was found for "
1078-
"package" in mocked_stderr.printed
1094+
"fail-on license MIT" in mocked_stderr.printed
1095+
) and ( # GHI 292 -- partial match may ommit 'License'
1096+
" was found for package" in mocked_stderr.printed
10791097
)
10801098

10811099

0 commit comments

Comments
 (0)