static-php-py 0.1.6__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. {static_php_py-0.1.6 → static_php_py-0.2.0}/PKG-INFO +3 -7
  2. {static_php_py-0.1.6 → static_php_py-0.2.0}/docs/design-modules.md +1 -2
  3. {static_php_py-0.1.6 → static_php_py-0.2.0}/docs/impl.md +4 -4
  4. {static_php_py-0.1.6 → static_php_py-0.2.0}/pyproject.toml +3 -9
  5. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_sources/_discovery.py +2 -2
  6. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/test_discovery.py +14 -6
  7. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/test_remote_download.py +1 -2
  8. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/test_integration_factory.py +1 -1
  9. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/test_php_factory.py +2 -2
  10. static_php_py-0.1.6/src/static_php_py/_sources/_entrypoints.py +0 -22
  11. static_php_py-0.1.6/tests/_sources/test_entrypoints.py +0 -63
  12. {static_php_py-0.1.6 → static_php_py-0.2.0}/.gitignore +0 -0
  13. {static_php_py-0.1.6 → static_php_py-0.2.0}/LICENSE +0 -0
  14. {static_php_py-0.1.6 → static_php_py-0.2.0}/README.md +0 -0
  15. {static_php_py-0.1.6 → static_php_py-0.2.0}/docs/concept.md +0 -0
  16. {static_php_py-0.1.6 → static_php_py-0.2.0}/docs/design-api.md +0 -0
  17. {static_php_py-0.1.6 → static_php_py-0.2.0}/docs/design-discovery.md +0 -0
  18. {static_php_py-0.1.6 → static_php_py-0.2.0}/docs/design-extraction.md +0 -0
  19. {static_php_py-0.1.6 → static_php_py-0.2.0}/docs/design-packaged.md +0 -0
  20. {static_php_py-0.1.6 → static_php_py-0.2.0}/docs/design-providers.md +0 -0
  21. {static_php_py-0.1.6 → static_php_py-0.2.0}/docs/index.md +0 -0
  22. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/__init__.py +0 -0
  23. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_exceptions.py +0 -0
  24. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_execution.py +0 -0
  25. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_manifest.py +0 -0
  26. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_php.py +0 -0
  27. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_sources/__init__.py +0 -0
  28. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_sources/_cache.py +0 -0
  29. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_sources/_extraction.py +0 -0
  30. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_sources/_integrity.py +0 -0
  31. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_sources/_packaged.py +0 -0
  32. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_sources/_path.py +0 -0
  33. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_sources/_publishing.py +0 -0
  34. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_sources/_remote.py +0 -0
  35. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_types.py +0 -0
  36. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/_version.py +0 -0
  37. {static_php_py-0.1.6 → static_php_py-0.2.0}/src/static_php_py/py.typed +0 -0
  38. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/conftest.py +0 -0
  39. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/test_cache.py +0 -0
  40. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/test_integrity.py +0 -0
  41. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/test_packaged.py +0 -0
  42. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/test_packaged_selection.py +0 -0
  43. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/test_path.py +0 -0
  44. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/test_remote_archive.py +0 -0
  45. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/test_remote_checksum.py +0 -0
  46. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/test_remote_containment.py +0 -0
  47. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/_sources/test_remote_search.py +0 -0
  48. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/conftest.py +0 -0
  49. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/test_exceptions.py +0 -0
  50. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/test_init.py +0 -0
  51. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/test_integration_exec.py +0 -0
  52. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/test_manifest.py +0 -0
  53. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/test_php_exec.py +0 -0
  54. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/test_php_inspect.py +0 -0
  55. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/test_php_require.py +0 -0
  56. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/test_types.py +0 -0
  57. {static_php_py-0.1.6 → static_php_py-0.2.0}/tests/test_version_fallback.py +0 -0
@@ -1,10 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: static-php-py
3
- Version: 0.1.6
3
+ Version: 0.2.0
4
4
  Summary: Python wrapper library for static PHP binaries; code-only execution library
5
- Project-URL: Homepage, https://github.com/samhsu-dev/static-php-py
6
- Project-URL: Repository, https://github.com/samhsu-dev/static-php-py
7
- Project-URL: Issues, https://github.com/samhsu-dev/static-php-py/issues
8
5
  Author: static-php-py contributors
9
6
  License: GNU GENERAL PUBLIC LICENSE
10
7
  Version 2, June 1991
@@ -351,16 +348,15 @@ Classifier: Development Status :: 3 - Alpha
351
348
  Classifier: Intended Audience :: Developers
352
349
  Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2)
353
350
  Classifier: Programming Language :: Python :: 3
354
- Classifier: Programming Language :: Python :: 3.9
355
351
  Classifier: Programming Language :: Python :: 3.10
356
352
  Classifier: Programming Language :: Python :: 3.11
357
353
  Classifier: Programming Language :: Python :: 3.12
358
354
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
359
- Requires-Python: >=3.9
355
+ Requires-Python: >=3.10
360
356
  Requires-Dist: packaging>=21.0
361
357
  Requires-Dist: platformdirs>=4.0.0
362
358
  Provides-Extra: bundled
363
- Requires-Dist: static-php-py-binary==0.1.4; extra == 'bundled'
359
+ Requires-Dist: static-php-py-binary==0.2.0; extra == 'bundled'
364
360
  Description-Content-Type: text/markdown
365
361
 
366
362
  # static-php-py
@@ -25,7 +25,6 @@ distribution.
25
25
  | `_sources/_integrity.py` | Checksum parsing and file digest verification |
26
26
  | `_sources/_cache.py` | Cache root location and remote cache-entry keying |
27
27
  | `_sources/_discovery.py` | `_BundledDiscovery`, companion exception mirroring |
28
- | `_sources/_entrypoints.py` | Entry-point group reading (3.9/3.10 compatibility) |
29
28
 
30
29
  All modules except `__init__.py` are internal (`_`-prefixed); the public API
31
30
  is re-exported from `__init__.py`, whose `__all__` is the single source of
@@ -65,7 +64,7 @@ discovery is by group name, so the module path is companion-internal.
65
64
  - `_sources/_remote.py` → `_sources/test_remote_download.py`, `_sources/test_remote_checksum.py`
66
65
  - `_sources/_packaged.py` → `_sources/test_packaged.py`, `_sources/test_packaged_selection.py`; `_sources/_publishing.py` → exercised through `_sources/test_packaged.py`, `_sources/test_remote_download.py`
67
66
  - `_sources/_extraction.py` full-tree model + `_RemoteProvider` archive flow → `_sources/test_remote_archive.py`, `_sources/test_remote_search.py`, `_sources/test_remote_containment.py`; single-member model → exercised through `_sources/test_packaged.py`
68
- - `_sources/_discovery.py` → `_sources/test_discovery.py`; `_sources/_integrity.py` → `_sources/test_integrity.py`; `_sources/_cache.py` → `_sources/test_cache.py`; `_sources/_entrypoints.py` → `_sources/test_entrypoints.py`
67
+ - `_sources/_discovery.py` → `_sources/test_discovery.py`; `_sources/_integrity.py` → `_sources/test_integrity.py`; `_sources/_cache.py` → `_sources/test_cache.py`
69
68
  - `_manifest.py` → `test_manifest.py`; `_types.py` → `test_types.py`; `_exceptions.py` → `test_exceptions.py`; `_version.py` → `test_version_fallback.py`
70
69
  - Companion: `_php.py` → `test_php.py`; `_exceptions.py` → `test_exceptions.py`
71
70
  - Cross-module integration: `test_integration_exec.py`, `test_integration_factory.py`
@@ -7,10 +7,10 @@
7
7
  - **[php-cli]** `php -d key=value` — must precede the script path or `-r`; placed after the script path it lands in `$argv` instead of applying as ini. Multiple `-d` options compose. Script args after the script path and stdin are readable simultaneously (all verified with the 8.4 binary).
8
8
  - **[php-cli]** `php --version` output — standard binaries report `PHP X.Y.Z (cli) ...`; static-php-cli builds can report `static-php-cli X.Y.Z`; version parsing tries both patterns and returns the bare `X.Y.Z`.
9
9
  - **[stdlib]** `php -m` output parse — drop the `[PHP Modules]` / `[Zend Modules]` header lines and blank lines; lowercase each remaining name (output is mixed case, e.g. `Core`, `tokenizer`, `SPL`).
10
- - **[stdlib]** `importlib.metadata.entry_points(group="static_php_py.binary")` — `PHP.bundled` discovers the companion's binary resolver; empty group → companion not installed → `BinaryNotFoundError` naming the `[bundled]` extra; for the multiple-registration error message use `EntryPoint.name` + `.value` — `.dist` is 3.10+ only (absent on 3.9, verified) and the package supports 3.9.
10
+ - **[stdlib]** `importlib.metadata.entry_points(group="static_php_py.binary")` — `PHP.bundled` discovers the companion's binary resolver; empty group → companion not installed → `BinaryNotFoundError` naming the `[bundled]` extra; for the multiple-registration error message use `EntryPoint.name` + `.value`.
11
11
  - **[stdlib]** `importlib.resources.files(pkg)` returns a `Traversable`, not a `Path`; binaries must be exec'd from a real path, so use `with as_file(files("static_php_py_binary") / name) as p:` — the package name is the companion package, not a bare `"resources"`.
12
12
  - **[stdlib]** `files(package) / "_resources" / name` — traverses into `_resources/` without it being importable as a package; `as_file` yields a usable real path even for a not-yet-existing member, so the same call names the extraction target (`PackagedBinary`).
13
- - **[stdlib]** `Traversable.__truediv__` — join one segment per `/` call; a multi-level `directory` like `"assets/php"` is split on `/` and joined part by part (multi-arg `joinpath` is 3.12+; package supports 3.9).
13
+ - **[stdlib]** `Traversable.__truediv__` — join one segment per `/` call; a multi-level `directory` like `"assets/php"` is split on `/` and joined part by part (multi-arg `joinpath` is 3.12+; package supports 3.10).
14
14
  - **[stdlib]** `zipfile.ZipFile(path)` + `archive.open(info.filename)` — streams a zip member (`PackagedBinary` Windows archives); zip does not preserve the execute bit, so the publish step always chmods; directories via `info.is_dir()`, member basename via `info.filename.rsplit("/", 1)[-1]` (zip names always use `/`).
15
15
  - **[stdlib]** `platform.machine()` + `sys.platform` — host OS/arch detection; the companion selects its PHP tar.gz with it.
16
16
  - **[stdlib]** `tarfile.open(path, "r:gz")` + `archive.extractfile(member)` — the companion streams its PHP binary out of a bundled tar.gz in source/editable installs; tar.gz preserves the Unix execute bit (zip does not), so `chmod` is only a fallback. Member names carry a `./` prefix — match by `member.name.rsplit("/", 1)[-1]`; `extractfile` returns None for non-regular members.
@@ -64,10 +64,10 @@ Design decided (2026-07): signature, verification points, and cache keying live
64
64
  - **[pip]** hash-checking mode — requirement-file convention `pkg==1.0 --hash=sha256:<hex>`, repeatable per requirement; `STRONG_HASHES = ["sha256", "sha384", "sha512"]`, `FAVORITE_HASH = "sha256"`, md5/sha1 rejected; `Hashes.check_against_chunks` streams `hashlib.new(name).update(chunk)` during download, unknown name → `InstallationError`; mismatch → `HashMismatch` and a previously downloaded file is unlinked. Source: `pip/_internal/utils/hashes.py`.
65
65
  - **[huggingface_hub]** `hf_hub_download` — no user-supplied hash; `http_get` checks byte count from `X-Linked-Size`/`Content-Length` after download, mismatch → `EnvironmentError`; sha256 (`sha_fileobj`) compared against the LFS etag only to validate an existing local file; writes to a `.incomplete` temp then moves. Source: `huggingface_hub/file_download.py`.
66
66
  - **[playwright]** (binary-in-wheel peer) — no checksum verification of downloaded browser archives; `curl` over HTTPS from cdn.playwright.dev only. Peers ship without verification; opt-in verification exceeds peer practice.
67
- - **[stdlib]** `hashlib.new(name)` — raises `ValueError` on unknown name; incremental `h.update(chunk)` supports stream hashing; `hashlib.file_digest` is 3.11+ only (package is `requires-python >=3.9`); portable set = `hashlib.algorithms_guaranteed`.
67
+ - **[stdlib]** `hashlib.new(name)` — raises `ValueError` on unknown name; incremental `h.update(chunk)` supports stream hashing; `hashlib.file_digest` is 3.11+ only (package is `requires-python >=3.10`); portable set = `hashlib.algorithms_guaranteed`.
68
68
 
69
69
  Implementation facts:
70
70
 
71
- - **[hashlib]** `hashlib.new(name)` after a frozenset gate on `{sha256, sha384, sha512}` (pip's `STRONG_HASHES`); `hashlib.file_digest` is 3.11+ only — stream with `h.update(chunk)` loops instead (package is `requires-python >=3.9`).
71
+ - **[hashlib]** `hashlib.new(name)` after a frozenset gate on `{sha256, sha384, sha512}` (pip's `STRONG_HASHES`); `hashlib.file_digest` is 3.11+ only — stream with `h.update(chunk)` loops instead (package is `requires-python >=3.10`).
72
72
  - **[hashlib]** digest lengths for hex validation: sha256=64, sha384=96, sha512=128 — `hashlib.new(name).digest_size * 2`.
73
73
  - The hashed artifact is always the pre-extraction `downloaded` file, never the extracted binary; the checksum a user supplies is the published digest of the URL's artifact.
@@ -1,9 +1,9 @@
1
1
  [project]
2
2
  name = "static-php-py"
3
- version = "0.1.6"
3
+ version = "0.2.0"
4
4
  description = "Python wrapper library for static PHP binaries; code-only execution library"
5
5
  readme = "README.md"
6
- requires-python = ">=3.9"
6
+ requires-python = ">=3.10"
7
7
  license = { file = "LICENSE" }
8
8
  authors = [
9
9
  { name = "static-php-py contributors" }
@@ -14,7 +14,6 @@ classifiers = [
14
14
  "Intended Audience :: Developers",
15
15
  "License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
16
16
  "Programming Language :: Python :: 3",
17
- "Programming Language :: Python :: 3.9",
18
17
  "Programming Language :: Python :: 3.10",
19
18
  "Programming Language :: Python :: 3.11",
20
19
  "Programming Language :: Python :: 3.12",
@@ -26,12 +25,7 @@ dependencies = [
26
25
  ]
27
26
 
28
27
  [project.optional-dependencies]
29
- bundled = ["static-php-py-binary==0.1.4"]
30
-
31
- [project.urls]
32
- Homepage = "https://github.com/samhsu-dev/static-php-py"
33
- Repository = "https://github.com/samhsu-dev/static-php-py"
34
- Issues = "https://github.com/samhsu-dev/static-php-py/issues"
28
+ bundled = ["static-php-py-binary==0.2.0"]
35
29
 
36
30
  [build-system]
37
31
  requires = ["hatchling"]
@@ -2,10 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import importlib.metadata
5
6
  from pathlib import Path
6
7
 
7
8
  from .._exceptions import BinaryNotFoundError, InvalidArchiveError, PHPError
8
- from ._entrypoints import entries_for_group
9
9
 
10
10
  _BINARY_GROUP = "static_php_py.binary"
11
11
 
@@ -41,7 +41,7 @@ class _BundledDiscovery:
41
41
  InvalidArchiveError: When the companion's platform archive holds
42
42
  no PHP executable member.
43
43
  """
44
- entries = entries_for_group(_BINARY_GROUP)
44
+ entries = list(importlib.metadata.entry_points(group=_BINARY_GROUP))
45
45
  if not entries:
46
46
  raise BinaryNotFoundError(
47
47
  "No bundled PHP binary found. Install the companion "
@@ -1,6 +1,7 @@
1
1
  """Tests for _BundledDiscovery — companion binary entry-point resolution.
2
2
 
3
3
  Test cases:
4
+ - test_binary_group_registers_companion_resolver -- the installed companion's resolver is the sole static_php_py.binary registration.
4
5
  - TestBundledDiscovery::test_resolve_returns_companion_path -- resolve() returns the path from the single entry point's resolver.
5
6
  - TestBundledDiscovery::test_resolve_raises_when_group_empty -- resolve() raises BinaryNotFoundError naming the [bundled] extra when the group is empty.
6
7
  - TestBundledDiscovery::test_resolve_raises_on_multiple_registrations -- resolve() raises plain PHPError (not BinaryNotFoundError) naming every registration when the group holds more than one entry point.
@@ -11,6 +12,7 @@ Test cases:
11
12
 
12
13
  from __future__ import annotations
13
14
 
15
+ import importlib.metadata
14
16
  from pathlib import Path
15
17
  from unittest.mock import Mock, patch
16
18
 
@@ -44,10 +46,16 @@ def _registration(name: str, value: str) -> Mock:
44
46
  return entry
45
47
 
46
48
 
49
+ def test_binary_group_registers_companion_resolver() -> None:
50
+ """The installed companion's resolver is the sole binary-group registration."""
51
+ entries = importlib.metadata.entry_points(group="static_php_py.binary")
52
+ assert [entry.name for entry in entries] == ["resolver"]
53
+
54
+
47
55
  class TestBundledDiscovery:
48
56
  """Test _BundledDiscovery.resolve()."""
49
57
 
50
- @patch("static_php_py._sources._discovery.entries_for_group")
58
+ @patch("importlib.metadata.entry_points")
51
59
  def test_resolve_returns_companion_path(self, mock_eps: Mock, tmp_path: Path) -> None:
52
60
  """resolve() returns the path from the single registered resolver."""
53
61
  binary = tmp_path / "php"
@@ -60,7 +68,7 @@ class TestBundledDiscovery:
60
68
 
61
69
  assert _BundledDiscovery().resolve() == binary
62
70
 
63
- @patch("static_php_py._sources._discovery.entries_for_group")
71
+ @patch("importlib.metadata.entry_points")
64
72
  def test_resolve_raises_when_group_empty(self, mock_eps: Mock) -> None:
65
73
  """resolve() raises BinaryNotFoundError naming the extra when the group is empty."""
66
74
  mock_eps.return_value = []
@@ -68,7 +76,7 @@ class TestBundledDiscovery:
68
76
  with pytest.raises(BinaryNotFoundError, match=r"static-php-py\[bundled\]"):
69
77
  _BundledDiscovery().resolve()
70
78
 
71
- @patch("static_php_py._sources._discovery.entries_for_group")
79
+ @patch("importlib.metadata.entry_points")
72
80
  def test_resolve_raises_on_multiple_registrations(self, mock_eps: Mock) -> None:
73
81
  """resolve() fails loudly, naming every registration, when the group holds >1."""
74
82
  mock_eps.return_value = [
@@ -84,7 +92,7 @@ class TestBundledDiscovery:
84
92
  assert "'bundled' -> static_php_py_binary._resource:_RESOLVER" in message
85
93
  assert "'rogue' -> rogue_pkg._impl:_RESOLVER" in message
86
94
 
87
- @patch("static_php_py._sources._discovery.entries_for_group")
95
+ @patch("importlib.metadata.entry_points")
88
96
  def test_resolve_translates_companion_binary_not_found(self, mock_eps: Mock) -> None:
89
97
  """A companion-local BinaryNotFoundError becomes this library's PHPError subclass."""
90
98
  original = _Companion.BinaryNotFoundError("no matching archive")
@@ -97,7 +105,7 @@ class TestBundledDiscovery:
97
105
  assert isinstance(exc_info.value, PHPError)
98
106
  assert exc_info.value.__cause__ is original
99
107
 
100
- @patch("static_php_py._sources._discovery.entries_for_group")
108
+ @patch("importlib.metadata.entry_points")
101
109
  def test_resolve_translates_companion_invalid_archive(self, mock_eps: Mock) -> None:
102
110
  """A companion-local InvalidArchiveError becomes this library's PHPError subclass."""
103
111
  original = _Companion.InvalidArchiveError("no PHP member")
@@ -110,7 +118,7 @@ class TestBundledDiscovery:
110
118
  assert isinstance(exc_info.value, PHPError)
111
119
  assert exc_info.value.__cause__ is original
112
120
 
113
- @patch("static_php_py._sources._discovery.entries_for_group")
121
+ @patch("importlib.metadata.entry_points")
114
122
  def test_resolve_propagates_unmirrored_resolver_error(self, mock_eps: Mock) -> None:
115
123
  """An exception whose class name is not mirrored propagates untranslated."""
116
124
  resolver = Mock()
@@ -19,7 +19,6 @@ from __future__ import annotations
19
19
 
20
20
  import http.client
21
21
  import os
22
- import socket
23
22
  import urllib.error
24
23
  from collections.abc import Callable
25
24
  from email.message import Message
@@ -161,7 +160,7 @@ class TestRemoteDownload:
161
160
  """A timeout during download raises DownloadError (design-providers.md DownloadError)."""
162
161
  mock_cache_dir.return_value = str(tmp_path / "cache")
163
162
 
164
- mock_urlopen.side_effect = socket.timeout("timed out")
163
+ mock_urlopen.side_effect = TimeoutError("timed out")
165
164
 
166
165
  provider = _RemoteProvider("https://example.com/php")
167
166
 
@@ -17,7 +17,7 @@ from static_php_py._php import PHP
17
17
  class TestBundledIntegration:
18
18
  """Integration tests for PHP.bundled() static method."""
19
19
 
20
- @patch("static_php_py._sources._discovery.entries_for_group")
20
+ @patch("importlib.metadata.entry_points")
21
21
  def test_bundled_resolves_via_companion(self, mock_eps: Mock, php_binary: Path) -> None:
22
22
  """PHP.bundled() resolves the bundled binary via the companion entry point."""
23
23
  resolver = Mock()
@@ -45,7 +45,7 @@ def _wire_provider(mock_provider_class: Mock, tmp_path: Path) -> Path:
45
45
  class TestPHPBundled:
46
46
  """Test bundled() factory method."""
47
47
 
48
- @patch("static_php_py._sources._discovery.entries_for_group")
48
+ @patch("importlib.metadata.entry_points")
49
49
  def test_bundled_wraps_companion_binary(self, mock_eps: Mock, tmp_path: Path) -> None:
50
50
  """PHP.bundled() wraps the path resolved by the companion entry point."""
51
51
  php_path = tmp_path / "php"
@@ -62,7 +62,7 @@ class TestPHPBundled:
62
62
  assert result.path == php_path
63
63
  resolver.resolve.assert_called_once()
64
64
 
65
- @patch("static_php_py._sources._discovery.entries_for_group")
65
+ @patch("importlib.metadata.entry_points")
66
66
  def test_bundled_raises_when_companion_absent(self, mock_eps: Mock) -> None:
67
67
  """PHP.bundled() raises BinaryNotFoundError naming the extra when empty."""
68
68
  mock_eps.return_value = []
@@ -1,22 +0,0 @@
1
- """Version-tolerant entry-point group queries."""
2
-
3
- from __future__ import annotations
4
-
5
- import importlib.metadata
6
- import sys
7
-
8
-
9
- def entries_for_group(group: str) -> list[importlib.metadata.EntryPoint]:
10
- """Return the installed entry points registered under ``group``.
11
-
12
- Args:
13
- group: Entry-point group name.
14
-
15
- Returns:
16
- Entry points registered under the group; empty when none.
17
- """
18
- if sys.version_info >= (3, 10):
19
- return list(importlib.metadata.entry_points(group=group))
20
- # Python 3.9: entry_points() accepts no selector and returns a
21
- # dict keyed by group name.
22
- return list(importlib.metadata.entry_points().get(group, []))
@@ -1,63 +0,0 @@
1
- """Tests for _entrypoints — version-tolerant entry-point group queries.
2
-
3
- Regression guard for the Python 3.9 crash: ``importlib.metadata.entry_points``
4
- accepts no ``group`` keyword before 3.10, so the query must go through
5
- ``entries_for_group``. The first two tests use the real ``importlib.metadata``
6
- API of the running interpreter; the dict-API tests pin the module to the
7
- 3.9 shape by patching its version gate and ``entry_points`` callable.
8
-
9
- Test cases:
10
- - test_entries_for_group_unknown_group_returns_empty -- an unregistered group yields an empty list on the running interpreter.
11
- - test_entries_for_group_known_group_returns_entries -- the companion's static_php_py.binary group lists its resolver entry.
12
- - test_entries_for_group_dict_api_returns_group_entries -- the Python 3.9 dict-shaped entry_points() result yields the group's entries.
13
- - test_entries_for_group_dict_api_missing_group_returns_empty -- the Python 3.9 dict-shaped result yields an empty list for a missing group.
14
- """
15
-
16
- from __future__ import annotations
17
-
18
- import importlib.metadata
19
- from collections.abc import Iterator
20
- from contextlib import contextmanager
21
- from unittest.mock import patch
22
-
23
- from static_php_py._sources._entrypoints import entries_for_group
24
-
25
- _MODULE = "static_php_py._sources._entrypoints"
26
-
27
-
28
- @contextmanager
29
- def _dict_shaped_entry_points(
30
- groups: dict[str, list[importlib.metadata.EntryPoint]],
31
- ) -> Iterator[None]:
32
- """Pin the module to the Python 3.9 dict-returning entry_points API."""
33
- with (
34
- patch(f"{_MODULE}.sys.version_info", (3, 9, 18, "final", 0)),
35
- patch(f"{_MODULE}.importlib.metadata.entry_points", return_value=groups),
36
- ):
37
- yield
38
-
39
-
40
- def test_entries_for_group_unknown_group_returns_empty() -> None:
41
- """An unregistered group yields an empty list, not an error."""
42
- assert entries_for_group("static_php_py.no_such_group") == []
43
-
44
-
45
- def test_entries_for_group_known_group_returns_entries() -> None:
46
- """The companion's registered resolver is listed for its group."""
47
- assert [entry.name for entry in entries_for_group("static_php_py.binary")] == ["resolver"]
48
-
49
-
50
- def test_entries_for_group_dict_api_returns_group_entries() -> None:
51
- """The 3.9 dict-shaped entry_points() result yields the group's entries."""
52
- entry = importlib.metadata.EntryPoint("resolver", "pkg.mod:obj", "demo.group")
53
-
54
- with _dict_shaped_entry_points({"demo.group": [entry]}):
55
- assert entries_for_group("demo.group") == [entry]
56
-
57
-
58
- def test_entries_for_group_dict_api_missing_group_returns_empty() -> None:
59
- """The 3.9 dict-shaped result yields an empty list for a missing group."""
60
- entry = importlib.metadata.EntryPoint("resolver", "pkg.mod:obj", "demo.group")
61
-
62
- with _dict_shaped_entry_points({"demo.group": [entry]}):
63
- assert entries_for_group("absent.group") == []
File without changes
File without changes
File without changes